2020-07-03 03:48:58 +00:00
|
|
|
cmake_minimum_required (VERSION 3.6)
|
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
|
2020-07-03 03:53:28 +00:00
|
|
|
project(SimpleEngine)
|
2020-07-03 03:48:58 +00:00
|
|
|
|
2021-11-21 06:23:53 +00:00
|
|
|
include(cmrc/CMakeRC.cmake)
|
2022-09-22 02:52:06 +00:00
|
|
|
include(CMake/GetStbLibraries.cmake)
|
2022-09-23 04:44:07 +00:00
|
|
|
include(CMake/GetEnTT.cmake)
|
2021-11-21 06:23:53 +00:00
|
|
|
|
2020-07-03 03:48:58 +00:00
|
|
|
# Add some CMake options:
|
2021-09-06 02:32:13 +00:00
|
|
|
option(SIMPLE_ENGINE_BUILD_EXAMPLES "Build example projects" ON)
|
2020-07-03 03:48:58 +00:00
|
|
|
|
2022-08-18 15:34:05 +00:00
|
|
|
# By default use OpenGL GLVND
|
|
|
|
option(SIMPLE_ENGINE_USE_GL_LEGACY "Use OpenGL legacy, or use BLVND" OFF)
|
|
|
|
if (SIMPLE_ENGINE_USE_GL_LEGACY)
|
|
|
|
set(OpenGL_GL_PREFERENCE "LEGACY")
|
|
|
|
else()
|
|
|
|
set(OpenGL_GL_PREFERENCE "GLVND")
|
|
|
|
endif()
|
|
|
|
|
2021-11-20 05:48:47 +00:00
|
|
|
find_package(GLEW REQUIRED)
|
|
|
|
find_package(glfw3 CONFIG REQUIRED)
|
|
|
|
find_package(glm CONFIG REQUIRED)
|
2022-08-18 15:34:05 +00:00
|
|
|
find_package(OpenGL REQUIRED)
|
2022-10-28 22:49:29 +00:00
|
|
|
find_package(fmt REQUIRED)
|
|
|
|
find_package(spdlog REQUIRED)
|
2022-09-29 01:21:47 +00:00
|
|
|
find_package(assimp CONFIG REQUIRED)
|
2022-11-11 00:07:05 +00:00
|
|
|
find_package(Bullet REQUIRED)
|
2022-09-17 23:41:38 +00:00
|
|
|
|
2020-07-03 03:48:58 +00:00
|
|
|
# Link sources
|
|
|
|
file(GLOB_RECURSE source_list src/*.cpp)
|
2020-07-03 03:53:28 +00:00
|
|
|
add_library(simpleengine STATIC ${source_list})
|
2020-07-03 03:48:58 +00:00
|
|
|
|
2022-10-28 22:49:29 +00:00
|
|
|
target_compile_definitions(simpleengine PUBLIC SPDLOG_FMT_EXTERNAL)
|
|
|
|
|
2020-07-03 03:48:58 +00:00
|
|
|
# Link headers
|
2020-07-03 03:53:28 +00:00
|
|
|
target_include_directories(simpleengine PUBLIC include PRIVATE include/simpleengine)
|
2020-07-03 03:48:58 +00:00
|
|
|
|
2021-12-13 03:21:10 +00:00
|
|
|
# Embed shaders
|
|
|
|
file(GLOB_RECURSE simpleeng_resources_list resources/**)
|
|
|
|
cmrc_add_resource_library(
|
|
|
|
simpleengine_resources# ALIAS simpleengine::res::shaders
|
|
|
|
#NAMESPACE simpleengine__res
|
|
|
|
#WHENCE resources/shaders
|
|
|
|
#PREFIX resources/shaders
|
|
|
|
${simpleeng_resources_list}
|
|
|
|
)
|
|
|
|
|
2020-07-03 03:48:58 +00:00
|
|
|
# Link dependencies
|
2021-11-20 05:48:47 +00:00
|
|
|
target_link_libraries(simpleengine PUBLIC GLEW::GLEW)
|
|
|
|
target_link_libraries(simpleengine PUBLIC glfw)
|
2022-10-28 22:49:29 +00:00
|
|
|
target_link_libraries(simpleengine PUBLIC fmt)
|
|
|
|
target_link_libraries(simpleengine PUBLIC spdlog)
|
2022-09-16 15:14:38 +00:00
|
|
|
target_link_libraries(simpleengine PUBLIC ${GLM_LIBRARIES})
|
2022-08-18 15:34:05 +00:00
|
|
|
target_link_libraries(simpleengine PUBLIC ${OPENGL_LIBRARIES})
|
2022-11-11 00:07:05 +00:00
|
|
|
target_link_libraries(simpleengine PUBLIC ${BULLET_LIBRARIES})
|
2022-09-29 01:21:47 +00:00
|
|
|
if(WIN32)
|
|
|
|
target_link_libraries(simpleengine PUBLIC assimp::assimp)
|
|
|
|
else()
|
|
|
|
target_link_libraries(simpleengine PUBLIC assimp)
|
|
|
|
endif()
|
|
|
|
|
2022-10-12 03:16:52 +00:00
|
|
|
# Link resources
|
|
|
|
target_link_libraries(simpleengine PUBLIC cmrc::base)
|
2021-12-13 03:21:10 +00:00
|
|
|
target_link_libraries(simpleengine PRIVATE simpleengine_resources)
|
2022-09-22 02:52:06 +00:00
|
|
|
|
2022-08-18 15:34:05 +00:00
|
|
|
# Include some dependencies' include directories
|
2022-09-22 02:52:06 +00:00
|
|
|
target_include_directories(simpleengine PUBLIC ${OPENGL_INCLUDE_DIR})
|
|
|
|
target_include_directories(simpleengine PUBLIC ${GLM_INCLUDE_DIRS})
|
2022-09-23 04:44:07 +00:00
|
|
|
target_include_directories(simpleengine PUBLIC ${STB_INCLUDE_DIR})
|
|
|
|
target_include_directories(simpleengine PUBLIC ${ENTT_INCLUDE_DIR})
|
2022-11-11 00:07:05 +00:00
|
|
|
target_include_directories(simpleengine PUBLIC ${BULLET_INCLUDE_DIRS})
|
2021-11-25 21:15:24 +00:00
|
|
|
|
2020-07-03 03:48:58 +00:00
|
|
|
# Add examples as a target if the user has them enabled
|
2021-09-06 02:32:13 +00:00
|
|
|
if (SIMPLE_ENGINE_BUILD_EXAMPLES)
|
2020-07-03 03:48:58 +00:00
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
|
|
|
|
2021-11-20 05:48:47 +00:00
|
|
|
# Set C++ standard to C++20
|
|
|
|
set_target_properties(simpleengine PROPERTIES CXX_STANDARD 20 CXX_EXTENSIONS OFF)
|