-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
65 lines (57 loc) · 2.44 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
## brief: CMake Configuration for MicroMouse Maze Library
## author: Ryotaro Onuki <kerikun11+github@gmail.com>
## date: 2022.04.16
cmake_minimum_required(VERSION 3.13)
project("MicroMouse Maze Library" CXX)
## cmake options
option(BUILD_DOCS "build documentation" ON)
option(BUILD_TEST "build unit test" ON)
option(BUILD_EXAMPLES "build example projects" ON)
## global build options
set(CMAKE_CXX_STANDARD 17) # enable option -std=c++17
set(CMAKE_CXX_EXTENSIONS OFF) # without compiler extensions like gnu++14
## make a static library
set(MICROMOUSE_MAZE_LIBRARY "maze") # target name
file(GLOB SRC_FILES src/*.cpp)
add_library(${MICROMOUSE_MAZE_LIBRARY} STATIC ${SRC_FILES})
target_include_directories(${MICROMOUSE_MAZE_LIBRARY}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
)
## c.f. https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options
target_compile_options(${MICROMOUSE_MAZE_LIBRARY} PUBLIC
-mno-ms-bitfields # for use of '__attribute__((__packed__))' on MSYS environment
)
target_compile_options(${MICROMOUSE_MAZE_LIBRARY} PRIVATE
-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/= # make __FILE__ macro relative path
-fdiagnostics-color=always # colorized output for gcc
-Wall # This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros.
-Wextra # This enables some extra warning flags that are not enabled by -Wall.
-Wundef # Warn if an undefined identifier is evaluated in an #if directive. Such identifiers are replaced with zero.
-Wcast-align # Warn whenever a pointer is cast such that the required alignment of the target is increased.
-Wdouble-promotion # Give a warning when a value of type float is implicitly promoted to double.
-Wfloat-equal # Warn if floating-point values are used in equality comparisons.
)
## documentation
if(BUILD_DOCS)
add_subdirectory(docs)
endif()
## unit test
if(BUILD_TEST)
add_subdirectory(test)
endif()
## examples
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
## cpplint
add_custom_target(cpplint
COMMAND cpplint --quiet --recursive --exclude=build .
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
USES_TERMINAL
)
## cppcheck
add_custom_target(cppcheck
COMMAND cppcheck --quiet --enable=all --inline-suppr --suppressions-list=cppcheck-suppressions.txt -i build --platform=unix32 --std=c++17 .
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
USES_TERMINAL
)