Improvements in cmake functionality
authorfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Feb 2011 10:01:16 +0000 (10:01 +0000)
committerfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Feb 2011 10:01:16 +0000 (10:01 +0000)
CMakeLists.txt
EVGEN/CMakelibEVGEN.pkg
HMPID/CMakelibHMPIDbase.pkg
HMPID/CMakelibHMPIDrec.pkg
MUON/AliMUONTrackerQADataMakerRec.cxx
PWG2/CMakelibPWG2forward2.pkg
PWG2/CMakelibPWG2resonances.pkg
T0/CMakelibT0base.pkg
T0/CMakelibT0sim.pkg
cmake/ALICE_CMake.cmake
cmake/FindRuleChecker.cmake

index 312f56e..b49429c 100644 (file)
@@ -211,12 +211,10 @@ set(EXPORTFILES)
 # ------------------------------
 
 add_custom_target(alilibs-static)
-add_custom_target(include-headers)
+add_custom_target(include-headers ALL)
 add_custom_target(DA-all)
-if(RULECHECKER_FOUND)
-  add_custom_target(check-all)
-  add_dependencies(check-all ${FACTFILE})
-endif(RULECHECKER_FOUND)
+add_custom_target(check-all) 
+add_custom_target(check-hxml)
 add_custom_target(par-all)
 add_custom_target(test-par-all)
 
@@ -226,12 +224,8 @@ foreach(MODULE ${MODDIRS})
   set(${MODULE}ALIBS)
   configure_file(${PROJECT_SOURCE_DIR}/cmake/Module.tmp ${PROJECT_SOURCE_DIR}/${MODULE}/CMakeLists.txt @ONLY)
   add_custom_target(${MODULE}-all ALL)
-  add_custom_target(${MODULE}-check-all)
   add_custom_target(${MODULE}-par-all)
   add_custom_target(test-${MODULE}-par-all)
-  if(RULECHECKER_FOUND)
-    add_dependencies(check-all "${MODULE}-check-all")
-  endif(RULECHECKER_FOUND)
   add_custom_target(${MODULE}-all-static)
   add_dependencies(alilibs-static "${MODULE}-static")
   add_subdirectory(${MODULE})
@@ -242,9 +236,11 @@ if(DATE_FOUND AND AMORE_FOUND)
 endif(DATE_FOUND AND AMORE_FOUND)
 
 if(RULECHECKER_FOUND)
