-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
105 lines (86 loc) · 1.96 KB
/
Copy pathCMakeLists.txt
File metadata and controls
105 lines (86 loc) · 1.96 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
104
105
cmake_minimum_required(VERSION 3.16)
project(tsp_ga_solver VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(TSP_BUILD_TESTS "Build unit tests" OFF)
# Try find_package first (vcpkg), fallback to FetchContent
find_package(cxxopts QUIET)
if(NOT cxxopts_FOUND)
include(FetchContent)
FetchContent_Declare(
cxxopts
GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git
GIT_TAG v3.1.1
)
FetchContent_MakeAvailable(cxxopts)
endif()
if(TSP_BUILD_TESTS)
find_package(GTest QUIET)
if(NOT GTest_FOUND)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
FetchContent_MakeAvailable(googletest)
endif()
endif()
add_library(tsp_core
src/city.cpp
src/tsplib_parser.cpp
src/population.cpp
)
target_include_directories(tsp_core
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(tsp_core
PUBLIC
cxxopts::cxxopts
)
add_library(tsp_cli
src/cli.cpp
)
target_include_directories(tsp_cli
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(tsp_cli
PUBLIC
cxxopts::cxxopts
tsp_core
)
add_executable(tsp_solver
src/main.cpp
)
target_include_directories(tsp_solver
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(tsp_solver
PRIVATE
tsp_core
tsp_cli
)
if(TSP_BUILD_TESTS)
enable_testing()
add_executable(tsp_tests
tests/test_core.cpp
)
target_include_directories(tsp_tests
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(tsp_tests
PRIVATE
tsp_core
GTest::gtest_main
)
include(GoogleTest)
gtest_discover_tests(tsp_tests)
endif()
install(TARGETS tsp_solver
RUNTIME DESTINATION bin
)