forked from KrakowHEPSoft/HEPLike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
138 lines (112 loc) · 4.65 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
cmake_minimum_required (VERSION 2.8.12)
project (HEPLike)
enable_testing()
message("######################################################")
message("# #")
message("# HEPLike software V2.0 #")
message("# J.Bhom, M.Chrzaszcz, T.Gonzalo #")
message("# #")
message("# Documentation: #")
message("# https://github.com/KrakowHEPSoft/HEPLike #")
message("# GPL 3 license #")
message("# #")
message("######################################################")
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS}/build)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} $ENV{ROOTSYS}/etc/cmake)
set(CMAKE_MACOSX_RPATH TRUE) # use @rpath keyword for the macOS rpath
###########################
#
# Compile seetings
#
###########################
# Add -fPIC for 64 bit systems
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
###########################
#
# Packages search
#
###########################
# Use provided version of yaml-cpp
add_subdirectory(${PROJECT_SOURCE_DIR}/yaml-cpp EXCLUDE_FROM_ALL)
# looking for boost
find_package(Boost REQUIRED)
# GSL
find_package(GSL REQUIRED)
include_directories(${CMAKE_SOURCE_DIR}/yaml-cpp/include)
include_directories(${CMAKE_SOURCE_DIR}/include ${Boost_INCLUDE_DIRS})
option(USE_ROOT "Compile with ROOT enabled" TRUE)
if(USE_ROOT)
# ROOT:
find_package(ROOT REQUIRED COMPONENTS MathCore RIO Hist Tree Net)
include(${ROOT_USE_FILE})
include_directories(${ROOT_INCLUDE_DIRS})
add_definitions(${ROOT_CXX_FLAGS})
endif()
###########################
#
# Config Variables
#
###########################
if(NOT DEFINED EXECUTABLE)
set(EXECUTABLE FALSE)
endif()
# Configure the file
set(outhdr "${CMAKE_SOURCE_DIR}/include/cmake_variables.h")
configure_file("${CMAKE_SOURCE_DIR}/include/cmake_variables.h.in" ${outhdr})
###########################
#
# Libraries
#
###########################
file(GLOB HL_SOURCES ${CMAKE_SOURCE_DIR}/src/*.cc)
add_library(HEPLike_static ${HL_SOURCES})
add_library(HEPLike_shared SHARED ${HL_SOURCES})
set_target_properties(HEPLike_static PROPERTIES OUTPUT_NAME HEPLike)
set_target_properties(HEPLike_shared PROPERTIES OUTPUT_NAME HEPLike)
target_link_libraries(HEPLike_shared PRIVATE ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${GSL_LIBRARIES} )
###########################
#
# Executables
#
###########################
if(EXECUTABLE)
execute_process (
COMMAND bash -c "ln -s ../data_toy/ data"
)
add_executable(Br_example main/Br_example.cc)
add_executable(BrBifurGaussian_example main/BrBifurGaussian_example.cc)
add_executable(Limit_example main/Limit_example.cc)
add_executable(Ndim_Gaussian main/Ndim_Gaussian.cc)
add_executable(ProfLikelihood_example main/ProfLikelihood_example.cc)
add_executable(Ndim_BifurGaussian_example main/Ndim_BifurGaussian_example.cc)
add_executable(Ndim_Likelihood_example main/Ndim_Likelihood_example.cc)
add_executable(Data_Fit_example main/Data_Fit_example.cc)
add_executable(Test_YAML main/Test_YAML.cc)
if(USE_ROOT)
set(LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${GSL_LIBRARIES})
else()
set(LIBARRIES ${Boost_LIBRARIES} ${GSL_LIBRARIES})
endif()
target_link_libraries(Br_example HEPLike_shared yaml-cpp ${LIBRARIES} )
target_link_libraries(BrBifurGaussian_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Limit_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Ndim_Gaussian HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(ProfLikelihood_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Ndim_BifurGaussian_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Ndim_Likelihood_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Data_Fit_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Test_YAML HEPLike_static yaml-cpp ${LIBRARIES})
add_test(HL_Test_YAML Test_YAML ../data_toy/examples/test_3dimassym.yaml)
add_test(HL_Limit Limit_example xterm)
add_test(HL_Br_example Br_example)
add_test(HL_BrBifurGaussian_example BrBifurGaussian_example)
add_test(HL_Ndim_Gaussian Ndim_Gaussian)
add_test(HL_ProfLikelihood_example ProfLikelihood_example ${CMAKE_CURRENT_BINARY_DIR})
add_test(HL_Ndim_BifurGaussian_example Ndim_BifurGaussian_example)
endif()