PAR: Makefile works on rebuild and has colors
[u/mrichter/AliRoot.git] / cmake / GenParFile.cmake
CommitLineData
b24da1d3 1macro(add_parfile PARMODULE PARSOURCES PARHEADERS PARLINKDEF)
2
3 message(STATUS "PARfile generation: ${PARMODULE}")
4 message(STATUS "--> Module: ${PARMODULE}")
5 message(STATUS "--> Sources: ${PARSOURCES}")
6
7 # Export variable
8 set(PARMODULE "${PARMODULE}")
9
10 foreach(LOOPVAR ${PARSOURCES})
11 message(STATUS "----> ${LOOPVAR}")
12 endforeach()
13
14 # PARfile output directory (the one we will tar)
15 set(PARDIR ${CMAKE_CURRENT_BINARY_DIR}/PARfiles/${PARMODULE})
16
17 # Create base directory for this module's PARfile: this is the directory we will tar
18 # This works as "mkdir -p" (i.e. it's recursive and creates parents)
19 file(MAKE_DIRECTORY ${PARDIR}/PROOF-INF)
20
21 # Create Makefile
22 configure_file(
23 ${PROJECT_SOURCE_DIR}/cmake/PARfiles/Makefile.in
24 ${PARDIR}/Makefile
25 @ONLY
26 )
27
28 # Create BUILD.sh
29 configure_file(
30 ${PROJECT_SOURCE_DIR}/cmake/PARfiles/BUILD.sh.in
31 ${PARDIR}/PROOF-INF/BUILD.sh
32 @ONLY
33 )
34 execute_process(COMMAND chmod a+x ${PARDIR}/PROOF-INF/BUILD.sh)
35
36 # Create SETUP.C
37 configure_file(
38 ${PROJECT_SOURCE_DIR}/cmake/PARfiles/SETUP.C.in
39 ${PARDIR}/PROOF-INF/SETUP.C
40 @ONLY
41 )
42
43 # Target for creating PARfile (would stop after the first failed COMMAND)
44 add_custom_target("${PARMODULE}.par"
45 COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ${PARSOURCES} ${PARHEADERS} ${PARLINKDEF} ${PARDIR}/
46 COMMAND cmake -E copy ${ROOT_ETCDIR}/Makefile.arch ${PARDIR}/
47 COMMAND tar -C ${PARDIR}/.. -czf ${PARDIR}/../${PARMODULE}.par ${PARMODULE}/
48 )
49
50endmacro()