-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
37 lines (28 loc) · 1.19 KB
/
CMakeLists.txt
File metadata and controls
37 lines (28 loc) · 1.19 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
# Get the exercise name from the current directory
get_filename_component(root_folder ${CMAKE_CURRENT_SOURCE_DIR} NAME)
# string(REPLACE "-" "_" project_name ${root_folder})
# Set the minimum version of CMake that can be used To find the cmake version
# run $ cmake --version
cmake_minimum_required(VERSION 3.5)
# Set the project name
project(${root_folder})
# Create a sources variable with a link to all cpp files to compile
set(SOURCES src/Tests.cpp src/Float2.cpp src/User.cpp)
# Add an executable
add_executable(${PROJECT_NAME} ${SOURCES})
# Add catch2 to the project
add_subdirectory(third_party/catch2)
target_link_libraries(${PROJECT_NAME} catch2)
# Set the directories that should be included in the build command for this
# target when running g++ these will be included as -I/directory/path/
# target_include_directories(${PROJECT_NAME} PRIVATE
# ${PROJECT_SOURCE_DIR}/catch2)
target_include_directories(${PROJECT_NAME}
PRIVATE ${PROJECT_SOURCE_DIR}/include)
# Set C++ standard
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20)
# Run the tests on every build
add_custom_target(
test-${PROJECT_NAME} ALL
DEPENDS ${PROJECT_NAME}
COMMAND ${PROJECT_NAME})