2024-11-21 17:41:52 +00:00
|
|
|
# Set minimum CMake version
|
|
|
|
cmake_minimum_required(VERSION 3.22)
|
|
|
|
|
|
|
|
# Declare project
|
2024-07-29 15:59:40 +00:00
|
|
|
project(engine)
|
|
|
|
|
2024-11-21 17:41:52 +00:00
|
|
|
# Define variables of source files and include directories
|
|
|
|
set(CORE_INCLUDES core)
|
|
|
|
set(INPUT_INCLUDES core/input)
|
|
|
|
file(GLOB_RECURSE CORE_SOURCES "${CORE_INCLUDES}/*.cpp")
|
|
|
|
file(GLOB_RECURSE INPUT_SOURCES "${INPUT_INCLUDES}/*.cpp")
|
|
|
|
|
|
|
|
set(RENDERING_INCLUDES rendering)
|
|
|
|
file(GLOB_RECURSE RENDERING_SOURCES "${RENDERING_INCLUDES}/*.cpp")
|
2024-07-29 15:59:40 +00:00
|
|
|
|
2024-11-21 17:41:52 +00:00
|
|
|
set(SCENE_INCLUDES scene)
|
|
|
|
set(COMPONENTS_INCLUDES scene/components)
|
|
|
|
file(GLOB SCENE_SOURCES "${SCENE_INCLUDES}/*.cpp")
|
|
|
|
file(GLOB COMPONENTS_SOURCES "${COMPONENTS_INCLUDES}/*.cpp")
|
2024-07-29 15:59:40 +00:00
|
|
|
|
2024-11-21 17:41:52 +00:00
|
|
|
set(UI_INCLUDES ui)
|
|
|
|
file(GLOB UI_SOURCES "${UI_INCLUDES}/*.cpp")
|
|
|
|
|
2024-11-27 16:52:57 +00:00
|
|
|
set(ENGINE_RESOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
|
|
|
|
set(ENGINE_RESOURCES_DIR ${ENGINE_RESOURCES_DIR} PARENT_SCOPE)
|
2024-11-22 13:40:41 +00:00
|
|
|
|
2024-11-21 17:41:52 +00:00
|
|
|
# Build engine as library
|
2024-07-29 15:59:40 +00:00
|
|
|
add_library(${PROJECT_NAME})
|
|
|
|
|
2024-11-21 17:41:52 +00:00
|
|
|
# Add resources folder
|
2024-07-30 16:57:32 +00:00
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
2024-11-22 13:40:41 +00:00
|
|
|
file(COPY ${ENGINE_RESOURCES_DIR} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC ENGINE_RESOURCES_PATH="${CMAKE_CURRENT_BINARY_DIR}/resources/")
|
2024-07-30 16:57:32 +00:00
|
|
|
else()
|
2024-11-27 16:52:57 +00:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC ENGINE_RESOURCES_PATH="${ENGINE_RESOURCES_DIR}/")
|
2024-07-30 16:57:32 +00:00
|
|
|
endif()
|
2024-07-29 15:59:40 +00:00
|
|
|
|
2024-11-21 17:41:52 +00:00
|
|
|
# Link sources, include directories, and third party libraries
|
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
|
|
|
${CORE_INCLUDES} ${INPUT_INCLUDES}
|
|
|
|
${RENDERING_INCLUDES}
|
|
|
|
${SCENE_INCLUDES} ${COMPONENTS_INCLUDES}
|
|
|
|
${UI_INCLUDES})
|
|
|
|
target_sources(${PROJECT_NAME} PRIVATE
|
|
|
|
${CORE_SOURCES} ${INPUT_SOURCES}
|
|
|
|
${RENDERING_SOURCES}
|
|
|
|
${SCENE_SOURCES} ${COMPONENTS_SOURCES}
|
|
|
|
${UI_SOURCES})
|
2024-08-22 15:55:30 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME} glfw glad glm imgui stb)
|