-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
154 lines (121 loc) · 6.39 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#/*============================================================================
#
# PHAS0100ASSIGNMENT1: PHAS0100 Assignment 1 Game of Life Simulation.
#
# Copyright (c) University College London (UCL). All rights reserved.
#
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.
#
# See LICENSE.txt in the top level directory for details.
#
#============================================================================*/
######################################################################
# Set the minimum CMake version.
######################################################################
set(PHAS0100ASSIGNMENT1_CMAKE_MINIMUM_REQUIRED_VERSION 3.10)
cmake_minimum_required(VERSION ${PHAS0100ASSIGNMENT1_CMAKE_MINIMUM_REQUIRED_VERSION})
###################################################################################
# Set some CMake Policies.
# See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details.
###################################################################################
set(project_policies )
foreach(policy ${project_policies})
if(POLICY ${policy})
cmake_policy(SET ${policy} NEW)
endif()
endforeach()
###############################################################################
# Setup project name, and version.
###############################################################################
project(PHAS0100ASSIGNMENT1 VERSION 0.0.0)
######################################################################
# Setup the path to load CMake macros, and extra CMake files.
# This means cmake can 'see' or 'use' files in the CMake folder.
######################################################################
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)
######################################################################
# Set main build options.
######################################################################
option(BUILD_TESTING "Build Unit tests." ON)
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
######################################################################
# Setup Testing.
######################################################################
include(golSetupTesting)
######################################################################
# Setting supported build types. Should ONLY be Release or Debug.
######################################################################
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Valid options are Release or Debug" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug")
endif()
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "Debug"))
message(FATAL_ERROR "Build type \"${CMAKE_BUILD_TYPE}\" is not supported.")
endif()
######################################################################
# Choose C++ standard. Currently 17.
######################################################################
set(PHAS0100ASSIGNMENT1_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS 0)
set(CMAKE_CXX_STANDARD ${PHAS0100ASSIGNMENT1_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED 1)
######################################################################
# Print out where the source and binary folders
# are, just to make it really explicit.
######################################################################
message("CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}")
message("CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}")
######################################################################
# Additionally add the build folder, now we are building main project.
######################################################################
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
######################################################################
# Copy some reference files to output.
######################################################################
configure_file(${CMAKE_SOURCE_DIR}/LICENSE.txt ${CMAKE_BINARY_DIR}/LICENSE.txt @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/LICENSE.txt DESTINATION . COMPONENT CONFIG)
configure_file(${CMAKE_SOURCE_DIR}/README.md ${CMAKE_BINARY_DIR}/README.md @ONLY)
######################################################################
# Organise module/plugin/etc projects better within the IDE.
######################################################################
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
######################################################################
# Suppress some warnings related to old Eigen library. In general not
# a good idea to suppress warnings but these have been confirmed to be
# unconsequential and were confusing for students learning cmake.
######################################################################
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations" CACHE STRING "FLags used by the compiler during all build types." FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-ignored-attributes")
endif()
######################################################################
# A few shortcuts for lists of libraries.
######################################################################
set(PHAS0100ASSIGNMENT1_LIBRARIES PHAS0100ASSIGNMENT1)
set(ALL_LIBRARIES ${PHAS0100ASSIGNMENT1_LIBRARIES})
######################################################################
# Set up a few paths.
######################################################################
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(PHAS0100ASSIGNMENT1_INSTALL_LIB_DIR lib)
set(PHAS0100ASSIGNMENT1_INSTALL_INC_DIR include)
set(PHAS0100ASSIGNMENT1_INSTALL_BIN_DIR bin)
foreach(type LIBRARY RUNTIME ARCHIVE)
set(output_dir ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.")
mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY)
endforeach()
include_directories(${CMAKE_SOURCE_DIR}/Code/3rdParty/Eigen-3.2.2.1)
include_directories(${CMAKE_SOURCE_DIR}/Code/Lib)
include_directories(${CMAKE_BINARY_DIR})
######################################################################
# Add our main code folders. This is where all our functionality is.
######################################################################
add_subdirectory(Code)
if(BUILD_TESTING)
set(TEMP_DIR ${CMAKE_BINARY_DIR}/Testing/Temporary)
include_directories(${CMAKE_SOURCE_DIR}/Testing/)
add_subdirectory(Testing)
endif()