-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
48 lines (40 loc) · 1.82 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
# Tests
# - Not setting BUILD_TESTING as a command line argument is equivalent to use -DBUILD_TESTING=OFF
# To build tests, use -DBUILD_TESTING=ON
# - Finding boost.test can be done in two ways :
# + With a package handler (for examples apt-get on unbuntu or vcpkg on windows)
# To do this, set CMAKE_TOOLCHAIN_FILE as a command line argument.
# + By downloading, compiling and installing it
# To do this, set BUILD_DEPS to ON as a command line argument.
# - To find boost.test, you must use one of these two ways : not setting CMAKE_TOOLCHAIN_FILE or BUILD_DEPS
# leads to an error. Note that the first has priority over the second in case you set both cache variables.
#
# Usage (with unit tests and boost.test to run tests) :
# Configuration :
# - with vcpkg for boost.test :
# > cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE=${vcpkg_path}/scripts/buildsystems/vcpkg.cmake -DBUILD_TESTING=ON . -B build
# - with boost.test installation from github
# > cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=release -DBUILD_TESTING=ON -DBUILD_DEPS=ON . -B build
# Build :
# > cmake --build build --config Release
# Run unit tests :
# > cd build
# > ctest -C Release
# > cd ..
cmake_minimum_required(VERSION 3.5)
project(Fizzbuzz LANGUAGES CXX)
if(CMAKE_TOOLCHAIN_FILE)
set(BUILD_DEPS OFF)
endif()
add_subdirectory(src)
if(BUILD_TESTING)
# include(CTest) # call enable_testing() and turn BUILD_TESTING to ON by default (among other useful things)
enable_testing()
if(BUILD_DEPS)
# Setting CMAKE_PREFIX_PATH so that find_package(boost.test...) finds "${FizzBuzz current path}/ext" boost.test
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ext")
endif()
# Finds boost.test or builds boost.test from github
add_subdirectory(ext)
add_subdirectory(tests)
endif()