-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
57 lines (46 loc) · 1.7 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
# Date: 24/07/2024
#
# Description: This CMakeLists.txt file is used to build the project.
#
# To build the project, go into the project's directory and run:
# ./scripts/build.sh [dev] [test]
# Specify the minimum version for CMake and the project's name
cmake_minimum_required(VERSION 3.10)
project(Sudoku)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
# Option to toggle development mode
option(DEVELOPMENT "Build the project in development mode" OFF)
message(STATUS "Development mode: ${DEVELOPMENT}")
# Option to build tests
option(TEST "Build tests" OFF)
message(STATUS "Build tests: ${TEST}")
# Add the main executable
add_executable(Sudoku src/sudoku.cpp)
# Include directories
target_include_directories(Sudoku PUBLIC "include/")
# External dependencies
# Include the findAndCheckDependency function
include(${CMAKE_SOURCE_DIR}/cmake/findAndCheckDependency.cmake)
# Add source files
file(GLOB_RECURSE PROJECT_SOURCES "src/*.cpp")
# Exclude main file to avoid duplication
list(REMOVE_ITEM PROJECT_SOURCES "${CMAKE_SOURCE_DIR}/src/sudoku.cpp")
target_sources(Sudoku PRIVATE ${PROJECT_SOURCES})
# Find and link SFML
find_package(SFML 2.5 COMPONENTS system window graphics audio REQUIRED)
target_link_libraries(Sudoku PRIVATE sfml-system sfml-window sfml-graphics sfml-audio)
# Conditionally include spdlog in development mode
if(DEVELOPMENT)
# Add spdlog
find_and_check_dependency(PACKAGE spdlog)
target_link_libraries(Sudoku PRIVATE spdlog::spdlog)
# Define DEVELOPMENT preprocessor macro
target_compile_definitions(Sudoku PRIVATE DEVELOPMENT=1)
endif()
# Conditionally build tests
if(TEST)
enable_testing()
add_subdirectory(test)
endif()