-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
97 lines (84 loc) · 2.7 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Install example Geant4 ROOT scripts and conversion code
file(GLOB root_scripts RELATIVE ${PROJECT_SOURCE_DIR}/scripts CONFIGURE_DEPENDS
*.C
*.py
*.cc
*.txt
*.md
*.root
*.hepmc3
)
foreach(_script ${root_scripts})
configure_file(
${_script}
${_script}
COPYONLY
)
endforeach()
# Compile the .cc files:
# Get a list of all the files in this directory that end in ".cc"
file(GLOB script_progs RELATIVE ${PROJECT_SOURCE_DIR}/scripts CONFIGURE_DEPENDS
*.cc
)
# Make lists of programs that have any special dependencies.
list(APPEND HepMC3_Programs
"hepmc-convert.cc"
"hepmc-grams-example.cc"
"hepmc-ntuple.cc"
)
list(APPEND FITS_Programs
"healpix-maps.cc"
)
# For each such file...
foreach(_filename ${script_progs})
# Check if we can compile this program with the available
# libraries.
if (NOT HepMC3_FOUND)
# Is this file on our list of programs that need HepMC3?
list (FIND HepMC3_Programs "${_filename}" _index)
if ( _index GREATER -1 )
# Yes it is, so don't compile it.
continue()
endif()
endif()
if (NOT FITS_FOUND)
# Is this file on our list of programs that need cfitsio/healpix_cxx?
list (FIND FITS_Programs "${_filename}" _index)
if ( _index GREATER -1 )
# Yes it is, so don't compile it.
continue()
endif()
endif()
# Derive the executable program name by
# stripping the ".cc" from the end.
string(REGEX REPLACE "\\.cc" "" _prog "${_filename}")
# Add an extension determined by GramsSim/CMakeLists.txt.
string(APPEND _prog ${EXE})
# Tell CMake to compile <whatever.cc> to make
# the executable <whatever>, using the libraries
# from HepMC3, ROOT, and FITS.
add_executable(${_prog} ${_filename})
target_link_libraries(${_prog} ${ROOT_LIBRARIES} )
# Make sure that the Utilities and Dictionary libraries are
# available to the compiled programs, even if the program
# may not use them.
target_link_libraries(${_prog} Utilities )
target_link_libraries(${_prog} Dictionary)
# The following line is needed to make sure Dictionary is linked with the executable.
if (NOT MACOSX)
# The following line is needed to make sure Dictionary is linked with the executable.
target_link_options(${_prog} PRIVATE "LINKER:-no-as-needed")
endif()
if (HepMC3_FOUND)
target_link_libraries(${_prog} ${HEPMC3_LIBRARIES} )
endif()
if (FITS_FOUND)
target_link_libraries(${_prog} ${FITS_LDFLAGS} )
endif()
# Put the compiled binary into a "bin" directory within
# the destination directory.
set_target_properties( ${_prog}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/bin"
)
endforeach()