-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
88 lines (71 loc) · 2.62 KB
/
CMakeLists.txt
File metadata and controls
88 lines (71 loc) · 2.62 KB
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
cmake_minimum_required(VERSION 3.16)
project(AudioIdentifier VERSION 0.0.2
DESCRIPTION ""
LANGUAGES CXX)
# Prevent building in the source directory
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.")
endif()
# Set C++ standard to C++20
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set build type to Release if not specified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
# Update the submodules
include(external/UpdateSubmodules.cmake)
# Add subdirectory with external projects' code
message(STATUS "Adding subdirectory for external projects")
add_subdirectory(external)
# Include common settings
include(cmake/StandardSettings.cmake)
include(cmake/StaticAnalyzers.cmake)
include(cmake/Utils.cmake)
# Define debug macro for UNIX
if (UNIX)
add_compile_options("$<$<CONFIG:DEBUG>:-D_DEBUG>")
endif()
# Setup alternative names
if(${PROJECT_NAME}_USE_ALT_NAMES)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWERCASE)
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)
else()
set(PROJECT_NAME_LOWERCASE ${PROJECT_NAME})
set(PROJECT_NAME_UPPERCASE ${PROJECT_NAME})
endif()
# Find all headers and implementation files
include(cmake/SourcesAndHeaders.cmake)
include(cmake/Database.cmake)
include(cmake/Engine.cmake)
include(cmake/UI.cmake)
# Build executable if enabled
if(${PROJECT_NAME}_BUILD_EXECUTABLE)
add_executable(${PROJECT_NAME} ${main_sources})
target_link_libraries(${PROJECT_NAME} Engine UI Database)
add_executable(load_folder ${loader_sources})
target_link_libraries(load_folder Engine Database)
add_executable(test_folder ${folder_tester_sources})
target_link_libraries(test_folder Engine Database)
endif()
# Set output directories
set_target_properties(
${PROJECT_NAME}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}"
)
# Enable package managers if needed
# include(cmake/Conan.cmake)
# include(cmake/Vcpkg.cmake)
# Set compiler warnings
include(cmake/CompilerWarnings.cmake)
set_project_warnings(${PROJECT_NAME})
# Enable unit testing if specified
if(${PROJECT_NAME}_ENABLE_UNIT_TESTING)
enable_testing()
message(STATUS "Building unit tests for the project. Tests should always be found in the test folder")
add_subdirectory(test)
endif()