-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
106 lines (82 loc) · 2.77 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
# Copyright Dominic (DNKpp) Koepke 2024 - 2024.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 3.15)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project(
mimicpp
LANGUAGES CXX
VERSION 5
DESCRIPTION "A modern and (mostly) macro free mocking-framework"
HOMEPAGE_URL "https://github.com/DNKpp/mimicpp"
)
set(MESSAGE_PREFIX "mimic++:")
message(STATUS "${MESSAGE_PREFIX} version: v${PROJECT_VERSION} from: ${mimicpp_SOURCE_DIR}")
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "${MESSAGE_PREFIX} targeting 64-bit architecture")
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
message(STATUS "${MESSAGE_PREFIX} targeting 32-bit architecture")
else ()
message(WARNING "${MESSAGE_PREFIX} unable to determine architecture")
endif ()
message(DEBUG "${MESSAGE_PREFIX} CXXFLAGS: $ENV{CXXFLAGS}")
message(DEBUG "${MESSAGE_PREFIX} CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message(DEBUG "${MESSAGE_PREFIX} CMAKE_CXX_FLAGS_INIT: ${CMAKE_CXX_FLAGS_INIT}")
include(GNUInstallDirs)
add_library(mimicpp INTERFACE)
add_library(mimicpp::mimicpp ALIAS mimicpp)
target_include_directories(
mimicpp
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_compile_options(
mimicpp
INTERFACE
# this option is required to make __VA_OPT__ work on msvc
"$<$<CXX_COMPILER_ID:MSVC>:/Zc:preprocessor>"
)
set(CMAKE_CXX_STANDARD 20)
if (MIMICPP_FORCED_CXX_STANDARD)
set(CMAKE_CXX_STANDARD ${MIMICPP_FORCED_CXX_STANDARD})
endif()
target_compile_features(
mimicpp
INTERFACE
cxx_std_${CMAKE_CXX_STANDARD}
)
include(EnableConfigOptions)
target_link_libraries(
mimicpp
INTERFACE
mimicpp::internal::config-options
)
if (CMAKE_SOURCE_DIR STREQUAL mimicpp_SOURCE_DIR)
set(IS_TOP_LEVEL_PROJECT ON)
else()
set(IS_TOP_LEVEL_PROJECT OFF)
endif()
OPTION(MIMICPP_BUILD_TESTS "Determines, whether the tests shall be built." ${IS_TOP_LEVEL_PROJECT})
if (MIMICPP_BUILD_TESTS)
include(CTest)
add_subdirectory("test")
endif()
OPTION(MIMICPP_BUILD_EXAMPLES "Determines, whether the examples shall be built." ${IS_TOP_LEVEL_PROJECT})
if (MIMICPP_BUILD_EXAMPLES)
include(CTest)
add_subdirectory("examples")
endif()
OPTION(MIMICPP_CONFIGURE_DOXYGEN "Determines, whether the doxyfile shall be configured." OFF)
if (MIMICPP_CONFIGURE_DOXYGEN)
OPTION(MIMICPP_ENABLE_GENERATE_DOCS "Enable the doxygen documentation target." OFF)
add_subdirectory("docs")
endif()
OPTION(MIMICPP_ENABLE_AMALGAMATE_HEADERS "Enables the amalgamation target." OFF)
if (MIMICPP_ENABLE_AMALGAMATE_HEADERS)
add_subdirectory("tools/amalgamate-headers")
endif()
if(NOT CMAKE_SKIP_INSTALL_RULES)
include(InstallRules)
endif()