-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
72 lines (62 loc) · 2.42 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
# 3.8.2 required for CMAKE_CXX_STANDARD 17
cmake_minimum_required(VERSION 3.8.2 FATAL_ERROR)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# set build type to release if none is specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# options
option(CLANG_TIDY "Check code with clang-tidy." OFF)
option(CODE "Build primary libraries and executables." ON)
option(COVERAGE "Instrument code with coverage flags." OFF)
option(DOXYGEN "Add \"doxygen\" target which builds doxygen HTML output from the sources." OFF)
option(FORMAT "Add \"format\" target which runs clang-format." OFF)
option(FLAWFINDER "Add \"flawfinder\" target which checks code." OFF)
option(SANITISE "Add -fsanitize=address and -fsanitize=undefined flags." OFF)
option(TEST "Build unit and functional tests." OFF)
option(WERROR "Make all warnings into errors." OFF)
# disable base languages
unset(PROJECT_LANGUAGES)
if(${CODE})
set(PROJECT_LANGUAGES ${PROJECT_LANGUAGES} C CXX)
endif()
project(BoxNesting
VERSION 1.0.0
DESCRIPTION "Algorithms and Datastructures practicum 1 box nesting algorithm"
LANGUAGES ${PROJECT_LANGUAGES})
set(PROJECT_VERSION_SUFFIX "") # alpha/beta/rc, e.g. "-rc0"
set(PROJECT_VERSION "${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX}")
set(PROJECT_AUTHOR "Ties Klappe & Rowan Goemans")
set(PROJECT_COPYRIGHT "Copyright (C) 2018 Ties Klappe & Rowan Goemans")
set(PROJECT_MAIL "[email protected]")
# only set CMAKE variant when local name matches CMAKE name
# this avoids clashing when being used as a subproject
if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CMAKE_PROJECT_VERSION "${PROJECT_VERSION}")
set(CMAKE_PROJECT_VERSION_SUFFIX "${PROJECT_VERSION_SUFFIX}")
set(CMAKE_PROJECT_AUTHOR "${PROJECT_AUTHOR}")
set(CMAKE_PROJECT_COPYRIGHT "${PROJECT_COPYRIGHT}")
set(CMAKE_PROJECT_MAIL "${PROJECT_MAIL}")
endif()
include(version)
include(version_header)
if(${CODE})
include(code)
elseif(${CLANG_TIDY} OR ${COVERAGE} OR ${SANITISE} OR ${TEST})
message(FATAL_ERROR "At least one flag enabled that requires CODE=ON.")
endif()
if(${FORMAT})
include(clang_format)
endif()
if(${FLAWFINDER})
include(flawfinder)
endif()
if(${FLAWFINDER} OR ${FORMAT})
include(check)
endif()
if(${DOXYGEN})
add_subdirectory(doxygen)
endif()