Forked from
Game Development / Game Library
169 commits behind the upstream repository.
-
Joseph Walton-Rivers authoredJoseph Walton-Rivers authored
CMakeLists.txt 3.76 KiB
cmake_minimum_required(VERSION 3.16)
set(namespace "fggl")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
option(FGGL_CONAN "Should we use conan to find missing dependencies?" OFF)
option(FGGL_EXAMPLES "Should we build examples or just the library" ON)
option(FGGL_TESTS "Should we enable the testing suite?" ON)
option(FGGL_DOCS "Should we build documentation?" ON)
set(CONAN_BUILD_TYPE "Debug")
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
endif()
# Define the project
project(fggl
VERSION 0.1
DESCRIPTION ""
HOMEPAGE_URL ""
LANGUAGES C CXX)
include(GNUInstallDirs)
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# slightly cleaner conan support
include(cmake/conan-wrangler.cmake)
# testing support
include(CTest)
# Documentation support
if (FGGL_DOCS)
find_package(Doxygen)
if (Doxygen_FOUND)
add_subdirectory( docs )
else()
message(STATUS "Doxygen not found, not building docs")
endif()
endif()
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
##
# end windows support
##
# vendor dependencies
add_subdirectory( vendor/imgui )
# engine
add_subdirectory( fggl )
add_subdirectory( vendor/header_only )
# 3rd party integrations
add_subdirectory( integrations/bullet )
## G++ enable insane checks
target_compile_options( ${PROJECT_NAME} PRIVATE -Wall -Wpedantic -Wextra -Wodr -fno-strict-aliasing -fno-strict-overflow )
set_property(TARGET fggl PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
# extras
if (FGGL_TESTS)
add_subdirectory(tests)
endif()
if (FGGL_EXAMPLES)
add_subdirectory(demo)
target_compile_options( demo PRIVATE -Wall -Wextra -Wodr -Wdouble-promotion -fno-strict-aliasing -fno-strict-overflow )
set_property(TARGET demo PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
endif()
##
# INSTALL PHASE
# see https://decovar.dev/blog/2021/03/08/cmake-cpp-library/
##
file(GLOB_RECURSE public_headers
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/*.hpp
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/*.h
)
#include(CMakePrintHelpers)
# Structure preserving header macro
foreach(header ${public_headers})
file(RELATIVE_PATH header_file_path "${CMAKE_CURRENT_SOURCE_DIR}/include" "${header}")
get_filename_component(header_directory_path "${header_file_path}" DIRECTORY)
install(
FILES ${header}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${header_directory_path}"
)
endforeach()
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d")
include(CMakePackageConfigHelpers)
set(FGGL_CONFIG_PATH "${CMAKE_INSTALL_LIBDIR}/cmake/fggl")
# generate and install export file
install(EXPORT "${PROJECT_NAME}Targets"
FILE "${PROJECT_NAME}Targets.cmake"
NAMESPACE ${namespace}::
DESTINATION "${FGGL_CONFIG_PATH}"
)
# generate the version file for the config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION "${version}"
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${FGGL_CONFIG_PATH}"
)
# install config files
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION "${FGGL_CONFIG_PATH}"
)
# generate the export targets for the build tree
export(EXPORT "${PROJECT_NAME}Targets"
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
NAMESPACE ${namespace}::
)
install(TARGETS ${PROJECT_NAME}
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)