1 # This CMake macro generates a target that, in turn, will generate a PARfile for the given library.
3 # Usage: in the CMakeLists.txt, for a given library, add the following:
4 # add_target_parfile(${MODULE} "${SRCS}" "${HDRS}" "${MODULE}LinkDef.h" "${LIBDEPS}")
6 # Arguments are, in order:
7 # - library's name: for libBLAHBLAH it will generate a target BLAHBLAH.par
8 # - source files: classes to include in the PARfile, they must be exactly the ones used to generate
11 # - the LinkDef used by ROOT
12 # - dependent libraries: used to generate the rootmap
14 # To generate a parfile, if enabled in its CMakeLists.txt, go to the build directory and run:
17 macro(add_target_parfile PARMODULE PARSOURCES PARHEADERS PARLINKDEF PARLIBDEPS)
19 message(STATUS "PARfile generation: ${PARMODULE}")
22 foreach(THISLIB ${PARLIBDEPS})
23 set(_PARLIBDEPS "${_PARLIBDEPS} lib${THISLIB}")
25 string(STRIP "${_PARLIBDEPS}" PARLIBDEPS)
28 set(PARMODULE "${PARMODULE}")
30 message(STATUS "--> Module: ${PARMODULE}")
31 message(STATUS "--> Sources: ${PARSOURCES}")
32 message(STATUS "--> Deps: ${PARLIBDEPS}")
34 foreach(LOOPVAR ${PARSOURCES})
35 message(STATUS "----> ${LOOPVAR}")
38 # PARfile output directory (the one we will tar)
39 set(PARDIR ${CMAKE_CURRENT_BINARY_DIR}/PARfiles/${PARMODULE})
41 # Create base directory for this module's PARfile: this is the directory we will tar
42 # This works as "mkdir -p" (i.e. it's recursive and creates parents)
43 file(MAKE_DIRECTORY ${PARDIR}/PROOF-INF)
47 ${PROJECT_SOURCE_DIR}/cmake/PARfiles/Makefile.in
54 ${PROJECT_SOURCE_DIR}/cmake/PARfiles/BUILD.sh.in
55 ${PARDIR}/PROOF-INF/BUILD.sh
58 execute_process(COMMAND chmod a+x ${PARDIR}/PROOF-INF/BUILD.sh)
62 ${PROJECT_SOURCE_DIR}/cmake/PARfiles/SETUP.C.in
63 ${PARDIR}/PROOF-INF/SETUP.C
67 # Target for creating PARfile (would stop after the first failed COMMAND)
68 add_custom_target("${PARMODULE}.par"
69 COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ${PARSOURCES} ${PARHEADERS} ${PARLINKDEF} ${PARDIR}/
70 COMMAND cmake -E copy ${ROOT_ETCDIR}/Makefile.arch ${PARDIR}/
71 COMMAND tar -C ${PARDIR}/.. -czf ${PARDIR}/../${PARMODULE}.par ${PARMODULE}/