-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
118 lines (103 loc) · 3.73 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
115
116
117
# Set required version of CMake. Set this to the version
# of cmake on your computer/server. To find the version,
# run the command: `cmake --version`
cmake_minimum_required(VERSION 3.20)
# Specify the C++ standard that you will use in the project:
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# This will export the commands required to compile your
# program. This important for a lot of external tools such
# as language servers and debuggers for allowing them to
# understand the overall structure of your program and give
# better feedback and support. Not necessary but generally
# good to have.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Add knots main executable
set(KNOT_SRC_FILES
src/convert_knots.hpp
src/convert_knots.cpp
)
project(knot CXX)
add_executable(${PROJECT_NAME} ${KNOT_SRC_FILES})
# Add stack main executable
set(STACK_SRC_FILES
src/stack.hpp
src/stack.cpp
)
project(stack CXX)
add_executable(${PROJECT_NAME} ${STACK_SRC_FILES})
# Add letter_count main executable
set(COUNT_SRC_FILES
src/letter_count.hpp
src/letter_count.cpp
)
project(count CXX)
add_executable(${PROJECT_NAME} ${COUNT_SRC_FILES})
# This is for optionally building GTest suites. If GTest
# is installed on your system and it can be found on your
# $PATH, then this will build a 'gtest' binary that will
# run your tests. GTest is guaranteed to be installed on
# OpenLab, but you will need to install it on your own computer
# for this to build.
find_package(GTest REQUIRED)
if (GTest_FOUND)
# Knot Tests:
project(knot_gtests CXX)
# If you add other test files, be sure to add them to
# this list!
# NOTE : We are adding src/convert_knots.hpp manually
# here to disconnect errors in `stack` from affecting
# this test.
set(KNOT_GTEST_FILES
gtest/gtestmain.cpp
gtest/knot_gtests.cpp
src/convert_knots.hpp
)
include_directories(${GTEST_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} ${KNOT_GTEST_FILES})
# This ensures that the cpp files in gtest/ can include headers from
# src/ simply by doing
# #include "foo.hpp"
# instead of having to write the cumbersome
# #include "../src/foo.hpp"
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(${PROJECT_NAME} ${GTEST_LIBRARIES})
# Stack Tests:
project(stack_gtests CXX)
# If you add other test files, be sure to add them to
# this list!
set(STACK_GTEST_FILES
gtest/gtestmain.cpp
gtest/stack_gtests.cpp
src/stack.hpp
src/stack.cpp
)
include_directories(${GTEST_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} ${STACK_GTEST_FILES})
# This ensures that the cpp files in gtest/ can include headers from
# src/ simply by doing
# #include "foo.hpp"
# instead of having to write the cumbersome
# #include "../src/foo.hpp"
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(${PROJECT_NAME} ${GTEST_LIBRARIES} )
# Letter Count Tests:
project(count_gtests CXX)
# If you add other test files, be sure to add them to
# this list!
set(COUNT_GTEST_FILES
gtest/gtestmain.cpp
gtest/count_gtests.cpp
src/letter_count.hpp
)
include_directories(${GTEST_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} ${COUNT_GTEST_FILES})
# This ensures that the cpp files in gtest/ can include headers from
# src/ simply by doing
# #include "foo.hpp"
# instead of having to write the cumbersome
# #include "../src/foo.hpp"
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(${PROJECT_NAME} ${GTEST_LIBRARIES})
endif()