IsoEngine/CMakeLists.txt

106 lines
3.3 KiB
CMake
Raw Normal View History

CMAKE_MINIMUM_REQUIRED(VERSION 3.28) # Required for modern cpp modules support
PROJECT(ICEngine LANGUAGES CXX C)
# Read version for logger
FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VERSION_TEXT)
STRING(STRIP "${VERSION_TEXT}" VERSION_TEXT)
STRING(REGEX MATCH "([A-Z]+)-([0-9]+)\\.([0-9]+)\\.([0-9]+)" _ ${VERSION_TEXT})
SET(PROJECT_VERSION ${CMAKE_MATCH_1}-${CMAKE_MATCH_2}.${CMAKE_MATCH_3}.${CMAKE_MATCH_4})
ADD_DEFINITIONS(-DPROJECT_VERSION=\"${PROJECT_VERSION}\")
OPTION(BUILD_ENGINE_AS_SHARED_LIBRARY "Build engine as a shared library" OFF)
OPTION(BUILD_DEPS_AS_SHARED_LIBRARIES "Builds engine's dependencies as shared libraries" OFF)
OPTION(BUILD_EXAMPLES "Builds examples to showcase engine" OFF)
OPTION(INSTALL_ICENGINE "Install ICEngine as a package" ON)
IF (CMAKE_GENERATOR MATCHES "Visual Studio|Xcode")
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release;MinSizeRel" CACHE STRING "" FORCE)
ELSE ()
IF (NOT CMAKE_BUILD_TYPE)
MESSAGE(" | ICEngine | No build type specified, defaulting to Debug")
SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build: Debug, Release, MinSizeRel" FORCE)
ENDIF ()
ENDIF ()
SET(ARCHITECTURE "x64")
SET(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_XCODE_GENERATE_SCHEME ON)
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
MESSAGE(STATUS "Building for x64 architecture")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${ARCH_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${ARCH_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${ARCH_DIR}/lib)
IF (MSVC)
ADD_COMPILE_OPTIONS(/W4 /WX)
ELSE ()
ADD_COMPILE_OPTIONS(-Wall -Wextra -Werror -Wpedantic)
ENDIF ()
IF (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
ADD_COMPILE_OPTIONS(-fmodules-ts)
ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
ADD_COMPILE_OPTIONS(-fmodules)
ENDIF ()
INCLUDE_DIRECTORIES(
engine/src/
2024-09-09 02:50:07 -06:00
)
IF (BUILD_ENGINE_AS_SHARED_LIBRARY)
ADD_LIBRARY(ICEngine SHARED)
SET_TARGET_PROPERTIES(ICEngine PROPERTIES
OUTPUT_NAME "ICEngine"
WINDOWS_EXPORT_ALL_SYMBOLS ON
)
ELSE ()
ADD_LIBRARY(ICEngine STATIC)
SET_TARGET_PROPERTIES(ICEngine PROPERTIES OUTPUT_NAME "ICEngine")
ENDIF ()
TARGET_SOURCES(ICEngine
PUBLIC
FILE_SET CXX_MODULES
BASE_DIRS engine/src
FILES engine/src/core/ICEngine.ixx
2024-09-09 02:50:07 -06:00
)
TARGET_INCLUDE_DIRECTORIES(ICEngine
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/engine/src>
$<INSTALL_INTERFACE:include>
2024-09-09 02:50:07 -06:00
)
IF (BUILD_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF ()
IF (INSTALL_ICENGINE)
INSTALL(TARGETS ICEngine
EXPORT ICEngineTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
FILE_SET CXX_MODULES DESTINATION include/icengine/modules
)
INSTALL(FILES engine/src/core/Logger.hpp DESTINATION include/icengine)
INSTALL(EXPORT ICEngineTargets
FILE ICEngineConfig.cmake
NAMESPACE ICEngine::
DESTINATION lib/cmake/ICEngine
)
EXPORT(EXPORT ICEngineTargets
FILE ${CMAKE_BINARY_DIR}/ICEngineConfig.cmake
NAMESPACE ICEngine::
)
ENDIF ()