-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
138 lines (117 loc) · 4.42 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
project(XS4GCR Fortran C CXX)
cmake_minimum_required(VERSION 2.8)
set( CMAKE_VERBOSE_MAKEFILE off )
set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" )
set( CMAKE_fortran_COMPILER "gfortran" )
get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
set( CMAKE_C_COMPILER "gcc-9" )
set( CMAKE_CXX_COMPILER "g++-9" )
set( CMAKE_CXX_FLAGS "-O2 -ftree-vectorize -std=c++11" )
set( XS4GCR_INCLUDES )
set( XS4GCR_LIBRARIES )
option(BUILD_DOC "Build documentation" OFF)
# include
include_directories( "${CMAKE_SOURCE_DIR}/include" )
# cparamlib (provided)
add_subdirectory(libs/cparamlib)
list(APPEND XS4GCR_LIBRARIES cparamlib)
list(APPEND XS4GCR_INCLUDES libs/cparamlib/include)
# fortran codes (provided)
add_subdirectory(libs/external_codes)
list(APPEND XS4GCR_LIBRARIES external_codes)
# GSL (external)
find_package(GSL)
if(GSL_FOUND)
set(HAVE_LIBGSL 1)
list(APPEND XS4GCR_INCLUDES ${GSL_INCLUDE_DIR})
list(APPEND XS4GCR_LIBRARIES ${GSL_LIBRARIES})
else(GSL_FOUND)
message(FATAL_ERROR "Require GSL: set GSL_HOME")
endif(GSL_FOUND)
# check if Doxygen is installed
find_package(Doxygen)
if (DOXYGEN_FOUND)
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")
# note the option DOC to build the docs with make doc
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
# copy data files in the working dir
set(XS4GCR_DATA
data/Evoli2019_fragmentation_fitparams.txt
data/WNEWTR_082693.CDR.txt
data/barpol.txt
data/crchart_Z28_2020.txt
data/ghost_list.txt
data/isotope_decays.txt
data/xsec_spallation_Webber2003.txt
data/xsecs_data_full.txt
)
foreach(_script ${XS4GCR_DATA})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
# add source files
set(XS4GCR_SRCS
src/antiprotons/antiproton_tables.cpp
src/antiprotons/antiprotons.cpp
src/antiprotons/DiMauro2015.cpp
src/antiprotons/Duperray03.cpp
src/antiprotons/TanNg83.cpp
src/inelastic/CROSEC.cpp
src/inelastic/inelastic.cpp
src/inelastic/Letaw1983.cpp
src/inelastic/Tripathi99.cpp
src/leptons/leptons.cpp
src/spallation/Evoli2019.cpp
src/spallation/fitting_functions.cpp
src/spallation/ghost_tree.cpp
src/spallation/spallation.cpp
src/spallation/Webber1993.cpp
src/spallation/Webber2003_table.cpp
src/cr_chart.cpp
src/grid.cpp
src/protons.cpp
src/utilities.cpp
src/xs4gcr.cpp
)
# make library
include_directories (include ${XS4GCR_INCLUDES})
add_library( XS4GCR ${XS4GCR_SRCS} ${XS4GCR_INCLUDES} )
# make executables
add_executable(xsec_inelastic examples/inelastic.cpp)
target_link_libraries (xsec_inelastic XS4GCR ${XS4GCR_LIBRARIES})
add_executable(xsec_secleptons examples/secleptons.cpp )
target_link_libraries (xsec_secleptons XS4GCR ${XS4GCR_LIBRARIES})
add_executable(xsec_secantiprotons examples/secantiprotons.cpp )
target_link_libraries (xsec_secantiprotons XS4GCR ${XS4GCR_LIBRARIES})
add_executable(decay examples/decay.cpp )
target_link_libraries (decay XS4GCR ${XS4GCR_LIBRARIES})
#add_executable(xsec_example5 examples/example5.cpp )
#target_link_libraries (xsec_example5 XS4GCR ${XS4GCR_LIBRARIES})
#add_executable(xsec_example6 examples/example6.cpp )
#target_link_libraries (xsec_example6 XS4GCR ${XS4GCR_LIBRARIES})
add_executable(sandbox examples/sandbox.cpp )
target_link_libraries (sandbox XS4GCR ${XS4GCR_LIBRARIES})
add_executable(frag_table examples/frag_table.cpp )
target_link_libraries (frag_table XS4GCR ${XS4GCR_LIBRARIES})
# show summary
message (STATUS "CMAKE_SYSTEM .......... = ${CMAKE_SYSTEM}")
message (STATUS "BUILD_SHARED_LIBS ..... = ${BUILD_SHARED_LIBS}")
message (STATUS "CMAKE_CXX_COMPILER .... = ${CMAKE_CXX_COMPILER}")
message (STATUS "CMAKE_CXX_FLAGS ....... = ${CMAKE_CXX_FLAGS}")
message (STATUS "CMAKE_INCLUDE_PATH .... = ${CMAKE_INCLUDE_PATH}")
message (STATUS "XS4GCR_INCLUDES ....... = ${XS4GCR_INCLUDES}")
message (STATUS "XS4GCR_LIBRARIES ...... = ${XS4GCR_LIBRARIES}")