-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
78 lines (61 loc) · 3.07 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
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
project(TPCRS LANGUAGES CXX)
include(CTest)
set(TPCRS_VERSION_MAJOR 0 CACHE STRING "major version of tpc-rs" FORCE)
set(TPCRS_VERSION_MINOR 2 CACHE STRING "minor version of tpc-rs" FORCE)
set(TPCRS_VERSION_PATCH 0 CACHE STRING "patch version of tpc-rs" FORCE)
set(TPCRS_VERSION "${TPCRS_VERSION_MAJOR}.${TPCRS_VERSION_MINOR}.${TPCRS_VERSION_PATCH}" CACHE STRING "version of tpc-rs" FORCE)
# By default build shared libraries but allow the user to change if desired
OPTION(BUILD_SHARED_LIBS "Global flag to cause add_library to create shared libraries if on" ON)
# Add to path in order to pick up the FindXXX.cmake files included in this project
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# A compiler with c++11 support is required
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
set(CMAKE_CXX_EXTENSIONS OFF)
# This library depends on ROOT
find_package(ROOT REQUIRED COMPONENTS Cint MathMore Geom)
# In case of 32-bit ROOT add the compatible compiler flag
if(${ROOT_CXX_FLAGS} MATCHES "-m32")
message(STATUS "tpc-rs: Found -m32 option in $ROOT_CXX_FLAGS (root-config). Will proceed with 32 bit build")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_SIZEOF_VOID_P 4)
endif()
# Set a debug postfix
set(CMAKE_DEBUG_POSTFIX "-dbg")
# Set installation destinations
if(UNIX)
include(GNUInstallDirs)
set(TPCRS_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/tpcrs")
set(TPCRS_RUNTIME_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
set(TPCRS_LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(TPCRS_ARCHIVE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(TPCRS_FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(TPCRS_ADDITIONAL_FILES_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/tpc-rs-${TPCRS_VERSION}")
set(TPCRS_CMAKE_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/tpc-rs-${TPCRS_VERSION}/cmake")
set(TPCRS_DATA_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/tpc-rs-${TPCRS_VERSION}/data")
elseif(WIN32)
set(TPCRS_INC_INSTALL_DIR "include/tpcrs")
set(TPCRS_RUNTIME_INSTALL_DIR "bin")
set(TPCRS_LIBRARY_INSTALL_DIR "bin")
set(TPCRS_ARCHIVE_INSTALL_DIR "lib")
set(TPCRS_FRAMEWORK_INSTALL_DIR "bin")
set(TPCRS_ADDITIONAL_FILES_INSTALL_DIR "share/tpc-rs-${TPCRS_VERSION}")
set(TPCRS_CMAKE_CONFIG_INSTALL_DIR "share/tpc-rs-${TPCRS_VERSION}/cmake")
set(TPCRS_DATA_INSTALL_DIR "share/tpc-rs-${TPCRS_VERSION}/data")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
else()
message(FATAL_ERROR "Could not set install folders for this platform!")
endif()
# Setup yaml-cpp library as external project
include(cmake/ExternalProject_yaml-cpp.cmake)
add_subdirectory(src)
if(BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
# Install additional files such as README, LICENSE, etc.
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/README.md" DESTINATION ${TPCRS_ADDITIONAL_FILES_INSTALL_DIR})
install(EXPORT tpcrsTargets DESTINATION ${TPCRS_CMAKE_CONFIG_INSTALL_DIR} FILE tpcrs-config.cmake)