-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
143 lines (117 loc) · 4.41 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
cmake_minimum_required(VERSION 3.11...3.16)
if (${CMAKE_VERSION} VERSION_LESS 3.11)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif ()
cmake_policy(SET CMP0054 NEW)
message("CMake Version: ${CMAKE_VERSION}.")
# This is a magic line. Don't mess with this.
# Essentially, each library needs to be built either dynamically or statically,
# but it needs to be built in a consistent manner. This is for MSVC.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
project(FinalProject
VERSION 1.0
DESCRIPTION "CS 126 Final Project"
LANGUAGES CXX)
include(ExternalProject)
# Optionally set things like CMAKE_CXX_STANDARD, CMAKE_POSITION_INDEPENDENT_CODE here
set(CMAKE_CXX_STANDARD 14)
# This tells the compiler to not aggressively optimize and
# to include debugging information so that the debugger
# can properly read what's going on.
# You can set a release configuration through CLion.
set(CMAKE_BUILD_TYPE Debug)
# Let's ensure -std=c++xx instead of -std=g++xx
set(CMAKE_CXX_EXTENSIONS OFF)
# Let's nicely support folders in IDE's
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Allow code coverage.
if("{CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang"
OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
message("Building with llvm Code Coverage Tools")
set(CMAKE_CXX_FLAGS "-fprofile-instr-generate -fcoverage-mapping")
elseif(CMAKE_COMPILER_IS_GNUCXX)
message("Building with lcov Code Coverage Tools")
set(CMAKE_CXX_FLAGS "--coverage")
endif()
# Docs only available if this is the main app
find_package(Doxygen)
if(Doxygen_FOUND)
add_subdirectory(docs)
else()
# This is the message that some of you were seeing. It's not really an error or anything.
message(STATUS "Doxygen not found, not building docs")
endif()
# FetchContent added in CMake 3.11, downloads during the configure step
include(FetchContent)
# FetchContent_MakeAvailable was not added until CMake 3.14
if(${CMAKE_VERSION} VERSION_LESS 3.14)
include(cmake/add_FetchContent_MakeAvailable.cmake)
endif()
# The library code is here.
add_subdirectory(src)
# The Cinder executable code is here.
add_subdirectory(apps)
# The tests are here.
add_subdirectory(tests)
############## Third-party Libraries #####################
# Testing library. Header-only.
FetchContent_Declare(
catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.11.1
)
FetchContent_Declare(
sqlite-modern-cpp
GIT_REPOSITORY https://github.com/SqliteModernCpp/sqlite_modern_cpp.git
GIT_TAG a0f96c10f04d96ccea1b8a49d5998c96e7887bf4
)
FetchContent_Declare(
sqlite3
GIT_REPOSITORY https://github.com/alex85k/sqlite3-cmake.git
GIT_TAG v3.24.0
)
# Command-line parsing library
FetchContent_Declare(
gflags
GIT_REPOSITORY https://github.com/gflags/gflags.git
GIT_TAG v2.2.2
)
# JSON Library. Header-only.
FetchContent_Declare(
nlohmann_json
URL https://github.com/nlohmann/json/releases/download/v3.7.3/include.zip
)
# Adds catch2 library. This is a header only library.
FetchContent_GetProperties(catch2)
if(NOT catch2_POPULATED)
FetchContent_Populate(catch2)
# This is overkill since we only need a single file. Though it is a clean solution.
add_library(catch2 INTERFACE)
target_include_directories(catch2 INTERFACE ${catch2_SOURCE_DIR}/single_include)
endif()
FetchContent_GetProperties(sqlite-modern-cpp)
if (NOT sqlite-modern-cpp_POPULATED)
FetchContent_Populate(sqlite-modern-cpp)
add_library(sqlite-modern-cpp INTERFACE)
target_include_directories(sqlite-modern-cpp INTERFACE ${sqlite-modern-cpp_SOURCE_DIR}/hdr)
endif ()
FetchContent_GetProperties(sqlite3)
if (NOT sqlite3_POPULATED)
FetchContent_Populate(sqlite3)
add_subdirectory(${sqlite3_SOURCE_DIR} ${sqlite3_BINARY_DIR})
target_include_directories(sqlite3 INTERFACE ${sqlite3_SOURCE_DIR}/src)
endif ()
# Adds gflags::gflags
FetchContent_GetProperties(gflags)
if (NOT gflags_POPULATED)
FetchContent_Populate(gflags)
add_subdirectory(${gflags_SOURCE_DIR} ${gflags_BINARY_DIR})
endif ()
# Adds nlohmann_json library.
FetchContent_GetProperties(nlohmann_json)
if (NOT nlohmann_json_POPULATED)
FetchContent_Populate(nlohmann_json)
add_library(nlohmann_json INTERFACE)
target_include_directories(nlohmann_json INTERFACE ${nlohmann_json_SOURCE_DIR}/single_include)
endif ()
# Add more CMake libraries here ...