-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
executable file
·85 lines (65 loc) · 2.66 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
cmake_minimum_required(VERSION 3.19)
project(KatalystEngine)
# Find engine library packages
find_package(spdlog REQUIRED)
find_package(glfw3 REQUIRED)
find_package(imgui CONFIG REQUIRED)
# Add ThirdParty subprojects
add_subdirectory("ThirdParty/glad") # Provides OpenGL 4.6 and Vulkan 1.3 Loaders
# Collect all source files
file(GLOB_RECURSE KATALYST_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/Source/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Source/*.h"
)
# Platform-specific configurations
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
message(STATUS "Building for Windows.")
add_definitions(-DKL_ENGINE_EXPORT)
# Check if Linux folder exists before excluding it
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Source/Platforms/Linux")
list(FILTER KATALYST_SOURCES EXCLUDE REGEX ".*Platforms/Linux/.*")
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS "Building for Linux")
# Check if Windows folder exists before excluding it
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Source/Platforms/Windows")
list(FILTER KATALYST_SOURCES EXCLUDE REGEX ".*Platforms/Windows/.*")
endif()
endif()
# Collect platform-specific source files
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Source/Platforms/${CMAKE_SYSTEM_NAME}")
file(GLOB_RECURSE PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/Source/Platforms/${CMAKE_SYSTEM_NAME}/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Source/Platforms/${CMAKE_SYSTEM_NAME}/*.h"
)
else()
message(WARNING "Platform-specific folder for ${CMAKE_SYSTEM_NAME} does not exist.")
set(PLATFORM_SOURCES "")
endif()
# Combine common and platform-specific sources
set(PROJECT_SOURCES ${KATALYST_SOURCES} ${PLATFORM_SOURCES})
# Debug specific configurations
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DKL_DEBUG_BUILD) # This will enable debug specific features.
endif()
# Create the shared library
add_library(KatalystEngine SHARED ${PROJECT_SOURCES})
# Add compiler defintions
target_compile_definitions(KatalystEngine PRIVATE GLFW_INCLUDE_NONE)
# Precompiled headers
target_precompile_headers(KatalystEngine PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/Source/KatalystPCH.h"
)
# Specify include directories for the library
target_include_directories(KatalystEngine PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/Source"
)
# Link dependencies from packages
target_link_libraries(KatalystEngine PUBLIC spdlog::spdlog_header_only glfw imgui::imgui)
# Link dependencies from ThirdParty
target_link_libraries(KatalystEngine PUBLIC glad)
# Link Platform-specific libraries
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(KatalystEngine PUBLIC dwmapi)
endif()
install(TARGETS KatalystEngine DESTINATION ./lib/)