Skip to content

Commit

Permalink
Modern cmake (#59)
Browse files Browse the repository at this point in the history
* Use targets
* Do not use buckets
* Export targets
* Properly import Monitoring
* Handle correctly the case when MySQL is missing
  • Loading branch information
Barthelemy authored Sep 27, 2018
1 parent c3a9fd3 commit 27b1e07
Show file tree
Hide file tree
Showing 43 changed files with 1,001 additions and 2,814 deletions.
31 changes: 31 additions & 0 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
additional_commands:
foo:
flags:
- BAR
- BAZ
kwargs:
DEPENDS: '*'
HEADERS: '*'
SOURCES: '*'
algorithm_order:
- 0
- 1
- 2
- 3
always_wrap: []
bullet_char: '*'
command_case: lower
dangle_parens: true
enable_markup: true
enum_char: .
fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$
first_comment_is_literal: false
keyword_case: unchanged
line_ending: unix
line_width: 120
literal_comment_pattern: null
max_subargs_per_line: 3
ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$
separate_ctrl_name_with_space: false
separate_fn_name_with_space: false
tab_size: 2
114 changes: 103 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,111 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.2 FATAL_ERROR)
# ---- CMake options ----

### CMP0025 Compiler id for Apple Clang is now AppleClang.
### CMP0042 MACOSX_RPATH is enabled by default.
cmake_minimum_required(VERSION 3.5.2 FATAL_ERROR)

FOREACH (p
CMP0025 # CMake 3.0
CMP0042 # CMake 3.0
)
IF (POLICY ${p})
cmake_policy(SET ${p} NEW)
ENDIF ()
endforeach ()
# Set cmake policy by version: https://cmake.org/cmake/help/latest/manual/cmake-policies.7.html
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.12)
endif()

enable_testing()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

include(CMakeParseArguments)
include(QCModulesUtils)

# ---- Project ----

project(
QualityControl
VERSION
0.6.2 # TODO update this automatically when there are new releases
DESCRIPTION
"O2 Quality Control"
LANGUAGES CXX
)

set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include")

# ---- Compilation flags and build options ----

# Set the default build type to "RelWithDebInfo"
if(NOT CMAKE_BUILD_TYPE)
set(
CMAKE_BUILD_TYPE "RelWithDebInfo"
CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Coverage."
FORCE
)
endif(NOT CMAKE_BUILD_TYPE)

# Build targets with install rpath on Mac to dramatically speed up installation
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif()
unset(isSystemDir)

# C++ standard
set(CMAKE_CXX_STANDARD 14)

# Add compiler flags for warnings and (more importantly) fPIC and debug symbols
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra")

# Set fPIC for all targets
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# ---- Dependencies ----

find_package(
Boost 1.58
COMPONENTS
container
unit_test_framework
program_options
system
log
signals
)
find_package(Git QUIET)
find_package(Configuration REQUIRED)
find_package(Monitoring REQUIRED)
find_package(MySQL REQUIRED)
find_package(Common REQUIRED)
find_package(InfoLogger REQUIRED)
find_package(DataSampling REQUIRED)
find_package(AliceO2 REQUIRED)
find_package(CURL REQUIRED)
find_package(ZeroMQ REQUIRED)
find_package(Arrow REQUIRED)
find_package(GLFW)
find_package(FairRoot REQUIRED)
find_package(FairMQ REQUIRED)
find_package(FairLogger REQUIRED)
find_package(
ROOT 6.06.02
COMPONENTS
RHTTP
RMySQL
Gui
REQUIRED
)

if(NOT MYSQL_FOUND)
message(WARNING "MySQL not found, the corresponding classes won't be built.")
endif()

# ---- Subdirectories ----

add_subdirectory(Framework)
add_subdirectory(Modules)
add_subdirectory(doc)
Loading

0 comments on commit 27b1e07

Please sign in to comment.