-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
64 lines (43 loc) · 1.81 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
# DO NOT EDIT THIS FILE
# the correction pipeline will fail if you change anything here!
# this is the root cmake configuration file for your homeworks.
# it sets up the project and (at the bottom) includes your homework code.
cmake_minimum_required(VERSION 3.14)
project(cppcourse)
# try to prevent in-source builds
if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed. Please create a separate 'build' directory and build in there.")
endif()
# set default c++ standard for compile targets
set(CMAKE_CXX_STANDARD 20)
# require C++20, don't allow falling back to older version of standard
set(CXX_STANDARD_REQUIRED ON)
# disable C++ extensions
set(CMAKE_CXX_EXTENSIONS OFF)
# testing features
include(CTest)
enable_testing()
# locate doctest - we use it for testing your code.
find_package(doctest REQUIRED)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
# register the directory with automated tests to cmake
add_subdirectory(tests EXCLUDE_FROM_ALL)
#------- tweaks for an improved build experience -------
# so language servers like clangd know what the buildsystem does
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# windows needs "exported" symbols for linking
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# display many warnings during compilation
# they usually help you find some bugs
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
add_compile_options(-Wall -Wextra -Wconversion -pedantic -Wfatal-errors)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/W3 /WX)
# so the dll files are alongside the executables
# and the windows loader is happy (no more error 0xc0000135)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()
#------- homework code inclusion -------
add_subdirectory("hw08")