]> git.uio.no Git - u/mrichter/AliRoot.git/blame - cmake/GenParFile.cmake
Extra header added to the list
[u/mrichter/AliRoot.git] / cmake / GenParFile.cmake
CommitLineData
7a05f29e 1# This CMake function generates a target that, in turn, will generate a PARfile for the given
2# library.
0f2e807c 3#
4# Usage: in the CMakeLists.txt, for a given library, add the following:
42ad3e35 5# add_target_parfile(${MODULE} "${SRCS}" "${HDRS}" "${MODULE}LinkDef.h" "${LIBDEPS}" ["extrainclude1 extrainclude2..."])
0f2e807c 6#
7# Arguments are, in order:
8# - library's name: for libBLAHBLAH it will generate a target BLAHBLAH.par
9# - source files: classes to include in the PARfile, they must be exactly the ones used to generate
10# the library
11# - headers
12# - the LinkDef used by ROOT
13# - dependent libraries: used to generate the rootmap
42ad3e35 14# - extra include paths (optional): passed during compilation
0f2e807c 15#
16# To generate a parfile, if enabled in its CMakeLists.txt, go to the build directory and run:
17# make BLAHBLAH.par
18
7a05f29e 19function(add_target_parfile PARMODULE PARSOURCES PARHEADERS PARLINKDEF PARLIBDEPS)
b24da1d3 20
7a05f29e 21 # Libraries: result is a space-separated string
22 foreach(_THISLIB ${PARLIBDEPS})
23 set(_PARLIBDEPS "${_PARLIBDEPS} lib${_THISLIB}")
0c9d4db8 24 endforeach()
25 string(STRIP "${_PARLIBDEPS}" PARLIBDEPS)
b24da1d3 26
7a05f29e 27 # Export variables: used in configure_file()
b24da1d3 28 set(PARMODULE "${PARMODULE}")
7a05f29e 29 string(REPLACE ";" " " PARSOURCES_FLAT "${PARSOURCES}")
a05f4fbd 30 string(REPLACE ";" " " PARHEADERS_FLAT "${PARHEADERS}")
b24da1d3 31
7a05f29e 32 #message(STATUS "[add_target_parfile] Library (space-separated): ${PARMODULE}")
33 #message(STATUS "[add_target_parfile] Sources (list): ${PARSOURCES}")
a05f4fbd 34 #message(STATUS "[add_target_parfile] Headers (list): ${PARHEADERS}")
7a05f29e 35 #message(STATUS "[add_target_parfile] Dependencies (space-separated): ${PARLIBDEPS}")
0c9d4db8 36
42ad3e35 37 if(NOT "${ARGV5}" STREQUAL "")
38 # Optional: extra includes, space-separated
39 set(PAREXTRAINCLUDES "${ARGV5}")
40 #message(STATUS "[add_target_parfile] Extra Includes (space-separated): ${PAREXTRAINCLUDES}")
41 endif()
b24da1d3 42
43 # PARfile output directory (the one we will tar)
44 set(PARDIR ${CMAKE_CURRENT_BINARY_DIR}/PARfiles/${PARMODULE})
45
46 # Create base directory for this module's PARfile: this is the directory we will tar
47 # This works as "mkdir -p" (i.e. it's recursive and creates parents)
48 file(MAKE_DIRECTORY ${PARDIR}/PROOF-INF)
49
50 # Create Makefile
51 configure_file(
52 ${PROJECT_SOURCE_DIR}/cmake/PARfiles/Makefile.in
53 ${PARDIR}/Makefile
54 @ONLY
55 )
56
57 # Create BUILD.sh
58 configure_file(
59 ${PROJECT_SOURCE_DIR}/cmake/PARfiles/BUILD.sh.in
60 ${PARDIR}/PROOF-INF/BUILD.sh
61 @ONLY
62 )
63 execute_process(COMMAND chmod a+x ${PARDIR}/PROOF-INF/BUILD.sh)
64
65 # Create SETUP.C
66 configure_file(
67 ${PROJECT_SOURCE_DIR}/cmake/PARfiles/SETUP.C.in
68 ${PARDIR}/PROOF-INF/SETUP.C
69 @ONLY
70 )
71
72 # Target for creating PARfile (would stop after the first failed COMMAND)
73 add_custom_target("${PARMODULE}.par"
257c50bf 74 COMMAND rsync --relative ${PARSOURCES} ${PARHEADERS} ${PARLINKDEF} ${PARDIR}/
b24da1d3 75 COMMAND tar -C ${PARDIR}/.. -czf ${PARDIR}/../${PARMODULE}.par ${PARMODULE}/
257c50bf 76 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
b24da1d3 77 )
78
8b703647 79 # Install target
80 install(FILES ${PARDIR}/../${PARMODULE}.par DESTINATION PARfiles OPTIONAL)
81
9596d7e9 82 # Add this module to the list of generated PARfiles
83 list(APPEND ALIPARFILES ${PARMODULE})
84 set(ALIPARFILES ${ALIPARFILES} CACHE INTERNAL "ALIPARFILES")
85
7a05f29e 86endfunction()