forked from MapCollaboration/MontBlanc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
145 lines (129 loc) · 4.27 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
141
142
143
144
145
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(MontBlanc)
# activating some global properties for the project
set(MontBlanc_VERSION 1.0.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/MontBlanc/version.h.in"
"${PROJECT_SOURCE_DIR}/inc/MontBlanc/version.h"
)
find_package(PkgConfig REQUIRED)
pkg_search_module(YAML REQUIRED yaml-cpp)
pkg_search_module(EIGEN3 REQUIRED eigen3)
find_package(Ceres REQUIRED)
include_directories(${CERES_INCLUDE_DIRS})
pkg_search_module(GLOG REQUIRED libglog)
pkg_search_module(GFLAGS REQUIRED 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/MontBlanc-config.in"
"${PROJECT_SOURCE_DIR}/bin/MontBlanc-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)
# NANGAPARBAT
find_program(NANGAPARBAT_CONFIG NangaParbat-config REQUIRED)
if (NANGAPARBAT_CONFIG)
exec_program(${NANGAPARBAT_CONFIG}
ARGS --cppflags
OUTPUT_VARIABLE NANGAPARBAT_CXX_FLAGS
)
set(NANGAPARBAT_CXX_FLAGS ${NANGAPARBAT_CXX_FLAGS} CACHE STRING INTERNAL)
exec_program(${NANGAPARBAT_CONFIG}
ARGS --ldflags
OUTPUT_VARIABLE NANGAPARBAT_LIBRARIES
)
set(NANGAPARBAT_LIBRARIES ${NANGAPARBAT_LIBRARIES} CACHE STRING
INTERNAL)
else(NANGAPARBAT_CONFIG)
message(FATAL_ERROR "NANGAPARBAT not found!")
endif(NANGAPARBAT_CONFIG)
# GSL
find_program(GSL_CONFIG gsl-config REQUIRED)
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(FATAL_ERROR "GSL not found!")
endif(GSL_CONFIG)
# NNAD
find_program(NNAD_CONFIG nnad-config REQUIRED)
if (NNAD_CONFIG)
exec_program(${NNAD_CONFIG}
ARGS --cflags
OUTPUT_VARIABLE NNAD_CFLAGS
)
set(NNAD_CFLAGS ${NNAD_CFLAGS} CACHE STRING INTERNAL)
endif(NNAD_CONFIG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NNAD_CFLAGS} ${EIGEN3_CFLAGS} ${Ceres_CFLAGS} ${GLOG_CFLAGS} ${GFLAGS_CFLAGS} ${LHAPDF_CXX_FLAGS} ${APFELXX_CXX_FLAGS} ${NANGAPARBAT_CXX_FLAGS} ${GSL_CXX_FLAGS} ${YAML_CFLAGS} -Wall -fPIC -Wunused")
# build target library
add_subdirectory(src)
add_subdirectory(run)
add_subdirectory(tests)
#option(BUILD_TESTS "Build tests code" ON)
#if(BUILD_TESTS)
# enable_testing()
# add_subdirectory(tests)
#endif(BUILD_TESTS)
install(FILES ${PROJECT_SOURCE_DIR}/bin/MontBlanc-config
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)