Skip to content

Commit 27b1e07

Browse files
authored
Modern cmake (#59)
* Use targets * Do not use buckets * Export targets * Properly import Monitoring * Handle correctly the case when MySQL is missing
1 parent c3a9fd3 commit 27b1e07

43 files changed

Lines changed: 1001 additions & 2814 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cmake-format.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
additional_commands:
2+
foo:
3+
flags:
4+
- BAR
5+
- BAZ
6+
kwargs:
7+
DEPENDS: '*'
8+
HEADERS: '*'
9+
SOURCES: '*'
10+
algorithm_order:
11+
- 0
12+
- 1
13+
- 2
14+
- 3
15+
always_wrap: []
16+
bullet_char: '*'
17+
command_case: lower
18+
dangle_parens: true
19+
enable_markup: true
20+
enum_char: .
21+
fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$
22+
first_comment_is_literal: false
23+
keyword_case: unchanged
24+
line_ending: unix
25+
line_width: 120
26+
literal_comment_pattern: null
27+
max_subargs_per_line: 3
28+
ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$
29+
separate_ctrl_name_with_space: false
30+
separate_fn_name_with_space: false
31+
tab_size: 2

CMakeLists.txt

Lines changed: 103 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,111 @@
1-
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.2 FATAL_ERROR)
1+
# ---- CMake options ----
22

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)
54

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()
1411

1512
enable_testing()
1613

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+
17109
add_subdirectory(Framework)
18110
add_subdirectory(Modules)
19111
add_subdirectory(doc)

0 commit comments

Comments
 (0)