-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
56 lines (41 loc) · 1.32 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
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(ulog_cpp LANGUAGES CXX)
# Determine if ulog_cpp is built as a subproject (using add_subdirectory) or if it is the main project.
set(MAIN_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(MAIN_PROJECT ON)
endif()
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_subdirectory(ulog_cpp)
if(MAIN_PROJECT)
add_compile_options(
# Warnings
-Wall
-Wextra
-Werror
# disabled warnings
-Wno-missing-field-initializers
-Wno-unused-parameter
)
# compiler specific flags
if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang"))
add_compile_options(
-fcolor-diagnostics # force color for clang (needed for clang + ccache)
-fdiagnostics-absolute-paths # force absolute paths
-Qunused-arguments
-Wno-unknown-warning-option
-Wno-unused-const-variable
)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(clang_format)
add_subdirectory(examples)
add_subdirectory(test)
endif()
target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/>)