CMake: Propagate compilation flags to the dictionary generation
authoragrigora <alina.grigoras@cern.ch>
Wed, 28 Jan 2015 14:35:42 +0000 (15:35 +0100)
committeragrigora <alina.grigoras@cern.ch>
Wed, 28 Jan 2015 14:42:24 +0000 (15:42 +0100)
Compilation flags have to propagated to the dictionary generation,
especially the defines
- general definitions, as set per project(Ex: ROOT -DWITHXML)
- custom definition per library such as ALI_DATE

cmake/CMakeALICE.cmake

index 4ca1ae1..31fa6e3 100644 (file)
@@ -24,6 +24,8 @@
 # @LDNAME LinkDef file name, ex: LinkDef.h
 # @DHDRS  Dictionary headers
 # @DINCDIR Include folders that need to be passed to cint/cling
+# @EXTRADEFINITIONS - optional, extra compile flags specific to library
+#       - used as ${ARGV4}
 macro(generate_dictionary DNAME LDNAME DHDRS DINCDIRS)
 
     # Creating the INCLUDE path for cint/cling
@@ -31,24 +33,21 @@ macro(generate_dictionary DNAME LDNAME DHDRS DINCDIRS)
         set(INCLUDE_PATH -I${dir} ${INCLUDE_PATH})
     endforeach()
     
-    # Generate the dictionary
-#    message(STATUS "Generating dictionary ${DNAME} for ${LDNAME}")
-    
-#    message(STATUS "${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.cxx")
-#    message(STATUS "${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.h")
-#    message(STATUS "bbb${INCLUDE_PATH}bbb")
-#    message(STATUS "${DHDRS} ${LDNAME}")
-#    message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}")
+    # Get the list of definitions from the directory to be sent to CINT
+    get_directory_property(tmpdirdefs COMPILE_DEFINITIONS)
+    foreach(dirdef ${tmpdirdefs})
+        set(GLOBALDEFINITIONS -D${dirdef} ${GLOBALDEFINITIONS})
+    endforeach()
     
-    # Get the definitions from the directory to be sent to CINT
-    get_directory_property(tmpdirdefs DEFINITIONS)
-    string(REPLACE " " ";" tmpdirdefs "${tmpdirdefs}")
+    # Custom definitions specific to library
+    # Received as the forth optional argument
+    separate_arguments(EXTRADEFINITIONS UNIX_COMMAND "${ARGV4}")
 
     if (ROOT_VERSION_MAJOR LESS 6)
     add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.cxx ${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.h
                        COMMAND LD_LIBRARY_PATH=${ROOT_LIBDIR}:$ENV{LD_LIBRARY_PATH} ${ROOT_CINT}
                        ARGS -f ${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.cxx -c -p 
-                       ${tmpdirdefs} ${INCLUDE_PATH} 
+                       ${GLOBALDEFINITIONS} ${EXTRADEFINITIONS} ${INCLUDE_PATH} 
                        ${DHDRS} ${LDNAME}
                        DEPENDS ${DHDRS} ${LDNAME} ${ROOT_CINT}
                        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
@@ -60,7 +59,7 @@ macro(generate_dictionary DNAME LDNAME DHDRS DINCDIRS)
                        ARGS
                          -f ${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.cxx
                          -rmf ${CMAKE_CURRENT_BINARY_DIR}/lib${DNAME}.rootmap -rml lib${DNAME}
-                         ${tmpdirdefs} ${INCLUDE_PATH} ${DHDRS} ${LDNAME}
+                         ${GLOBALDEFINITIONS} ${EXTRADEFINITIONS}  ${INCLUDE_PATH} ${DHDRS} ${LDNAME}
                        DEPENDS
                          ${DHDRS} ${LDNAME} ${ROOT_CINT}
                        WORKING_DIRECTORY