-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
99 lines (80 loc) · 3.18 KB
/
CMakeLists.txt
File metadata and controls
99 lines (80 loc) · 3.18 KB
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
# Example CMake command line to create project build files:
#
# cmake -B Build . -DENABLE_IT=ON
# Specify the minimum CMake version required
cmake_minimum_required(VERSION 3.10)
# Project name and language (C or C++)
project(IntegrationTestFramework VERSION 1.0 LANGUAGES CXX)
# Set build options (see Predef.cmake)
set(DMQ_ASSERTS "OFF") # ON for assert faults
set(DMQ_ALLOCATOR "OFF") # ON for fixed-block allocator
set(DMQ_LOG "OFF") # ON for spglog output
set(DMQ_UTIL "ON") # ON for delegate utility classes
set(DMQ_THREAD "DMQ_THREAD_STDLIB") # Set thread support library or none
set(DMQ_SERIALIZE "DMQ_SERIALIZE_SERIALIZE") # Set serialization support library or none
set(DMQ_TRANSPORT "DMQ_TRANSPORT_NONE") # Set transport support library or none
include("${CMAKE_SOURCE_DIR}/DelegateMQ/DelegateMQ.cmake")
# Enable integration test build
set (ENABLE_IT "ON")
add_compile_definitions(IT_ENABLE)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Ensure all libraries use the dynamically linked runtime (/MDd for Debug, /MD for Release)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:DebugDLL>")
# Force GoogleTest to use the dynamic runtime libraries
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Collect all .cpp and *.h source files in the current directory
file(GLOB SOURCES "*.cpp" "*.h")
# Collect DelegateMQ predef source files
list(APPEND SOURCES ${DMQ_PORT_SOURCES})
# Organize delegate source files within IDE (Visual Studio)
source_group("Delegate Files" FILES ${DMQ_LIB_SOURCES})
source_group("Port Files" FILES ${DMQ_PORT_ONLY_SOURCES})
source_group("Extras Files" FILES ${DMQ_EXTRAS_SOURCES})
# Platform-specific linker flags
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
# GCC/Clang: Use --no-as-needed to prevent the removal of unused libraries
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-as-needed")
endif()
# Define the IT_ENABLE macro for the IntegrationTestFrameworkApp target
if (ENABLE_IT)
add_compile_definitions(IT_ENABLE)
endif()
# Add subdirectories to include path
include_directories(
${CMAKE_SOURCE_DIR}/Logger/src
${CMAKE_SOURCE_DIR}/Port/src
)
# Add subdirectories to include path if building integration tests
if (ENABLE_IT)
include_directories(
${DMQ_ROOT_DIR}
${CMAKE_SOURCE_DIR}/Logger/it
${CMAKE_SOURCE_DIR}/IntegrationTest
${CMAKE_SOURCE_DIR}/GoogleTest/googletest/include
)
endif()
# Add an executable target
add_executable(IntegrationTestFrameworkApp ${SOURCES} ${DMQ_LIB_SOURCES})
# Add subdirectories to build (product related code)
add_subdirectory(Logger/src)
add_subdirectory(Port/src)
# Add subdirectories to build (integration test related code)
if (ENABLE_IT)
add_subdirectory(Logger/it)
add_subdirectory(IntegrationTest)
add_subdirectory(GoogleTest)
endif()
target_link_libraries(IntegrationTestFrameworkApp PRIVATE
LoggerLib
PortLib
)
if (ENABLE_IT)
target_link_libraries(IntegrationTestFrameworkApp PRIVATE
Logger_ITLib
IntegrationTestLib
gtest
gtest_main
)
endif()