-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
103 lines (84 loc) · 3.17 KB
/
Copy pathCMakeLists.txt
File metadata and controls
103 lines (84 loc) · 3.17 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
100
101
102
103
cmake_minimum_required(VERSION 3.20)
# Project name and C++ standard
project(foliage_be)
set(CMAKE_CXX_STANDARD 20)
# Include directories (adjust paths as necessary)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/third-party
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Create the library target with shared code
add_library(foliage_lib STATIC
# Source files
third-party/tinyxml2.cpp
src/OSM.cpp
src/Geometry.cpp
src/QuadTree.cpp
src/LayeredAStarPathfinder.cpp
src/object.cpp
src/ConfigManager.h
# Add other shared source files if any
)
# Ensure the library has access to the necessary include directories
target_include_directories(foliage_lib PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/third-party
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Link any required libraries for foliage_lib (if needed)
# target_link_libraries(foliage_lib PUBLIC ...)
# Create the main executable
add_executable(foliage_be
main.cpp
# You can add any source files specific to the main executable here
)
# Link the main executable against the library
target_link_libraries(foliage_be PRIVATE foliage_lib)
# Ensure the main executable has access to necessary includes
target_include_directories(foliage_be PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/third-party
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Now we create the test executable
add_executable(foliage_be_tests
src/test/LayeredAStarPathfinderTest.cpp
src/test/QuadTreeTest.cpp
# Add other test source files if necessary
)
# Link the test executable against the library and GoogleTest libraries
target_link_libraries(foliage_be_tests
PRIVATE
foliage_lib
gtest_main
gtest
pthread # Add pthread if using on Linux/macOS
)
# Ensure the test executable has access to necessary includes
target_include_directories(foliage_be_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/third-party
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Set compile and link options based on the build type
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(foliage_be PRIVATE -fsanitize=undefined -g3)
target_link_options(foliage_be PRIVATE -fsanitize=undefined -g3)
target_compile_options(foliage_be_tests PRIVATE -fsanitize=undefined -g3)
target_link_options(foliage_be_tests PRIVATE -fsanitize=undefined -g3)
target_compile_options(foliage_lib PRIVATE -fsanitize=undefined -g3)
target_link_options(foliage_lib PRIVATE -fsanitize=undefined -g3)
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_options(foliage_be PRIVATE -O3)
target_link_options(foliage_be PRIVATE -O3)
target_compile_options(foliage_be_tests PRIVATE -O3)
target_link_options(foliage_be_tests PRIVATE -O3)
target_compile_options(foliage_lib PRIVATE -O3)
target_link_options(foliage_lib PRIVATE -O3)
endif()
# Enable testing
enable_testing()
# Add test discovery (automatically find all the tests in the test executable)
include(GoogleTest)
gtest_discover_tests(foliage_be_tests)