-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
114 lines (84 loc) · 3.84 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#
# Copyright (C) 2023 Renesas Electronics Corporation.
# Copyright (C) 2023 EPAM Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
cmake_minimum_required(VERSION 3.19)
# Check compiler using static library instead of applicion
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
project("aos_core_lib_cpp")
# ######################################################################################################################
# Options
# ######################################################################################################################
option(WITH_TEST "build with test" OFF)
option(WITH_COVERAGE "build with coverage" OFF)
option(WITH_DOC "build with documenation" OFF)
message(STATUS)
message(STATUS "${CMAKE_PROJECT_NAME} configuration:")
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
message(STATUS)
message(STATUS "WITH_TEST = ${WITH_TEST}")
message(STATUS "WITH_COVERAGE = ${WITH_COVERAGE}")
message(STATUS "WITH_DOC = ${WITH_DOC}")
message(STATUS)
# ######################################################################################################################
# Compiler flags
# ######################################################################################################################
set(common_flags "-fPIC -Wall -Werror -Wextra -Wpedantic -Wno-format-truncation -Wno-stringop-truncation")
set(CMAKE_CXX_FLAGS "${common_flags} ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${common_flags} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_STANDARD 17)
set(AOS_CORE_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if(WITH_TEST)
add_definitions(-include ${AOS_CORE_LIB_DIR}/include/aos/test/aoscoretestconfig.hpp)
endif()
# ######################################################################################################################
# Dependencies
# ######################################################################################################################
set(CMAKE_MODULE_PATH ${AOS_CORE_LIB_DIR}/cmake)
if(WITH_TEST)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.13.0
)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)
enable_testing()
endif()
if(WITH_COVERAGE)
include(CodeCoverage)
append_coverage_compiler_flags()
set(COVERAGE_EXCLUDES "build/*" "/usr/*" "*_test.cpp")
setup_target_for_coverage_lcov(NAME coverage EXECUTABLE ctest)
endif()
# ######################################################################################################################
# Includes
# ######################################################################################################################
include_directories(include)
# ######################################################################################################################
# Targets
# ######################################################################################################################
add_subdirectory(src/common)
add_subdirectory(src/sm)
add_subdirectory(src/iam)
if(WITH_TEST)
add_subdirectory(tests)
endif()
# ######################################################################################################################
# Doc
# ######################################################################################################################
if(WITH_DOC)
find_package(Doxygen)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen.cfg ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg @ONLY)
add_custom_target(
doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
endif()