Newer
Older
set(namespace "fggl")
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)
##
# Windows
# When on windows, integrate vcpkg
##
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()
DESCRIPTION "FOSS Galaxy Game Library, for use in Education, and Games"
HOMEPAGE_URL "https://git.fossgalaxy.com/gamedev/fggl"
# export compile commands for vim/neovim users
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# vendor dependencies
add_subdirectory( vendor/imgui )
add_subdirectory( vendor/header_only )
# engine headers
file(GLOB_RECURSE public_headers
${PROJECT_SOURCE_DIR}/include/fggl/*.hpp
)
# engine sources, enable strict compiler warnings
target_compile_options( fggl PRIVATE -Wall -Wpedantic -Wextra -Wodr -fno-strict-aliasing -fno-strict-overflow )
set_property(TARGET fggl PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
add_subdirectory( integrations/entt )
Joseph Walton-Rivers
committed
add_subdirectory(tests)
endif()
# 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()
# Demo project
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)
##
# INSTALL PHASE
# see https://decovar.dev/blog/2021/03/08/cmake-cpp-library/
##
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"
Joseph Walton-Rivers
committed
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"
Joseph Walton-Rivers
committed
DESTINATION "${FGGL_CONFIG_PATH}"
)
# generate the export targets for the build tree
install(TARGETS ${PROJECT_NAME}
EXPORT fgglTargets
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
export(EXPORT "${PROJECT_NAME}Targets"
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
NAMESPACE ${namespace}::
)
# 3rd party integrations
add_subdirectory( integrations/bullet )