Removing useless submodules and exporting targets

This commit is contained in:
Pcornat 2024-10-30 20:35:38 +01:00
parent 9d57971414
commit 2b59a832a4
Signed by: Pcornat
GPG Key ID: E0326CC678A00BDD
6 changed files with 51 additions and 47 deletions

9
.gitmodules vendored
View File

@ -1,12 +1,3 @@
[submodule "external/spdlog"]
path = external/spdlog
url = https://github.com/gabime/spdlog.git
[submodule "external/json"]
path = external/json
url = https://github.com/nlohmann/json.git
[submodule "external/catch2"]
path = external/catch2
url = https://github.com/catchorg/Catch2.git
[submodule "external/svector"]
path = external/svector
url = https://github.com/martinus/svector.git

View File

@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
project(BillySheet LANGUAGES CXX)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(FetchContent)
file(GLOB_RECURSE SOURCE_HEADERS include/*.h include/*.hpp)
file(GLOB_RECURSE SOURCE_FILES src/*.cpp)
@ -10,6 +14,9 @@ set(SOURCES
${SOURCE_FILES}
)
find_package(PkgConfig REQUIRED)
pkg_check_modules(Jemalloc REQUIRED IMPORTED_TARGET jemalloc)
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
message(STATUS "ccache found !")
@ -21,20 +28,11 @@ else ()
message(STATUS "ccache not found")
endif ()
add_subdirectory(external/svector)
option(SPDLOG_ENABLE_PCH "Build static or shared library using precompiled header to speed up compilation time" ON)
option(SPDLOG_BUILD_WARNINGS "Enable compiler warnings" ON)
option(SPDLOG_PREVENT_CHILD_FD "Prevent from child processes to inherit log file descriptors" ON)
option(SPDLOG_NO_THREAD_ID "prevent spdlog from querying the thread id on each log call if thread id is not needed" ON)
option(SPDLOG_NO_TLS "prevent spdlog from using thread local storage" ON)
option(SPDLOG_NO_ATOMIC_LEVELS "prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently" ON)
add_subdirectory(external/spdlog)
fetchcontent_declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
set(JSON_BuildTests OFF CACHE INTERNAL "")
option(JSON_ImplicitConversions "Enable implicit conversions." OFF)
option(JSON_SystemInclude "Include as system headers (skip for clang-tidy)." ON)
add_subdirectory(external/json)
fetchcontent_makeavailable(json)
option(CATCH_INSTALL_DOCS "Install documentation alongside library" OFF)
option(CATCH_INSTALL_EXTRAS "Install extras alongside library" OFF)
@ -64,10 +62,6 @@ set(LINKER_OPTIONS
-fdevirtualize-at-ltrans
)
set(LINKER_FLAGS
jemalloc
)
option(ENABLE_COVERAGE "Enabling coverage" OFF)
if (${ENABLE_COVERAGE})
@ -79,41 +73,56 @@ endif ()
add_library(BillySheet SHARED ${SOURCES})
target_include_directories(BillySheet PRIVATE include include/imgui external/ImFileDialog)
target_include_directories(BillySheet
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INDLUDEDIR}/billySheet>
)
set_target_properties(BillySheet spdlog svector PROPERTIES
set_target_properties(BillySheet PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON
# UNITY_BUILD ON
UNITY_BUILD ON
PUBLIC_HEADER "include/billy_objects.hpp;include/character_sheet.hpp;include/generic_object.hpp;include/characteristic.hpp"
)
set_target_properties(spdlog svector PROPERTIES UNITY_BUILD ON)
target_compile_definitions(BillySheet PRIVATE
$<$<CONFIG:Debug>:_GLIBCXX_DEBUG>
$<$<CONFIG:Debug>:SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG>
$<$<CONFIG:Release>:SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_ERROR>)
)
target_compile_definitions(spdlog PRIVATE $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
target_compile_definitions(svector INTERFACE $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
target_compile_options(spdlog PRIVATE ${COMPILE_FLAGS})
target_compile_options(svector INTERFACE ${COMPILE_FLAGS})
target_compile_options(BillySheet PRIVATE ${COMPILE_FLAGS})
target_link_options(spdlog PRIVATE ${LINKER_OPTIONS})
target_link_options(svector INTERFACE ${LINKER_OPTIONS})
target_link_options(BillySheet PRIVATE ${LINKER_OPTIONS})
target_link_libraries(spdlog PRIVATE ${LINKER_FLAGS})
target_link_libraries(svector INTERFACE ${LINKER_FLAGS})
target_link_libraries(BillySheet glfw
spdlog::spdlog_header_only
svector::svector
target_link_libraries(BillySheet PUBLIC
nlohmann_json::nlohmann_json
${LINKER_FLAGS}
PkgConfig::Jemalloc
)
install(TARGETS BillySheet nlohmann_json
EXPORT billySheetTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/billySheet"
)
install(EXPORT billySheetTargets
FILE billySheetTargets.cmake
NAMESPACE billySheet::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/billySheet
)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/billySheetConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/billySheet
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/billySheetConfig.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/billySheet
)
add_subdirectory("Unit testing")

7
Config.cmake.in Normal file
View File

@ -0,0 +1,7 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/billySheetTargets.cmake")
include(CMakeFindDependencyMacro)
find_dependency(PkgConfig REQUIRED)
check_required_components(billySheet)

1
external/json vendored

@ -1 +0,0 @@
Subproject commit 9cca280a4d0ccf0c08f47a99aa71d1b0e52f8d03

1
external/spdlog vendored

@ -1 +0,0 @@
Subproject commit 27cb4c76708608465c413f6d0e6b8d99a4d84302

1
external/svector vendored

@ -1 +0,0 @@
Subproject commit cbeced42e061da03b881ba1d09621d4604de030a