This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
generated from geugenm/template-cpp-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
68 lines (52 loc) · 2.26 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
# Set minimum CMake version and project details
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
cmake_policy(SET CMP0048 NEW)
project(basic_game_engine VERSION 1.0.0 LANGUAGES CXX C)
message(STATUS "Configuring ${PROJECT_NAME}...")
# Set default build type to Release if not specified
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting default build type to Release...")
set(CMAKE_BUILD_TYPE Release)
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Setting default build type to Debug. Enabling sanitizer...")
# add_compile_options(-fsanitize=address)
# add_link_options(-fsanitize=address)
endif ()
# Include necessary CMake modules and scripts
message(STATUS "Including necessary CMake modules...")
include(${CMAKE_SOURCE_DIR}/cmake/verify_cpp_support.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/git_update_submodules.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/packages.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/copy_resources.cmake)
option(ENABLE_CODE_QUALITY_TARGETS "Enable code quality tools" OFF)
if (ENABLE_CODE_QUALITY_TARGETS)
message(STATUS "Adding code quality tools targets...")
include(${CMAKE_SOURCE_DIR}/cmake/code_quality.cmake)
endif ()
option(BUILD_DOCS_TARGET "Build documentation" OFF)
if (BUILD_DOCS_TARGET)
message(STATUS "Adding build documentation targets...")
include(${CMAKE_SOURCE_DIR}/cmake/build_docs.cmake)
endif ()
# List library names
get_directory_property(MY_LIBRARIES_NAMES BUILDSYSTEM_TARGETS)
message(STATUS "Library names: ${MY_LIBRARIES_NAMES}")
# List global targets
get_property(_allTargets GLOBAL PROPERTY GlobalTargetList)
message(STATUS "GlobalTargetList: ${_allTargets}")
message(STATUS "Building ${PROJECT_NAME}...")
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(test)
# Print build information
message(STATUS "Compiler flags: ${CMAKE_CXX_FLAGS}")
message(STATUS "Linker flags: ${CMAKE_EXE_LINKER_FLAGS}")
message(STATUS "Build directory: ${CMAKE_BINARY_DIR}")
include(CMakePrintHelpers)
cmake_print_variables(CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_BINARY_DIR)
cmake_print_properties(TARGETS MY_LIBRARIES_NAMES
PROPERTIES POSITION_INDEPENDENT_CODE)
if (NOT DEFINED MY_LIBRARIES_NAMES)
message(FATAL_ERROR "MY_LIBRARIES_NAMES not defined")
endif ()