-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathCMakeLists.txt
87 lines (72 loc) · 2.51 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
cmake_minimum_required(VERSION 3.15)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Set default compile flags for GCC
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") )
# using Clang
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fsanitize=address -pedantic -Wall -Wextra -Werror")
endif()
# set the project name
project(cplings
VERSION 0.01
DESCRIPTION "Small exercises to get you used to reading and writing C++ code! Inspired by Rustlings"
)
##############################################
# Create target and set properties
##############################################
set(SOURCE_DIR src)
set(TESTER_DIR tests)
# set the CMake dir
set(CPM_DOWNLOAD_LOCATION "cmake/CPM.cmake")
include(${CPM_DOWNLOAD_LOCATION})
# Specify dependencies
CPMAddPackage("gh:catchorg/[email protected]")
# Including packages for safe_numerics
CPMAddPackage(NAME safe_numerics
GIT_REPOSITORY https://github.com/boostorg/safe_numerics.git
GIT_TAG boost-1.75.0
GIT_SHALLOW TRUE
DOWNLOAD_ONLY YES)
CPMAddPackage("gh:boostorg/core#boost-1.75.0")
CPMAddPackage("gh:boostorg/config#boost-1.75.0")
CPMAddPackage("gh:boostorg/detail#boost-1.75.0")
CPMAddPackage("gh:boostorg/logic#boost-1.75.0")
CPMAddPackage("gh:boostorg/mp11#boost-1.75.0")
CPMAddPackage("gh:boostorg/preprocessor#boost-1.75.0")
CPMAddPackage("gh:boostorg/type_traits#boost-1.75.0")
CPMAddPackage("gh:boostorg/integer#boost-1.75.0")
set(EXERCISES_PATH "exercises")
set(BOOST_LIBS safe_numerics core config detail logic
mp11 preprocessor type_traits integer)
set(UNIT_TESTING_LIBRARY Catch2)
# add each library to the include path
foreach(temp_lib ${BOOST_LIBS})
if(${temp_lib}_ADDED)
add_library(${temp_lib} INTERFACE IMPORTED)
set(temp_include_dir "${${temp_lib}_SOURCE_DIR}")
message(STATUS "For Boost lib ${temp_lib} including ${temp_include_dir}")
target_include_directories(${temp_lib} INTERFACE "${temp_include_dir}/include")
else()
message(STATUS "OOPS: ${temp_lib} not added")
endif()
endforeach()
# add the main tester
add_library(cplings OBJECT ${TESTER_DIR}/main_tester.cpp)
target_include_directories(cplings PUBLIC include)
target_link_libraries(cplings ${UNIT_TESTING_LIBRARY})
set(CHAPTERS
01_variables
02_functions
03_if
04_pointers_references
05_classes
06_raii
07_containers
08_ownership
09_templates
10_security
)
foreach(_test_case ${CHAPTERS})
add_subdirectory (${EXERCISES_PATH}/${_test_case})
endforeach()