Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
76 lines (63 loc) · 1.98 KB
/
Copy pathCMakeLists.txt
File metadata and controls
76 lines (63 loc) · 1.98 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
cmake_minimum_required(VERSION 3.22)
project(chess_ai)
enable_language(CXX)
# Set C++ 17 standard.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Install CHESS-AI Project Dependencies
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
include(FetchContent)
FetchContent_Declare(SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.6.x
)
FetchContent_Declare(spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.13.0
)
FetchContent_Declare(GTest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG v1.14.x
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(SFML spdlog GTest)
# PROJECT CHESS-AI
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_executable(${PROJECT_NAME} src/main.cpp)
else()
add_executable(${PROJECT_NAME} WIN32 src/main.cpp)
endif()
target_link_libraries(${PROJECT_NAME}
PRIVATE
sfml-graphics
$<$<PLATFORM_ID:Windows>:sfml-main>
gui
logger
)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
$<$<CONFIG:Debug>:DEBUG>
$<$<CONFIG:Release>:RELEASE>
$<$<CONFIG:RelWithDebInfo>:DEBUG>
)
# Set warning level and treat warnings as errors.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${PROJECT_NAME} PRIVATE -Werror -Wall -Wextra -Wpedantic -Wconversion)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE /permissive /W4 /WX)
else()
message(WARNING "Compiler not supported for this project. Compilation might not work as expected. Compiler flags not set.")
endif()
target_precompile_headers(${PROJECT_NAME}
PUBLIC
[["logger/Logger.h"]]
)
# Copy chess pieces images to binary dir.
file(COPY pieces_images DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY fonts DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY book DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
enable_testing()
include(CTest)
add_subdirectory(src)
add_subdirectory(test)