project(PamVMC) cmake_minimum_required(VERSION 2.6) ###### Find external packages # ROOT set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR} ${CMAKE_MODULE_PATH}) find_package(ROOT REQUIRED) include_directories(${ROOT_INCLUDE_DIR}) # GEANT4 find_package(Geant4 REQUIRED) include(${Geant4_USE_FILE}) # VGM find_package(VGM REQUIRED) # GEANT4VMC find_package(Geant4VMC REQUIRED) include_directories(${Geant4VMC_INCLUDE_DIRS}) # PAMELA software include directories include_directories($ENV{PAM_INC} $ENV{PAM_INC}/yoda) ###### Adjust configuration # Some compiler options have been set by external packages e.g. Geant4. # Remove the -pedantic compiler option introduced by Geant4. # This is necessary in order to avoid to trigger an error when initializing static const float # variables (e.g. trk/include/PamVMCTrkDig.h:97) string(REPLACE " -pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Automatically recurse over linked linbraries. # For binutils >= 2.22 (http://unix.derkeiler.com/Mailing-Lists/FreeBSD/current/2011-12/msg00257.html) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--copy-dt-needed-entries" ) # Mute compile warnings (i.e. remove the -Wsomething compiler options). # Warnigns can be shown by adding -DPAMVMC_SHOW_WARNINGS=1 to the invocation of cmake. if(NOT "${PAMVMC_SHOW_WARNINGS}" STREQUAL "1") string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) string(REPLACE " -W " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) string(REPLACE " -Wno-non-virtual-dtor" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) string(REPLACE " -Wno-long-long" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) string(REPLACE " -Wwrite-strings" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) string(REPLACE " -Wpointer-arith" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) string(REPLACE " -Woverloaded-virtual" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) string(REPLACE " -Wno-variadic-macros" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) string(REPLACE " -Wshadow" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) endif() # Enable compilation of Fortran code enable_language(Fortran) ##### PamVMC build # Include PamVMC directories include_directories(. include cal/include trk/include trk/include/f77 tof/include ac/include s4/include nd/include PamG4RunConfiguration PamG4RunConfiguration/include ) # Build PamG4RunConfiguration library root_generate_dictionary(PamG4RunConfigurationDict PamG4RunConfiguration/include/PamG4RunConfiguration.h LINKDEF PamG4RunConfiguration/include/PamG4RunConfigurationLinkDef.h ) add_library(PamG4RunConfiguration SHARED PamG4RunConfiguration/src/PamG4RegionConstruction.cxx PamG4RunConfiguration/src/PamG4RunConfiguration.cxx PamG4RunConfigurationDict.cxx ) # Build PamVMC_fc library file(GLOB HDR RELATIVE ${CMAKE_SOURCE_DIR} "include/*.h") list(REMOVE_ITEM HDR "include/PamVMC_fcLinkDef.h") file(GLOB AC_HDR RELATIVE ${CMAKE_SOURCE_DIR} "ac/include/*.h") file(GLOB CAL_HDR RELATIVE ${CMAKE_SOURCE_DIR} "cal/include/*.h") file(GLOB ND_HDR RELATIVE ${CMAKE_SOURCE_DIR} "nd/include/*.h") file(GLOB S4_HDR RELATIVE ${CMAKE_SOURCE_DIR} "s4/include/*.h") file(GLOB TRK_HDR RELATIVE ${CMAKE_SOURCE_DIR} "trk/include/*.h") file(GLOB TOF_HDR RELATIVE ${CMAKE_SOURCE_DIR} "tof/include/*.h") root_generate_dictionary(PamVMC_fcDict ${HDR} ${AC_HDR} ${CAL_HDR} ${ND_HDR} ${S4_HDR} ${TRK_HDR} ${TOF_HDR} LINKDEF include/PamVMC_fcLinkDef.h ) file(GLOB SRC "src/*.cxx") file(GLOB AC_SRC "ac/src/*.cxx") file(GLOB CAL_SRC "cal/src/*.cxx") file(GLOB ND_SRC "nd/src/*.cxx") file(GLOB S4_SRC "s4/src/*.cxx") file(GLOB TRK_SRC "trk/src/*.cxx") file(GLOB TRK_FSRC "trk/src/f77/*.F") file(GLOB TOF_SRC "tof/src/*.cxx") set(PamVMC_fc_SOURCE ${SRC} ${AC_SRC} ${CAL_SRC} ${ND_SRC} ${S4_SRC} ${TRK_SRC} ${TRK_FSRC} ${TOF_SRC} PamVMC_fcDict.cxx ) add_library(PamVMC_fc SHARED ${PamVMC_fc_SOURCE}) # Build PamVMC.exe link_directories($ENV{PAM_LIB}) add_executable(PamVMC.exe G4main/PamVMCmain.cxx) target_link_libraries(PamVMC.exe PamVMC_fc PamG4RunConfiguration ${ROOT_LIBRARIES} XMLParser ${Geant4VMC_LIBRARIES} yoda DarthVader gfortran ) # Build libPrimaryInfo.so include_directories(aux/spectra_generator/) root_generate_dictionary(PrimaryInfoDict aux/spectra_generator/PrimaryInfo.h LINKDEF aux/spectra_generator/LinkDef.h ) add_library(PrimaryInfo SHARED PrimaryInfoDict.cxx) # Build sp_gen add_executable(sp_gen aux/spectra_generator/sp_gen_VF.C ) target_link_libraries(sp_gen ${ROOT_LIBRARIES} PrimaryInfo yoda DarthVader ) ###### Install rules install(TARGETS PamVMC.exe sp_gen DESTINATION bin) install(TARGETS PamVMC_fc PamG4RunConfiguration PrimaryInfo DESTINATION lib)