|
1 | | -CMAKE_MINIMUM_REQUIRED(VERSION 3.5.2 FATAL_ERROR) |
| 1 | +# ---- CMake options ---- |
2 | 2 |
|
3 | | -### CMP0025 Compiler id for Apple Clang is now AppleClang. |
4 | | -### CMP0042 MACOSX_RPATH is enabled by default. |
| 3 | +cmake_minimum_required(VERSION 3.5.2 FATAL_ERROR) |
5 | 4 |
|
6 | | -FOREACH (p |
7 | | - CMP0025 # CMake 3.0 |
8 | | - CMP0042 # CMake 3.0 |
9 | | - ) |
10 | | - IF (POLICY ${p}) |
11 | | - cmake_policy(SET ${p} NEW) |
12 | | - ENDIF () |
13 | | -endforeach () |
| 5 | +# Set cmake policy by version: https://cmake.org/cmake/help/latest/manual/cmake-policies.7.html |
| 6 | +if(${CMAKE_VERSION} VERSION_LESS 3.12) |
| 7 | + cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) |
| 8 | +else() |
| 9 | + cmake_policy(VERSION 3.12) |
| 10 | +endif() |
14 | 11 |
|
15 | 12 | enable_testing() |
16 | 13 |
|
| 14 | +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
| 15 | + |
| 16 | +include(CMakeParseArguments) |
| 17 | +include(QCModulesUtils) |
| 18 | + |
| 19 | +# ---- Project ---- |
| 20 | + |
| 21 | +project( |
| 22 | + QualityControl |
| 23 | + VERSION |
| 24 | + 0.6.2 # TODO update this automatically when there are new releases |
| 25 | + DESCRIPTION |
| 26 | + "O2 Quality Control" |
| 27 | + LANGUAGES CXX |
| 28 | +) |
| 29 | + |
| 30 | +set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib") |
| 31 | +set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") |
| 32 | +set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include") |
| 33 | + |
| 34 | +# ---- Compilation flags and build options ---- |
| 35 | + |
| 36 | +# Set the default build type to "RelWithDebInfo" |
| 37 | +if(NOT CMAKE_BUILD_TYPE) |
| 38 | + set( |
| 39 | + CMAKE_BUILD_TYPE "RelWithDebInfo" |
| 40 | + CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Coverage." |
| 41 | + FORCE |
| 42 | + ) |
| 43 | +endif(NOT CMAKE_BUILD_TYPE) |
| 44 | + |
| 45 | +# Build targets with install rpath on Mac to dramatically speed up installation |
| 46 | +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
| 47 | +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) |
| 48 | +if("${isSystemDir}" STREQUAL "-1") |
| 49 | + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
| 50 | + set(CMAKE_INSTALL_RPATH "@loader_path/../lib") |
| 51 | + endif() |
| 52 | +endif() |
| 53 | +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
| 54 | + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) |
| 55 | +endif() |
| 56 | +unset(isSystemDir) |
| 57 | + |
| 58 | +# C++ standard |
| 59 | +set(CMAKE_CXX_STANDARD 14) |
| 60 | + |
| 61 | +# Add compiler flags for warnings and (more importantly) fPIC and debug symbols |
| 62 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra") |
| 63 | + |
| 64 | +# Set fPIC for all targets |
| 65 | +set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 66 | + |
| 67 | +# ---- Dependencies ---- |
| 68 | + |
| 69 | +find_package( |
| 70 | + Boost 1.58 |
| 71 | + COMPONENTS |
| 72 | + container |
| 73 | + unit_test_framework |
| 74 | + program_options |
| 75 | + system |
| 76 | + log |
| 77 | + signals |
| 78 | +) |
| 79 | +find_package(Git QUIET) |
| 80 | +find_package(Configuration REQUIRED) |
| 81 | +find_package(Monitoring REQUIRED) |
| 82 | +find_package(MySQL REQUIRED) |
| 83 | +find_package(Common REQUIRED) |
| 84 | +find_package(InfoLogger REQUIRED) |
| 85 | +find_package(DataSampling REQUIRED) |
| 86 | +find_package(AliceO2 REQUIRED) |
| 87 | +find_package(CURL REQUIRED) |
| 88 | +find_package(ZeroMQ REQUIRED) |
| 89 | +find_package(Arrow REQUIRED) |
| 90 | +find_package(GLFW) |
| 91 | +find_package(FairRoot REQUIRED) |
| 92 | +find_package(FairMQ REQUIRED) |
| 93 | +find_package(FairLogger REQUIRED) |
| 94 | +find_package( |
| 95 | + ROOT 6.06.02 |
| 96 | + COMPONENTS |
| 97 | + RHTTP |
| 98 | + RMySQL |
| 99 | + Gui |
| 100 | + REQUIRED |
| 101 | +) |
| 102 | + |
| 103 | +if(NOT MYSQL_FOUND) |
| 104 | + message(WARNING "MySQL not found, the corresponding classes won't be built.") |
| 105 | +endif() |
| 106 | + |
| 107 | +# ---- Subdirectories ---- |
| 108 | + |
17 | 109 | add_subdirectory(Framework) |
18 | 110 | add_subdirectory(Modules) |
19 | 111 | add_subdirectory(doc) |
0 commit comments