BillySheet/CMakeLists.txt

159 lines
5.4 KiB
CMake
Raw Normal View History

2022-01-08 20:02:04 +01:00
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
project(BillySheet LANGUAGES CXX C)
2022-01-08 20:02:04 +01:00
#set(GLEW_USE_STATIC_LIBS ON)
2022-01-08 23:40:31 +01:00
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
2022-01-08 23:40:31 +01:00
2022-01-17 23:36:12 +01:00
find_package(Boost REQUIRED COMPONENTS stacktrace_addr2line)
include_directories(${Boost_INCLUDE_DIR})
2024-02-23 19:38:17 +01:00
file(GLOB_RECURSE SOURCE_HEADERS
include/*.h
include/*.hpp
external/ImFileDialog/*.h
2024-01-28 20:31:50 +01:00
)
2022-01-08 20:02:04 +01:00
2024-02-23 19:38:17 +01:00
file(GLOB_RECURSE SOURCE_FILES
src/*.cpp
external/ImFileDialog/ImFileDialog.cpp
2024-01-28 20:31:50 +01:00
)
set(SOURCES
2024-01-28 21:10:36 +01:00
${SOURCE_HEADERS}
${SOURCE_FILES})
2022-01-08 23:40:31 +01:00
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
2024-01-28 21:10:36 +01:00
message(STATUS "ccache found !")
set_property(GLOBAL PROPERTY C_COMPILER_LAUNCHER ccache)
set_property(GLOBAL PROPERTY C_LINKER_LAUNCHER ccache)
set_property(GLOBAL PROPERTY CXX_COMPILER_LAUNCHER ccache)
set_property(GLOBAL PROPERTY CXX_LINKER_LAUNCHER ccache)
2022-01-08 23:40:31 +01:00
else ()
2024-01-28 21:10:36 +01:00
message(STATUS "ccache not found")
2022-01-08 23:40:31 +01:00
endif ()
2024-02-29 12:13:43 +01:00
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)
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)
set(JSON_BuildTests OFF CACHE INTERNAL "")
2022-06-09 21:52:49 +02:00
option(JSON_ImplicitConversions "Enable implicit conversions." OFF)
option(JSON_SystemInclude "Include as system headers (skip for clang-tidy)." ON)
add_subdirectory(external/json)
option(CATCH_INSTALL_DOCS "Install documentation alongside library" OFF)
option(CATCH_INSTALL_EXTRAS "Install extras alongside library" OFF)
add_subdirectory(external/catch2)
2022-01-08 23:40:31 +01:00
set(COMPILE_FLAGS
2024-01-28 21:10:36 +01:00
-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
-ffunction-sections
-fdata-sections
-fuse-ld=gold
-funroll-loops
-fdevirtualize-at-ltrans
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
2024-01-28 20:31:50 +01:00
)
2022-01-08 23:40:31 +01:00
set(LINKER_OPTIONS
2024-01-28 21:10:36 +01:00
-Wl,--sort-common,--as-needed,--gc-sections,--strip-all
-fuse-ld=gold
-fdevirtualize-at-ltrans
2024-01-28 20:31:50 +01:00
)
2022-01-08 23:40:31 +01:00
set(LINKER_FLAGS
2024-01-28 21:10:36 +01:00
jemalloc
2024-01-28 20:31:50 +01:00
)
2022-01-08 23:40:31 +01:00
option(ENABLE_COVERAGE "Enabling coverage" OFF)
if (${ENABLE_COVERAGE})
2024-01-28 21:10:36 +01:00
message(STATUS "Coverage enabled")
list(APPEND COMPILE_FLAGS --coverage)
list(APPEND LINKER_OPTIONS --coverage)
list(APPEND LINKER_FLAGS gcov)
endif ()
add_subdirectory("Unit testing")
add_executable(BillySheet ${SOURCES})
target_include_directories(BillySheet PRIVATE include include/imgui external/ImFileDialog)
2024-02-29 12:13:43 +01:00
set_target_properties(BillySheet spdlog svector PROPERTIES
2024-01-28 21:10:36 +01:00
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON
# UNITY_BUILD ON
2024-01-28 20:31:50 +01:00
)
2022-01-20 22:47:08 +01:00
2024-02-29 12:13:43 +01:00
set_target_properties(spdlog svector PROPERTIES UNITY_BUILD ON)
2022-01-20 22:47:08 +01:00
2022-01-08 23:40:31 +01:00
set_target_properties(glfw PROPERTIES
2024-01-28 21:10:36 +01:00
C_STANDARD 11
C_STANDARD_REQUIRED ON
C_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON
UNITY_BUILD ON
2024-01-28 20:31:50 +01:00
)
2022-01-08 23:40:31 +01:00
2022-01-17 23:36:12 +01:00
target_compile_definitions(BillySheet PRIVATE
2024-01-28 21:10:36 +01:00
$<$<CONFIG:Debug>:_GLIBCXX_DEBUG>
$<$<CONFIG:Debug>:SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG>
$<$<CONFIG:Release>:SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_ERROR>)
2022-01-08 23:40:31 +01:00
2024-02-29 12:04:09 +01:00
target_compile_definitions(spdlog PRIVATE $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
2024-02-29 12:13:43 +01:00
target_compile_definitions(svector INTERFACE $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
2024-02-29 12:04:09 +01:00
target_compile_definitions(glfw PRIVATE $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
2022-01-20 22:47:08 +01:00
2022-01-08 23:40:31 +01:00
target_compile_options(spdlog PRIVATE ${COMPILE_FLAGS})
2024-02-29 12:13:43 +01:00
target_compile_options(svector INTERFACE ${COMPILE_FLAGS})
2022-01-08 23:40:31 +01:00
target_compile_options(glfw PRIVATE ${COMPILE_FLAGS})
target_compile_options(BillySheet PRIVATE ${COMPILE_FLAGS})
target_link_options(spdlog PRIVATE ${LINKER_OPTIONS})
2024-02-29 12:13:43 +01:00
target_link_options(svector INTERFACE ${LINKER_OPTIONS})
2022-01-08 23:40:31 +01:00
target_link_options(glfw PRIVATE ${LINKER_OPTIONS})
target_link_options(BillySheet PRIVATE ${LINKER_OPTIONS})
target_link_libraries(spdlog PRIVATE ${LINKER_FLAGS})
2024-02-29 12:13:43 +01:00
target_link_libraries(svector INTERFACE ${LINKER_FLAGS})
2022-01-08 23:40:31 +01:00
target_link_libraries(glfw PRIVATE ${LINKER_FLAGS})
2024-02-29 12:04:09 +01:00
target_link_libraries(BillySheet glfw
spdlog::spdlog_header_only
2024-02-29 12:13:43 +01:00
svector::svector
2024-02-29 12:04:09 +01:00
OpenGL::OpenGL
GLEW::GLEW
nlohmann_json::nlohmann_json
${Boost_LIBRARIES}
${LINKER_FLAGS}
)