-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
131 lines (111 loc) · 4 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
#----------------------------------------------------------------------------
# Setup the project
#
project(FieldCalibration C CXX)
# An option to enable testing, enable it with "cmake blabla -DTESTING=On"
option(TESTING "Testing" OFF)
#----------------------------------------------------------------------------
# cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
#
cmake_minimum_required(VERSION 2.6.2)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3)
cmake_policy(VERSION 2.8.4)
else()
cmake_policy(VERSION 2.6)
endif()
endif()
#----------------------------------------------------------------------------
# Use C++11 extention and O3 optimization (-founding-math because of CGAL)
#
if (APPLE)
message(STATUS "No optimization for mac :-)")
else()
set(CMAKE_CXX_FLAGS "-O3 -frounding-math")
endif()
add_definitions("-std=c++11")
#----------------------------------------------------------------------------
# Find CGAL library
#
find_package(CGAL QUIET)
if ( CGAL_FOUND )
include( ${CGAL_USE_FILE} )
include( CGAL_CreateSingleSourceCGALProgram )
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()
#----------------------------------------------------------------------------
# Find ROOT (required package)
#
list(APPEND CMAKE_MODULE_PATH $ENV{ROOTSYS}/etc/cmake)
find_package(ROOT REQUIRED)
add_definitions(${ROOT_CXX_FLAGS})
#----------------------------------------------------------------------------
# Find package for multi-threading
#
find_package (Threads)
find_package(OpenMP)
if (OPENMP_FOUND)
message(STATUS "Using OpenMP")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
#----------------------------------------------------------------------------
# Add sources and headers
#
include_directories(./include)
set(SOURCE_FILES
source/Laser.cpp
source/LaserTrack.cpp
source/Laser.cpp
source/Matrix3x3.cpp
source/TPCVolumeHandler
source/Interpolation3D.cpp
source/Utilities.cpp
source/DriftVelocity.cpp )
#set(HEADER_FILES include/Laser.hpp include/LaserTrack.hpp include/Laser.hpp include/ThreeVector.hpp include/Matrix3x3.hpp include/TPCVolumeHandler include/Interpolation3D.hpp source/Utilities.cpp include/Utilities.hpp)
#----------------------------------------------------------------------------
# Locate sources and headers for this project
#
if (APPLE)
message(STATUS "So Yifan is trying somethings.")
execute_process(COMMAND "root-config" "--incdir" OUTPUT_VARIABLE rootinc RESULT_VARIABLE rs)
include_directories(${rootinc})
else()
include_directories(${ROOT_INCLUDE_DIR})
endif()
#----------------------------------------------------------------------------
# Add the executable, and link it to the necessary libraries
#
if(TESTING)
add_library(fieldcal SHARED ${SOURCE_FILES} )
endif()
add_executable(FieldCal FieldCal.cpp ${SOURCE_FILES} )
target_link_libraries(FieldCal ${ROOT_LIBRARIES} ${CGAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
#----------------------------------------------------------------------------
# Copy all required files to build directory.
#
#set(FieldCal_Files Field.root)
#foreach(_File ${FieldCal_Files})
# configure_file(
# ${PROJECT_SOURCE_DIR}/${_File}
# ${PROJECT_BINARY_DIR}/${_File}
# COPYONLY
# )
#endforeach()
# Testing stuff
if(TESTING)
message(STATUS "Testing enabled.")
find_package(GTest REQUIRED)
if( GTEST_FOUND )
enable_testing()
add_subdirectory(tests)
else()
message(STATUS "Cannot find GTest, which is required if testing is enabled. Either install GTest or disable
Testing again.")
endif()
endif()
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS FieldCal DESTINATION ${CMAKE_SOURCE_DIR}/bin)
#install(TARGETS fieldcal DESTINATION ${CMAKE_SOURCE_DIR}/lib )