forked from DESY-FH-ELab/TCT-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
257 lines (228 loc) · 10.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
########################################################
CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
########################################################
# project name
PROJECT( TCTAnalysis )
# project version
SET( TCTANALYSIS_VERSION_MAJOR 0 )
SET( TCTANALYSIS_VERSION_MINOR 1 )
SET( TCTANALYSIS_VERSION_PATCH 1 )
# some macros are redefined to keep compatability with CMake 2.8.12
include(${PROJECT_SOURCE_DIR}/cmake/CMakeCompatibility.cmake)
# Determine platform- and compiler-specific settings
include(${PROJECT_SOURCE_DIR}/cmake/Platform.cmake)
# Check if this is a source tarball build
IF(NOT IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
SET(SOURCE_PACKAGE 1)
ENDIF(NOT IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
# Set package version
IF(NOT SOURCE_PACKAGE)
# Get the version from last git tag plus numer of additional commits:
FIND_PACKAGE(Git QUIET)
IF(GIT_FOUND)
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} describe --tags HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE TCTANALYSIS_LIB_VERSION ERROR_VARIABLE GIT_ERROR)
IF(GIT_ERROR) # git execution resulted in error message -- cannot trust result but construct version from hard-set variable
MESSAGE(WARNING "Could not determine TCT-Analysis version from git -- git execution resulted in error: ${GIT_ERROR}")
SET(TCTANALYSIS_LIB_VERSION ${TCTANALYSIS_VERSION_MAJOR}.${TCTANALYSIS_VERSION_MINOR}.${TCTANALYSIS_VERSION_PATCH})
ELSE(GIT_ERROR)
STRING(REGEX REPLACE "([v0-9.]+[-a-zA-Z0-9]+)-([0-9]+)-([A-Za-z0-9]+)" "\\1+\\2~\\3" TCTANALYSIS_LIB_VERSION ${TCTANALYSIS_LIB_VERSION})
STRING(REGEX REPLACE "\n" "" TCTANALYSIS_LIB_VERSION ${TCTANALYSIS_LIB_VERSION}) # remove potential line breaks
STRING(REGEX REPLACE "v([v0-9.]+)(.*)" "\\1" TCTANALYSIS_LIB_BASEVERSION ${TCTANALYSIS_LIB_VERSION})
IF("${TCTANALYSIS_LIB_BASEVERSION}" VERSION_LESS "${TCTANALYSIS_VERSION_MAJOR}.${TCTANALYSIS_VERSION_MINOR}.${TCTANALYSIS_VERSION_PATCH}")
MESSAGE(WARNING "You do not seem to have fetched the latest tags in your git repository -- please consider running 'git fetch' for the main remote repository.")
ENDIF("${TCTANALYSIS_LIB_BASEVERSION}" VERSION_LESS "${TCTANALYSIS_VERSION_MAJOR}.${TCTANALYSIS_VERSION_MINOR}.${TCTANALYSIS_VERSION_PATCH}")
EXEC_PROGRAM(git ARGS status --porcelain ${CMAKE_CURRENT_SOURCE_DIR}/src OUTPUT_VARIABLE TCTANALYSIS_MAIN_STATUS)
IF(TCTANALYSIS_MAIN_STATUS STREQUAL "")
MESSAGE(STATUS "Main TCT-Analysis library directory is clean (all changes have been commited).")
ELSE(TCTANALYSIS_MAIN_STATUS STREQUAL "")
MESSAGE(STATUS "Main TCT-Analysis library directory is dirty (uncommitted changes present):\n ${TCTANALYSIS_MAIN_STATUS}.")
SET(TCTANALYSIS_LIB_VERSION ${TCTANALYSIS_LIB_VERSION}*)
ENDIF(TCTANALYSIS_MAIN_STATUS STREQUAL "")
ENDIF(GIT_ERROR)
ELSE(GIT_FOUND)
# If we don't have git we take the hard-set version.
SET(TCTANALYSIS_LIB_VERSION ${TCTANALYSIS_VERSION_MAJOR}.${TCTANALYSIS_VERSION_MINOR}.${TCTANALYSIS_VERSION_PATCH})
ENDIF(GIT_FOUND)
ELSE(NOT SOURCE_PACKAGE)
# If we don't have git we take the hard-set version.
SET(TCTANALYSIS_LIB_VERSION "v${TCTANALYSIS_VERSION_MAJOR}.${TCTANALYSIS_VERSION_MINOR}.${TCTANALYSIS_VERSION_PATCH}")
ENDIF(NOT SOURCE_PACKAGE)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.h" "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
MESSAGE("-- Determined TCT-Analysis version ${TCTANALYSIS_LIB_VERSION}")
# set the path to which we will install later: default project home, can be changed using
# cmake -DINSTALL_PREFIX=/some/dir ..
SET(INSTALL_PREFIX "${PROJECT_SOURCE_DIR}" CACHE PATH "Prefix prepended to install directories")
SET(CMAKE_INSTALL_PREFIX "${INSTALL_PREFIX}" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
# additional packages to be searched for by cmake
LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
# SET THE RPATH SO THAT OUR EXECUTABLES FIND THE TCTANALYSIS LIBRARY EVEN WHEN INSTALLED INTO NON-DEFAULT LOCATIONS
# see http://www.cmake.org/Wiki/CMake_RPATH_handling
# enable @rpath in the install name for any shared library being built
# note: it is planned that a future version of CMake will enable this by default
set(CMAKE_MACOSX_RPATH 1)
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# *ALTERNATIVELY*: USE RELATIVE PATHS
# see http://www.semipol.de/archives/356
# for all binaries created in a CMake project:
#SET(CMAKE_INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")
# for certain targets
#SET_TARGET_PROPERTIES(target 1 target2 ...
# PROPERTIES INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
# Should we ever need ROOT uncomment here...
FIND_PACKAGE( ROOT REQUIRED )
INCLUDE_DIRECTORIES( ${ROOT_INCLUDE_DIR} )
#OPTIONAL: add preprocessor defines to be able to check for ROOT in the code
ADD_DEFINITIONS(-DROOT_FOUND)
# include directories
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/include )
# GUI Option, if yes - Qt installation needed
OPTION(WITH_GUI "Setting the compiler to build GUI" OFF)
AUX_SOURCE_DIRECTORY(src/modules TCTMODULES)
if(WITH_GUI)
add_definitions(-DUSE_GUI)
FIND_PACKAGE(Qt5Widgets)
if(!Qt5Widgets_FOUND)
FIND_PACKAGE(Qt4 REQUIRED)
endif()
if(Qt5Widgets_FOUND)
QT5_WRAP_UI(UISrcs forms/base.ui forms/form_parameters.ui forms/form_sample.ui forms/form_folders.ui )
QT5_WRAP_CPP(MOCSrcs include/base.h include/gui_folders.h include/gui_sample.h include/gui_consoleoutput.h)
SET(QT_VERSION 5)
else(Qt4_FOUND)
INCLUDE(${QT_USE_FILE})
QT4_WRAP_UI(UISrcs forms/base.ui forms/form_parameters.ui forms/form_sample.ui forms/form_folders.ui )
QT4_WRAP_CPP(MOCSrcs include/base.h include/gui_folders.h include/gui_sample.h include/gui_consoleoutput.h)
SET(QT_VERSION 4)
else()
MESSAGE(ERROR "Neither Qt5 or Qt4 were not found")
endif()
# CORE LIBRARY:
SET(LIB_SOURCE_FILES
"src/sample.cc"
"src/acquisition.cc"
"src/measurement.cc"
"src/util.cc"
"src/analysis.cc"
"src/tct_config.cc"
"src/scanning.cc"
"src/TCTReader.cc"
"src/TCTModule.cc"
${TCTMODULES}
"src/base.cc"
"src/gui_folders.cc"
"src/gui_sample.cc"
${MOCSrcs}
${UISrcs}
)
else()
# CORE LIBRARY:
SET(LIB_SOURCE_FILES
"src/sample.cc"
"src/acquisition.cc"
"src/measurement.cc"
"src/util.cc"
"src/analysis.cc"
"src/tct_config.cc"
"src/scanning.cc"
"src/TCTReader.cc"
"src/TCTModule.cc"
${TCTMODULES}
)
endif()
MESSAGE(STATUS ${ROOT_LIBRARIES})
# Setting the LeCroy Library Requierment
OPTION(WITH_LECROY_RAW "Setting the LeCroy Library to read RAW files from the oscilloscope" OFF)
if(WITH_LECROY_RAW)
add_definitions(-DUSE_LECROY_RAW)
FIND_PACKAGE ( LCR REQUIRED )
INCLUDE_DIRECTORIES( ${LCR_INCLUDE_DIR} )
endif()
# Check for TCTAnalyze library by particulars.si
#FIND_PACKAGE ( TCTAnalyze REQUIRED )
#INCLUDE_DIRECTORIES( ${TCTAnalyze_INCLUDE} )
# build main TCT-ANALYSIS executable
if(WITH_GUI)
add_executable(tct-analysis src/main_gui.cxx ${LIB_SOURCE_FILES})
add_executable(tbrowser src/tbrowser.cxx )
else()
add_executable(tct-analysis src/main.cxx ${LIB_SOURCE_FILES})
endif()
if(WITH_GUI)
if(QT_VERSION EQUAL 5)
MESSAGE(STATUS "Linking against Qt5")
set(QT_LIBRARIES "Qt5::Widgets")
else(QT_VERSION EQUAL 4)
MESSAGE(STATUS "Linking against Qt4")
endif()
endif()
if(WITH_LECROY_RAW AND WITH_GUI)
target_link_libraries(tct-analysis ${ROOT_LIBRARIES} ${QT_LIBRARIES} ${LCR_LIBRARY})
target_link_libraries(tbrowser ${ROOT_LIBRARIES})
elseif(WITH_GUI)
target_link_libraries(tct-analysis ${ROOT_LIBRARIES} ${QT_LIBRARIES})
target_link_libraries(tbrowser ${ROOT_LIBRARIES})
elseif(WITH_LECROY_RAW)
target_link_libraries(tct-analysis ${ROOT_LIBRARIES} ${LCR_LIBRARY})
else()
target_link_libraries(tct-analysis ${ROOT_LIBRARIES})
endif()
# now set up the installation directory
if(WITH_GUI)
# creating and installing default config file
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/default.conf "DefaultFile = ../testanalysis/lpnhe_top.txt")
INSTALL(TARGETS tct-analysis tbrowser
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/default.conf DESTINATION bin)
else()
INSTALL(TARGETS tct-analysis
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()
#############################################
# Doxygen target to generate HTML reference #
#############################################
FIND_PACKAGE(Doxygen)
IF(DOXYGEN_FOUND)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/doc/doxygen/Doxyfile @ONLY)
ADD_CUSTOM_TARGET(doxygen
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/doxygen/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen
COMMENT "Generating HTML documentation with Doxygen" VERBATIM
)
ENDIF(DOXYGEN_FOUND)
#######################################################
# Print out system information useful for bug reports #
############################################### #######
include(PrintSystemInformation)
#######################
# Print configuration #
#######################
if(NOT WIN32)
string(ASCII 27 Esc)
set(ColourReset "${Esc}[m")
set(ColourBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[32m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
endif()
message(STATUS "${BoldRed}Build options:${ColourReset}")
message(STATUS "${Green}WITH_LECROY_RAW: " ${BoldGreen} ${WITH_LECROY_RAW} ${ColourReset})
message(STATUS "${Green}WITH_GUI: " ${BoldGreen} ${WITH_GUI} ${ColourReset})