forked from zaphodgjd/class-chess-123
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
127 lines (111 loc) · 3.5 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
cmake_minimum_required(VERSION 3.2.0)
project(Chess VERSION 0.1.0 LANGUAGES C CXX)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 20)
# Check for the operating system and compiler
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOS TRUE)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX TRUE)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(WINDOWS TRUE)
endif()
# Set compiler-specific flags for g++ and MinGW
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(LINUX OR WINDOWS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-cast-function-type -Wno-unused-variable -Wno-missing-field-initializers -Wno-overloaded-virtual")
endif()
endif()
# Find OpenGL and other dependencies
find_package(OpenGL REQUIRED)
# Include GLFW for macOS and Linux, or other necessary libraries
if(MACOS OR LINUX)
find_package(glfw3 REQUIRED)
include_directories(${GLFW_INCLUDE_DIRS})
endif()
# Define the platform-specific source files
if(MACOS)
set(MAIN_FILE "main_macos.cpp")
set(IMPL_FILE "imgui/imgui_impl_glfw.cpp")
elseif(WINDOWS)
set(MAIN_FILE "main_win32.cpp")
set(IMPL_FILE "imgui/imgui_impl_win32.cpp")
else() # Linux
set(MAIN_FILE "main_macos.cpp")
set(IMPL_FILE "imgui/imgui_impl_glfw.cpp")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(SOURCES
Application.cpp
imgui/imgui_demo.cpp
imgui/imgui_draw.cpp
imgui/imgui_tables.cpp
imgui/imgui_widgets.cpp
imgui/imgui.cpp
imgui/imgui_impl_opengl3.cpp
classes/ChessAI.cpp
classes/MagicBitboards/MagicBitboards.cpp
classes/Move.cpp
classes/MagicBitboards/ProtoBoard.cpp
classes/GameState.cpp
classes/Bit.cpp
classes/BitHolder.cpp
classes/ChessSquare.cpp
classes/Game.cpp
classes/Sprite.cpp
classes/MoveGeneration.cpp
classes/Chess.cpp
${MAIN_FILE}
${IMPL_FILE}
tools/Logger.cpp
)
else()
set(SOURCES
Application.cpp
imgui/imgui_demo.cpp
imgui/imgui_draw.cpp
imgui/imgui_tables.cpp
imgui/imgui_widgets.cpp
imgui/imgui.cpp
imgui/imgui_impl_opengl3.cpp
classes/ChessAI.cpp
classes/MagicBitboards/MagicBitboards.cpp
classes/Move.cpp
classes/MagicBitboards/ProtoBoard.cpp
classes/GameState.cpp
classes/Bit.cpp
classes/BitHolder.cpp
classes/ChessSquare.cpp
classes/Game.cpp
classes/Sprite.cpp
classes/MoveGeneration.cpp
classes/ChessStrings.cpp
classes/Chess.cpp
${MAIN_FILE}
${IMPL_FILE}
)
endif()
# Define the executable and sources
add_executable(Chess ${SOURCES})
target_compile_definitions(Chess PRIVATE $<$<CONFIG:Debug>:DEBUG>)
target_sources(Chess PRIVATE $<$<CONFIG:Debug>:tools/Logger.cpp>)
# headers used to make IDEs not scream at me.
target_sources(Chess PRIVATE
classes/ChessPiece.h
classes/PrecomputedData.h
classes/MagicBitboards/BitFunctions.h
classes/MagicBitboards/EvaluationTables.h
)
# Link libraries based on the platform
if(MACOS OR LINUX)
target_link_libraries(Chess ${OPENGL_gl_LIBRARY} glfw)
elseif(WINDOWS)
target_link_libraries(Chess ${OPENGL_gl_LIBRARY})
if(MINGW)
target_link_libraries(Chess dwmapi)
endif()
endif()
# Set the project for packaging
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)