/[PAMELA software]/PamVMC_update/CMakeLists.txt
ViewVC logotype

Annotation of /PamVMC_update/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sat Mar 21 21:21:23 2015 UTC (9 years, 8 months ago) by pam-ts
Branch: MAIN
File MIME type: text/plain
Add optional build with CMake (Nicola Mori).

1 pam-ts 1.1 project(PamVMC)
2     cmake_minimum_required(VERSION 2.6)
3    
4     ###### Find external packages
5     # ROOT
6     set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR} ${CMAKE_MODULE_PATH})
7     find_package(ROOT REQUIRED)
8     include_directories(${ROOT_INCLUDE_DIR})
9     # GEANT4
10     find_package(Geant4 REQUIRED)
11     include(${Geant4_USE_FILE})
12    
13     # VGM
14     find_package(VGM REQUIRED)
15    
16     # GEANT4VMC
17     find_package(Geant4VMC REQUIRED)
18     include_directories(${Geant4VMC_INCLUDE_DIRS})
19    
20     # PAMELA software include directories
21     include_directories($ENV{PAM_INC} $ENV{PAM_INC}/yoda)
22    
23     ###### Adjust configuration
24     # Some compiler options have been set by external packages e.g. Geant4.
25    
26     # Remove the -pedantic compiler option introduced by Geant4.
27     # This is necessary in order to avoid to trigger an error when initializing static const float
28     # variables (e.g. trk/include/PamVMCTrkDig.h:97)
29     string(REPLACE " -pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
30    
31     # Automatically recurse over linked linbraries.
32     # For binutils >= 2.22 (http://unix.derkeiler.com/Mailing-Lists/FreeBSD/current/2011-12/msg00257.html)
33     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--copy-dt-needed-entries" )
34    
35     # Mute compile warnings (i.e. remove the -Wsomething compiler options).
36     # Warnigns can be shown by adding -DPAMVMC_SHOW_WARNINGS=1 to the invocation of cmake.
37     if(NOT "${PAMVMC_SHOW_WARNINGS}" STREQUAL "1")
38     string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
39     string(REPLACE " -W " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
40     string(REPLACE " -Wno-non-virtual-dtor" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
41     string(REPLACE " -Wno-long-long" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
42     string(REPLACE " -Wwrite-strings" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
43     string(REPLACE " -Wpointer-arith" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
44     string(REPLACE " -Woverloaded-virtual" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
45     string(REPLACE " -Wno-variadic-macros" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
46     string(REPLACE " -Wshadow" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
47     endif()
48    
49     # Enable compilation of Fortran code
50     enable_language(Fortran)
51    
52     ##### PamVMC build
53     # Include PamVMC directories
54     include_directories(.
55     include
56     cal/include
57     trk/include
58     trk/include/f77
59     tof/include
60     ac/include
61     s4/include
62     nd/include
63     PamG4RunConfiguration
64     PamG4RunConfiguration/include
65     )
66    
67     # Build PamG4RunConfiguration library
68     root_generate_dictionary(PamG4RunConfigurationDict
69     PamG4RunConfiguration/include/PamG4RunConfiguration.h
70     LINKDEF PamG4RunConfiguration/include/PamG4RunConfigurationLinkDef.h
71     )
72     add_library(PamG4RunConfiguration SHARED
73     PamG4RunConfiguration/src/PamG4RegionConstruction.cxx
74     PamG4RunConfiguration/src/PamG4RunConfiguration.cxx
75     PamG4RunConfigurationDict.cxx
76     )
77    
78     # Build PamVMC_fc library
79     file(GLOB HDR RELATIVE ${CMAKE_SOURCE_DIR} "include/*.h")
80     list(REMOVE_ITEM HDR "include/PamVMC_fcLinkDef.h")
81     file(GLOB AC_HDR RELATIVE ${CMAKE_SOURCE_DIR} "ac/include/*.h")
82     file(GLOB CAL_HDR RELATIVE ${CMAKE_SOURCE_DIR} "cal/include/*.h")
83     file(GLOB ND_HDR RELATIVE ${CMAKE_SOURCE_DIR} "nd/include/*.h")
84     file(GLOB S4_HDR RELATIVE ${CMAKE_SOURCE_DIR} "s4/include/*.h")
85     file(GLOB TRK_HDR RELATIVE ${CMAKE_SOURCE_DIR} "trk/include/*.h")
86     file(GLOB TOF_HDR RELATIVE ${CMAKE_SOURCE_DIR} "tof/include/*.h")
87    
88     root_generate_dictionary(PamVMC_fcDict
89     ${HDR}
90     ${AC_HDR}
91     ${CAL_HDR}
92     ${ND_HDR}
93     ${S4_HDR}
94     ${TRK_HDR}
95     ${TOF_HDR}
96     LINKDEF include/PamVMC_fcLinkDef.h
97     )
98    
99     file(GLOB SRC "src/*.cxx")
100     file(GLOB AC_SRC "ac/src/*.cxx")
101     file(GLOB CAL_SRC "cal/src/*.cxx")
102     file(GLOB ND_SRC "nd/src/*.cxx")
103     file(GLOB S4_SRC "s4/src/*.cxx")
104     file(GLOB TRK_SRC "trk/src/*.cxx")
105     file(GLOB TRK_FSRC "trk/src/f77/*.F")
106     file(GLOB TOF_SRC "tof/src/*.cxx")
107    
108     set(PamVMC_fc_SOURCE
109     ${SRC}
110     ${AC_SRC}
111     ${CAL_SRC}
112     ${ND_SRC}
113     ${S4_SRC}
114     ${TRK_SRC}
115     ${TRK_FSRC}
116     ${TOF_SRC}
117     PamVMC_fcDict.cxx
118     )
119    
120    
121     add_library(PamVMC_fc SHARED ${PamVMC_fc_SOURCE})
122    
123     # Build PamVMC.exe
124     link_directories($ENV{PAM_LIB})
125     add_executable(PamVMC.exe G4main/PamVMCmain.cxx)
126     target_link_libraries(PamVMC.exe
127     PamVMC_fc
128     PamG4RunConfiguration
129     ${ROOT_LIBRARIES}
130     XMLParser
131     ${Geant4VMC_LIBRARIES}
132     yoda
133     DarthVader
134     gfortran
135     )

  ViewVC Help
Powered by ViewVC 1.1.23