forked from MapCollaboration/NangaParbat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
140 lines (124 loc) · 4.16 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
139
140
cmake_minimum_required (VERSION 3.5)
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
if (NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH 0)
endif()
# the project name
project(NangaParbat)
# activating some global properties for the project
set(NangaParbat_VERSION 1.5.0)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# export version to file
configure_file(
"${PROJECT_SOURCE_DIR}/inc/NangaParbat/version.h.in"
"${PROJECT_SOURCE_DIR}/inc/NangaParbat/version.h"
)
find_package(PkgConfig REQUIRED)
pkg_search_module(YAML REQUIRED yaml-cpp)
#pkg_search_module(CERES ceres-solver)
find_package(Ceres QUIET)
if (NOT Ceres_FOUND)
message ("CERES not found. Some parts of the code will not be compiled.")
endif ()
pkg_search_module(EIGEN3 eigen3)
pkg_search_module(GLOG libglog)
pkg_search_module(GFLAGS gflags)
# Configuration script
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "${prefix}")
set(includedir "${prefix}/include")
set(libdir "${prefix}/lib")
configure_file(
"${PROJECT_SOURCE_DIR}/bin/NangaParbat-config.in"
"${PROJECT_SOURCE_DIR}/bin/NangaParbat-config"
)
include_directories(${PROJECT_SOURCE_DIR}/inc)
# LHAPDF
find_program(LHAPDF_CONFIG lhapdf-config REQUIRED)
if (LHAPDF_CONFIG)
exec_program(${LHAPDF_CONFIG}
ARGS --cflags
OUTPUT_VARIABLE LHAPDF_CXX_FLAGS
)
set(LHAPDF_CXX_FLAGS ${LHAPDF_CXX_FLAGS} CACHE STRING INTERNAL)
exec_program(${LHAPDF_CONFIG}
ARGS --libs
OUTPUT_VARIABLE LHAPDF_LIBRARIES
)
set(LHAPDF_LIBRARIES ${LHAPDF_LIBRARIES} CACHE STRING INTERNAL)
else(LHAPDF_CONFIG)
message(FATAL_ERROR "LHAPDF not found!")
endif(LHAPDF_CONFIG)
# APFEL++
find_program(APFELXX_CONFIG apfelxx-config REQUIRED)
if (APFELXX_CONFIG)
exec_program(${APFELXX_CONFIG}
ARGS --cppflags
OUTPUT_VARIABLE APFELXX_CXX_FLAGS
)
set(APFELXX_CXX_FLAGS ${APFELXX_CXX_FLAGS} CACHE STRING INTERNAL)
exec_program(${APFELXX_CONFIG}
ARGS --ldflags
OUTPUT_VARIABLE APFELXX_LIBRARIES
)
set(APFELXX_LIBRARIES ${APFELXX_LIBRARIES} CACHE STRING INTERNAL)
else(APFELXX_CONFIG)
message(FATAL_ERROR "APFEL++ not found!")
endif(APFELXX_CONFIG)
# GSL
find_program(GSL_CONFIG gsl-config)
if (GSL_CONFIG)
exec_program(${GSL_CONFIG}
ARGS --cflags
OUTPUT_VARIABLE GSL_CXX_FLAGS
)
set(GSL_CXX_FLAGS ${GSL_CXX_FLAGS} CACHE STRING INTERNAL)
exec_program(${GSL_CONFIG}
ARGS --libs
OUTPUT_VARIABLE GSL_LIBRARIES
)
set(GSL_LIBRARIES ${GSL_LIBRARIES} CACHE STRING INTERNAL)
else(GSL_CONFIG)
message ("GSL not found. Some parts of the code will not be compiled.")
endif(GSL_CONFIG)
# ROOT
find_program(ROOT_CONFIG root-config)
if (ROOT_CONFIG)
exec_program(${ROOT_CONFIG}
ARGS --cflags
OUTPUT_VARIABLE ROOT_CXX_FLAGS
)
set(ROOT_CXX_FLAGS ${ROOT_CXX_FLAGS} CACHE STRING INTERNAL)
exec_program(${ROOT_CONFIG}
ARGS --libs
OUTPUT_VARIABLE ROOT_LIBRARIES
)
set(ROOT_LIBRARIES ${ROOT_LIBRARIES} CACHE STRING INTERNAL)
# Include Minuit2 to the libraries of ROOT (not included by default)
set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lMinuit2)
else(ROOT_CONFIG)
message ("ROOT not found. Some parts of the code will not be compiled.")
endif(ROOT_CONFIG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LHAPDF_CXX_FLAGS} ${APFELXX_CXX_FLAGS} ${GSL_CXX_FLAGS} ${YAML_CFLAGS} ${ROOT_CXX_FLAGS} ${EIGEN3_CFLAGS} ${Ceres_CFLAGS} ${GLOG_CFLAGS} ${GFLAGS_CFLAGS} -Wall -fPIC -Wunused")
# build target library
add_subdirectory(src)
add_subdirectory(run)
option(BUILD_TESTS "Build tests code" ON)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
add_subdirectory(tools)
endif(BUILD_TESTS)
install(FILES ${PROJECT_SOURCE_DIR}/bin/NangaParbat-config
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)