SimpleEngine/CMakeLists.txt

69 lines
2.2 KiB
CMake
Raw Normal View History

cmake_minimum_required (VERSION 3.6)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
project(SimpleEngine)
include(cmrc/CMakeRC.cmake)
include (CMake/GetStbLibraries.cmake)
# Add some CMake options:
2021-09-06 02:32:13 +00:00
option(SIMPLE_ENGINE_BUILD_EXAMPLES "Build example projects" ON)
# 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)
find_package(OpenGL REQUIRED)
# Get the stb header libraries.
#include(FetchContent)
#FetchContent_Declare(
# stb
# GIT_REPOSITORY https://github.com/nothings/stb.git
# GIT_TAG 8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55
#)
#FetchContent_MakeAvailable(stb)
#message("Downloaded stb library to: ${stb_SOURCE_DIR}")
# Link sources
file(GLOB_RECURSE source_list src/*.cpp)
add_library(simpleengine STATIC ${source_list})
# Link headers
target_include_directories(simpleengine PUBLIC include PRIVATE include/simpleengine)
# 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}
)
# Link dependencies
2021-11-20 05:48:47 +00:00
target_link_libraries(simpleengine PUBLIC GLEW::GLEW)
target_link_libraries(simpleengine PUBLIC glfw)
2022-09-16 15:14:38 +00:00
target_link_libraries(simpleengine PUBLIC ${GLM_LIBRARIES})
target_link_libraries(simpleengine PUBLIC ${OPENGL_LIBRARIES})
target_link_libraries(simpleengine PRIVATE simpleengine_resources)
target_include_directories(simpleengine PUBLIC ${STB_INCLUDE_DIR})
# Include some dependencies' include directories
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${GLM_INCLUDE_DIRS})
# Add examples as a target if the user has them enabled
2021-09-06 02:32:13 +00:00
if (SIMPLE_ENGINE_BUILD_EXAMPLES)
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)