+    add_custom_target(factfile DEPENDS ${FACTFILE})
     add_custom_command( OUTPUT ${FACTFILE}
-                        COMMAND ${JAVA_RUNTIME} -jar ${FACTEXTRACTOR_JAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}
-                       DEPENDS ${_factfile_deps}
+                        COMMAND ${CMAKE_COMMAND} -E echo "Re-generating factfile"
+                        COMMAND ${JAVA_RUNTIME}  -Xmx1024M -jar ${FACTEXTRACTOR_JAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}                   
+                       DEPENDS check-hxml ${CMAKE_BINARY_DIR}/check-hxml-touchfile ${_factfile_deps} 
                         WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
 endif(RULECHECKER_FOUND)
 
index 8b21b8d..e52825c 100644 (file)
@@ -33,7 +33,7 @@ set ( DHDR EVGENLinkDef.h)
 
 set ( EXPORT AliDecayer.h AliGenMC.h AliGenCocktailAfterBurner.h AliGenCocktail.h AliOmegaDalitz.h)
 
-set ( EINCLUDE FASTSIM THijing PYTHIA6)
+set ( EINCLUDE FASTSIM THijing PYTHIA6 LHAPDF)
 
 if( ALICE_TARGET STREQUAL "win32gcc")
        
index 2a73912..3ae03e9 100644 (file)
@@ -31,6 +31,8 @@ string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 
 set ( DHDR  HMPIDbaseLinkDef.h)
 
+set ( EINCLUDE RAW )
+
 if( ALICE_TARGET STREQUAL "win32gcc")
        
                                set ( PACKSOFLAGS  ${SOFLAGS} -L${ALICE_ROOT}/lib/tgt_${ALICE_TARGET} -lSTEER -lCDB -lSTEERBase -lRAWDatasim -lRAWDatarec -lRAWDatabase -L${ROOTLIBDIR} -lGeom)
index ca4ddfe..fc59a4b 100644 (file)
@@ -29,6 +29,8 @@ set ( SRCS   AliHMPIDReconstructor.cxx AliHMPIDtrack.cxx AliHMPIDTracker.cxx Ali
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 
+set ( EINCLUDE RAW )
+
 set ( DHDR  HMPIDrecLinkDef.h)
 
 if( ALICE_TARGET STREQUAL "win32gcc")
index b7d206b..005b60f 100644 (file)
@@ -1618,6 +1618,7 @@ TObjArray* AliMUONTrackerQADataMakerRec::GetArray(TObjArray*& array, Bool_t crea
     if ( create ) 
     {
       array = new TObjArray(AliRecoParam::kNSpecies);
+      array->SetOwner(kTRUE);
     }
   }
   
index 3a8c21b..aa75778 100644 (file)
@@ -60,7 +60,7 @@ set ( SRCS
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 set ( HDRS ${HDRS} FORWARD/analysis2/AliFMDStripIndex.h )
 
-set ( EINCLUDE  ANALYSIS)
+set ( EINCLUDE  ANALYSIS PWG2/FORWARD/analysis2)
 
 set ( EXPORT FORWARD/analysis2/AliAODForwardMult.h 
              FORWARD/analysis2/AliForwardUtil.h )
index 3aa1b12..a987183 100644 (file)
@@ -64,7 +64,7 @@ set ( DHDR PWG2resonancesLinkDef.h)
 
 set ( EXPORT )
 
-set ( EINCLUDE  PYTHIA6 PWG2/RESONANCES CORRFW )
+set ( EINCLUDE  PYTHIA6 PWG2/RESONANCES CORRFW ANALYSIS/EventMixing )
 if( ALICE_TARGET STREQUAL "win32gcc")
        
                        set ( PACKSOFLAGS  ${SOFLAGS} -L${ALICE_ROOT}/lib/tgt_${ALICE_TARGET} -lSTEERBase -lESD -lANALYSIS -lANALYSISalice -L${ROOTLIBDIR} -lEG)
index 07fdb19..668ae0b 100644 (file)
@@ -33,6 +33,8 @@ set ( EHDr  AliT0CalibLatency.h)
 
 set ( DHDR  T0baseLinkDef.h)
 
+set ( EINCLUDE RAW )
+
 if( ALICE_TARGET STREQUAL "win32gcc")
        
                                set ( PACKSOFLAGS  ${SOFLAGS} -L${ALICE_ROOT}/lib/tgt_${ALICE_TARGET} -lSTEER -lCDB -lSTEERBase -lRAWDatasim -lRAWDatarec -lRAWDatabase -L${ROOTLIBDIR} -lGeom -lSpectrum)
index 3a11606..2bdaf2a 100644 (file)
@@ -31,6 +31,8 @@ string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 
 set ( DHDR  T0simLinkDef.h)
 
+set ( EINCLUDE RAW )
+
 if( ALICE_TARGET STREQUAL "win32gcc")
        
                                set ( PACKSOFLAGS  ${SOFLAGS} -L${ALICE_ROOT}/lib/tgt_${ALICE_TARGET} -lT0base -lSTEER -lCDB -lSTEERBase -lRAWDatabase -L${ROOTLIBDIR} -lVMC -lGeom)
index 619e5af..67e3fb8 100644 (file)
@@ -320,7 +320,6 @@ macro(ALICE_BuildPackage)
   set(${MODULE}LIBS "${PMLIBS}" PARENT_SCOPE)
   set(${MODULE}INC "${EINCLUDE}" PARENT_SCOPE)
   list(APPEND INCLUDEFILES ${PEXPORTDEST})
-  ALICE_CopyHeaders()
   if(WITHDICT)  
     ALICE_SetPackageVariable(PDS "DS" "G__${PACKAGE}.cxx" "G__${PACKAGE}.cxx")
     ALICE_GenerateDictionary()
@@ -336,8 +335,8 @@ macro(ALICE_BuildPackage)
       ALICE_BuildExecutable()
     endif(lib)
   endif(PS OR PCS OR PFS)
+  ALICE_CopyHeaders()
   ALICE_BuildPAR()
-  ALICE_CheckModule()
 
 endmacro(ALICE_BuildPackage)
 
@@ -367,7 +366,7 @@ macro(ALICE_BuildModule)
                 ARCHIVE DESTINATION bin/tgt_${ALICE_TARGET})
       endif(NOT EXCLUDEPACKAGE)
   endforeach(PACKAGEFILE)
-
+  ALICE_CheckModule()
 endmacro(ALICE_BuildModule)
 
 macro(ALICE_GenerateDictionary)
@@ -459,6 +458,8 @@ macro(ALICE_BuildLibrary)
     set_property(TARGET ${PACKAGE} PROPERTY EXCLUDE_FROM_ALL TRUE)
   endif(NOT RESULT STREQUAL "-1")
 
+  set_target_properties(${PACKAGE} PROPERTIES INSTALL_NAME_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
+
 endmacro(ALICE_BuildLibrary)
 
 macro(ALICE_BuildExecutable)
@@ -476,10 +477,9 @@ macro(ALICE_BuildExecutable)
   separate_arguments(PBLIBS)
   separate_arguments(PELIBS)
   separate_arguments(SHLIB)
-
+  
   ALICE_Format(PELIBSDIR "-L" "" "${PELIBSDIR}")
   ALICE_CheckLibraries(PBLIBS "${PBLIBS}")
-#  ALICE_CheckLibraries(PELIBS "${PELIBS}")
 
   ALICE_CorrectPaths(EINCLUDE "${EINCLUDE}")
   ALICE_CorrectPaths(PINC "${PINC}")
@@ -552,15 +552,19 @@ endmacro(ALICE_BuildExecutable)
 
 macro(ALICE_CopyHeaders)
   
-  if(NOT EXPORT )
-    set(HEADERS)
-  else()
+  if(EXPORT )
     set(HEADERS ${EXPORT})
-  endif(NOT EXPORT)
-  foreach(header ${HEADERS})
-      configure_file(${header} ${PEXPORTDEST} COPYONLY)
+    set(_headersdep)
+    foreach(header ${HEADERS})
+      add_custom_command(OUTPUT ${PEXPORTDEST}/${header}
+                         COMMAND ${CMAKE_COMMAND} -E copy ${ALICE_ROOT}/${MODULE}/${header} ${PEXPORTDEST}/${header}
+                        DEPENDS ${ALICE_ROOT}/${MODULE}/${header})
+      list(APPEND _headersdep ${PEXPORTDEST}/${header})
       install(FILES ${header} DESTINATION include)
-  endforeach(header)
+    endforeach(header)
+    add_custom_target(${PACKAGE}-headers DEPENDS ${_headersdep})
+    add_dependencies(${PACKAGE} ${PACKAGE}-headers)
+  endif(EXPORT)
 
 endmacro(ALICE_CopyHeaders)
 
index e506832..64a78b0 100644 (file)
@@ -16,14 +16,14 @@ set(IRST_INSTALLDIR $ENV{IRST_INSTALLDIR})
 if(NOT IRST_INSTALLDIR)
   if(ALICE)
     message(STATUS "Setting IRST_INSTALLDIR to ${ALICE}/local/ALICENewRuleChecker")
-    set(IRST_INSTALLDIR ${ALICE_ROOT}/cmakelocal/ALICENewRuleChecker)
+    set(IRST_INSTALLDIR ${ALICE}/local/ALICENewRuleChecker)
   endif(ALICE)
 endif(NOT IRST_INSTALLDIR)
 
 if(IRST_INSTALLDIR)
-  find_file(RULECHECKER_JAR NAMES NewRuleChecker.jar PATHS ${IRST_INSTALLDIR}/NewRuleChecker ${ALICE_ROOT}/cmake/RuleChecker)
-  find_file(RULECHECKER_RULES NAMES CodingConventions.xml PATHS ${IRST_INSTALLDIR}/NewRuleChecker/config ${ALICE_ROOT}/cmake/RuleChecker)
-  find_file(FACTEXTRACTOR_JAR NAME FactExtractor.jar PATHS ${IRST_INSTALLDIR}/FactExtractor ${ALICE_ROOT}/cmake/RuleChecker)
+  find_file(RULECHECKER_JAR NAMES NewRuleChecker.jar PATHS ${IRST_INSTALLDIR}/NewRuleChecker NO_DEFAULT_PATH)
+  find_file(RULECHECKER_RULES NAMES CodingConventions.xml PATHS ${IRST_INSTALLDIR}/NewRuleChecker/config NO_DEFAULT_PATH)
+  find_file(FACTEXTRACTOR_JAR NAMES FactExtractor.jar PATHS ${IRST_INSTALLDIR}/FactExtractor NO_DEFAULT_PATH)
   if(RULECHECKER_JAR AND RULECHECKER_RULES AND RULECHECKER_SRCML AND JAVA_RUNTIME)
     set(RULECHECKER_FOUND TRUE)
     message(STATUS "RuleChecker jar : ${RULECHECKER_JAR}")
@@ -31,22 +31,27 @@ if(IRST_INSTALLDIR)
     message(STATUS "RuleChecker factextractor : ${FACTEXTRACTOR_JAR}")
     message(STATUS "RuleChecker found on the system")
 
+    if(NOT EXISTS ${CMAKE_BINARY_DIR}/check-hxml-touchfile)
+      file(WRITE ${CMAKE_BINARY_DIR}/check-hxml-touchfile "Dummy dependency for factfile")
+    endif(NOT EXISTS ${CMAKE_BINARY_DIR}/check-hxml-touchfile)
     set(FACTFILE ${CMAKE_BINARY_DIR}/factFile.xml)
     set(_factfile_deps)
 
     file(GLOB_RECURSE _root_headers  ${ROOTSYS}/include/*.h)
     foreach(_root_header ${_root_headers})
-      string (REGEX REPLACE "${ROOTSYS}/include/" "" _rel_root_header ${_root_header})
-      string (REGEX REPLACE "h$" "h.xml" _rel_root_hxml ${_rel_root_header})
-      get_filename_component(_rel_root_header_path ${_rel_root_hxml} PATH)
-      set(_root_hxml roothxml/${_rel_root_hxml})
-      if(NOT EXISTS roothxml/${_rel_root_header_path})
-       file(MAKE_DIRECTORY roothxml/${_rel_root_header_path})
-      endif(NOT EXISTS roothxml/${_rel_root_header_path})
-      list(APPEND _factfile_deps ${_root_hxml})
-      add_custom_command(OUTPUT  ${_root_hxml}
-                         COMMAND ${RULECHECKER_SRCML} ${_root_header} ${_root_hxml}
-                         DEPENDS ${_root_header})
+      if(NOT _root_header MATCHES ".*G__ci.h")
+       string (REGEX REPLACE "${ROOTSYS}/include/" "" _rel_root_header ${_root_header})
+       string (REGEX REPLACE "h$" "h.xml" _rel_root_hxml ${_rel_root_header})
+       get_filename_component(_rel_root_header_path ${_rel_root_hxml} PATH)
+       set(_root_hxml ${CMAKE_BINARY_DIR}/roothxml/${_rel_root_hxml})
+       if(NOT EXISTS ${CMAKE_BINARY_DIR}/roothxml/${_rel_root_header_path})
+         file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/roothxml/${_rel_root_header_path})
+       endif(NOT EXISTS ${CMAKE_BINARY_DIR}/roothxml/${_rel_root_header_path})
+       list(APPEND _factfile_deps ${_root_hxml})
+       add_custom_command(OUTPUT  ${_root_hxml}
+                           COMMAND ${RULECHECKER_SRCML} ${_root_header} ${_root_hxml}
+                           DEPENDS ${_root_header})
+      endif(NOT _root_header MATCHES ".*G__ci.h")
     endforeach(_root_header ${_root_headers})
   else()
     message(STATUS "RuleChecker not found on this system")
@@ -58,46 +63,62 @@ endif(IRST_INSTALLDIR)
 macro(ALICE_CheckModule)
   if(RULECHECKER_FOUND)
     set(CHECKDIR ${CMAKE_BINARY_DIR}/${MODULE}/check)
-    set(violFiles)
-
-    foreach(_srcfile ${SRCS})
-      string (REGEX REPLACE "cxx$" "h" _header ${_srcfile})
-      get_filename_component(_srcname ${_srcfile} NAME)
-      string (REGEX REPLACE "cxx$" "viol" _viol ${_srcname})
-      string (REGEX REPLACE "cxx$" "cxx.xml" _srcxml ${_srcname})
-      string (REGEX REPLACE "cxx$" "h.xml" _hxml ${_srcname})
-      string (REGEX REPLACE ".cxx$" "" _class ${_srcname})
-      set(_depends ${_srcfile})
-
-      if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_header})
-        list(APPEND _depends ${_header})
-       list(APPEND _factfile_deps ${_hxml})
-        add_custom_command( OUTPUT ${_viol}
-                          COMMAND ${RULECHECKER_SRCML} ${_srcfile} ${CHECKDIR}/${_srcxml}
-                          COMMAND ${RULECHECKER_SRCML} ${_header} ${CHECKDIR}/${_hxml}
-                          COMMAND ${JAVA_RUNTIME} -jar ${RULECHECKER_JAR} ${CHECKDIR}/${_srcxml} ${CHECKDIR}/${_hxml} ${FACTFILE} ${RULECHECKER_RULES} > ${CHECKDIR}/viols/${_viol}
-                          DEPENDS ${_depends}
-                          WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-        list(APPEND violFiles ${_viol})
-      else()
-        add_custom_command( OUTPUT ${_viol}
-                          COMMAND ${RULECHECKER_SRCML} ${_srcfile} ${CHECKDIR}/${_srcxml}
-                          COMMAND ${JAVA_RUNTIME} -jar ${RULECHECKER_JAR} ${CHECKDIR}/${_srcxml} ${CHECKDIR}/${_hxml} ${FACTFILE} ${RULECHECKER_RULES} > ${CHECKDIR}/viols/${_viol}
-                          DEPENDS ${_depends}
-                          WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-        list(APPEND violFiles ${_viol})
-      endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_header})
-      if(CLASSCHECK STREQUAL "YES")
-        add_custom_target(${MODULE}-${_class}-check DEPENDS ${_viol})
-      endif(CLASSCHECK STREQUAL "YES")
-    endforeach(_srcfile ${SRCS})
-    if(violFiles)
-      add_custom_target(${PACKAGE}-check DEPENDS ${FACTFILE} ${violFiles})
-#      add_dependencies(${PACKAGE}-check ${FACTFILE} ${violFiles})
-      add_dependencies(${MODULE}-check-all ${PACKAGE}-check)
-    endif(violFiles)
-    add_custom_command(TARGET clean
-                       COMMAND ${CMAKE_COMMAND} -E remove_directory ${CHECKDIR})
+
+    file(GLOB_RECURSE _headers  ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
+    file(GLOB_RECURSE _sources_tmp  ${CMAKE_CURRENT_SOURCE_DIR}/*.cxx)
+    list(APPEND _sources_tmp ${_headers})
+    foreach(_srcfile ${_sources_tmp})
+      string(REPLACE ".h"   "" _srcfile_tmp ${_srcfile})
+      string(REPLACE ".cxx" "" _srcfile ${_srcfile_tmp})
+      list(APPEND _sources ${_srcfile})
+    endforeach(_srcfile ${_sources_tmp})
+    list(REMOVE_DUPLICATES _sources)
+    list(SORT _sources)
+
+    set(_violfiles)
+    set(_module_factfile_deps)
+    foreach(_srcfile ${_sources})
+      if(NOT _srcfile MATCHES "^.*LinkDef$" AND NOT _srcfile MATCHES ".*PYTHIA8/pythia8.*")
+       set(_violdeps)
+       string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" _srcfile_short ${_srcfile})
+       set(_viol ${CHECKDIR}/${_srcfile_short}.viol)
+       get_filename_component(_viol_path ${_viol} PATH)
+       list(APPEND _violfiles ${_viol})
+       if(EXISTS ${_srcfile}.h)
+         add_custom_command(OUTPUT ${CHECKDIR}/${_srcfile_short}.h.xml
+                            COMMAND ${CMAKE_COMMAND} -E make_directory ${_viol_path}
+                             COMMAND ${RULECHECKER_SRCML} ${_srcfile}.h ${CHECKDIR}/${_srcfile_short}.h.xml
+                            COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/check-hxml-touchfile
+                            DEPENDS ${_srcfile}.h)
+         list(APPEND _violdeps ${CHECKDIR}/${_srcfile_short}.h.xml)
+         list(APPEND _module_factfile_deps ${CHECKDIR}/${_srcfile_short}.h.xml)
+       endif(EXISTS ${_srcfile}.h)
+       if(EXISTS ${_srcfile}.cxx)
+         add_custom_command(OUTPUT ${CHECKDIR}/${_srcfile_short}.cxx.xml
+                            COMMAND ${CMAKE_COMMAND} -E make_directory ${_viol_path}
+                             COMMAND ${RULECHECKER_SRCML} ${_srcfile}.cxx ${CHECKDIR}/${_srcfile_short}.cxx.xml
+                            DEPENDS ${_srcfile}.cxx)
+         list(APPEND _violdeps ${CHECKDIR}/${_srcfile_short}.cxx.xml)
+       endif(EXISTS ${_srcfile}.cxx)
+       add_custom_command( OUTPUT ${_viol}
+                            COMMAND ${JAVA_RUNTIME} -Xmx1024M -jar ${RULECHECKER_JAR} ${CHECKDIR}/${_srcfile_short}.cxx.xml ${CHECKDIR}/${_srcfile_short}.h.xml ${FACTFILE} ${RULECHECKER_RULES} > ${_viol}
+                            DEPENDS ${_violdeps}
+                            WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+      endif(NOT _srcfile MATCHES "^.*LinkDef$" AND NOT _srcfile MATCHES ".*PYTHIA8/pythia8.*")
+    endforeach(_srcfile ${_sources})
+
+
+    if(_violfiles)
+      add_custom_target(${MODULE}-check DEPENDS ${_violfiles})
+      add_dependencies(${MODULE}-check factfile)
+      add_dependencies(check-all ${MODULE}-check)
+
+      if(_module_factfile_deps)
+       add_custom_target(${MODULE}-hxml DEPENDS ${_module_factfile_deps})
+       add_dependencies(check-hxml ${MODULE}-hxml)
+      endif(_module_factfile_deps)
+    endif(_violfiles)
+
 
   endif(RULECHECKER_FOUND)
 endmacro(ALICE_CheckModule)