-
Notifications
You must be signed in to change notification settings - Fork 19
/
CMakeLists.txt
77 lines (63 loc) · 2.87 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
cmake_minimum_required(VERSION 3.12)
project(selene VERSION 0.3.1 LANGUAGES CXX C)
# User-settable options
option(SELENE_BUILD_TESTS "Build Selene tests" OFF)
option(SELENE_BUILD_EXAMPLES "Build Selene examples" OFF)
option(SELENE_BUILD_BENCHMARKS "Build Selene benchmarks" OFF)
option(SELENE_BUILD_ALL "Build Selene tests, examples, and benchmarks (even with other SELENE_BUILD_* variables OFF)" OFF)
if(SELENE_BUILD_ALL)
set(SELENE_BUILD_TESTS ON)
set(SELENE_BUILD_EXAMPLES ON)
set(SELENE_BUILD_BENCHMARKS ON)
endif()
option(SELENE_USE_LIBJPEG "Enable looking for libjpeg" ON)
option(SELENE_USE_LIBPNG "Enable looking for libpng" ON)
option(SELENE_USE_LIBTIFF "Enable looking for libtiff" ON)
option(SELENE_USE_OPENCV "Enable looking for OpenCV" ON)
option(SELENE_USE_DEFAULT_SINGLE_PRECISION "Use single precision for floating point calculations by default (instead of double precision)" OFF)
option(SELENE_WARNINGS_AS_ERRORS "Treat warnings as errors (mainly intended for CI)" OFF)
option(SELENE_ENABLE_SANITIZERS "If set, enable build flags for building using ASAN and UBSAN saniziters." OFF)
# https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard whose features are requested to build this target.")
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Boolean describing whether the value of CXX_STANDARD is a requirement.")
set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Boolean specifying whether compiler specific extensions are requested.")
# Generate compilation database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(SELENE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# Conan support: the cmake_paths generator requires Conan >= 1.4.1
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake)
endif()
include(cmake/get_external.cmake)
include(cmake/find_dependencies.cmake)
include(cmake/build_types.cmake)
include(cmake/compiler_options.cmake)
include(cmake/custom_targets.cmake)
add_subdirectory(selene)
if(SELENE_BUILD_TESTS OR SELENE_BUILD_EXAMPLES OR SELENE_BUILD_BENCHMARKS)
add_subdirectory(wrappers/fs)
if(SELENE_BUILD_TESTS OR SELENE_BUILD_BENCHMARKS)
add_subdirectory(test/utils)
endif()
endif()
if(SELENE_BUILD_TESTS)
include(CTest)
enable_testing()
add_subdirectory(external/Catch2)
add_subdirectory(test)
else()
message(STATUS "Not building unit tests; enable with SELENE_BUILD_TESTS=ON if desired.")
endif()
if(SELENE_BUILD_EXAMPLES)
add_subdirectory(examples)
else()
message(STATUS "Not building examples; enable with SELENE_BUILD_EXAMPLES=ON if desired.")
endif()
if(SELENE_BUILD_BENCHMARKS)
add_subdirectory(benchmark)
else()
message(STATUS "Not building benchmarks; enable with SELENE_BUILD_BENCHMARKS=ON if desired.")
endif()
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_subdirectory(package/cpack)
endif()