Making it a library

This commit is contained in:
Pcornat 2024-10-29 23:14:09 +01:00
commit f412b1b997
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD
37 changed files with 46 additions and 59382 deletions

View file

@ -1,28 +1,14 @@
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
project(BillySheet LANGUAGES CXX C)
project(BillySheet LANGUAGES CXX)
#set(GLEW_USE_STATIC_LIBS ON)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
file(GLOB_RECURSE SOURCE_HEADERS include/*.h include/*.hpp)
find_package(Boost CONFIG REQUIRED COMPONENTS stacktrace_addr2line)
include_directories(${Boost_INCLUDE_DIR})
file(GLOB_RECURSE SOURCE_HEADERS
include/*.h
include/*.hpp
external/ImFileDialog/*.h
)
file(GLOB_RECURSE SOURCE_FILES
src/*.cpp
external/ImFileDialog/ImFileDialog.cpp
)
file(GLOB_RECURSE SOURCE_FILES src/*.cpp)
set(SOURCES
${SOURCE_HEADERS}
${SOURCE_FILES})
${SOURCE_HEADERS}
${SOURCE_FILES}
)
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
@ -37,14 +23,6 @@ endif ()
add_subdirectory(external/svector)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
option(GLFW_INSTALL "Generate installation target" OFF)
option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF)
add_subdirectory(external/glfw)
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)
@ -64,30 +42,30 @@ add_subdirectory(external/catch2)
set(COMPILE_FLAGS
-pipe
-march=znver3 # change to native or your architecture.
-mtune=znver3 # same as above
-mrdseed # be careful about this, this is linked to the x86 architecture.
-mrdrnd # same as above
-Wall
-Wextra
-Wpedantic
# -Wpadded
-pedantic
$<$<CONFIG:Release>:-ffunction-sections -fdata-sections>
-fuse-ld=gold
-funroll-loops
-fdevirtualize-at-ltrans
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
-pipe
-march=znver3 # change to native or your architecture.
-mtune=znver3 # same as above
-mrdseed # be careful about this, this is linked to the x86 architecture.
-mrdrnd # same as above
-Wall
-Wextra
-Wpedantic
# -Wpadded
-pedantic
$<$<CONFIG:Release>:-ffunction-sections -fdata-sections>
-fuse-ld=gold
-funroll-loops
-fdevirtualize-at-ltrans
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
)
set(LINKER_OPTIONS
-Wl,--sort-common,--as-needed$<$<CONFIG:Release>:,--gc-sections,--strip-all>
-fuse-ld=gold
-fdevirtualize-at-ltrans
-Wl,--sort-common,--as-needed$<$<CONFIG:Release>:,--gc-sections,--strip-all>
-fuse-ld=gold
-fdevirtualize-at-ltrans
)
set(LINKER_FLAGS
jemalloc
jemalloc
)
option(ENABLE_COVERAGE "Enabling coverage" OFF)
@ -101,57 +79,41 @@ endif ()
add_subdirectory("Unit testing")
add_executable(BillySheet ${SOURCES})
add_library(BillySheet SHARED ${SOURCES})
target_include_directories(BillySheet PRIVATE include include/imgui external/ImFileDialog)
set_target_properties(BillySheet spdlog svector PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON
# UNITY_BUILD ON
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON
# UNITY_BUILD ON
)
set_target_properties(spdlog svector PROPERTIES UNITY_BUILD ON)
set_target_properties(glfw PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED ON
C_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON
# 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>)
$<$<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_definitions(glfw PRIVATE $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
target_compile_options(spdlog PRIVATE ${COMPILE_FLAGS})
target_compile_options(svector INTERFACE ${COMPILE_FLAGS})
target_compile_options(glfw PRIVATE ${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(glfw PRIVATE ${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(glfw PRIVATE ${LINKER_FLAGS})
target_link_libraries(BillySheet glfw
spdlog::spdlog_header_only
svector::svector
OpenGL::OpenGL
GLEW::GLEW
nlohmann_json::nlohmann_json
${Boost_LIBRARIES}
${LINKER_FLAGS}
spdlog::spdlog_header_only
svector::svector
nlohmann_json::nlohmann_json
${LINKER_FLAGS}
)