BillySheet/CMakeLists.txt

184 lines
5.8 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
# see https://cmake.org/cmake/help/latest/module/FindBoost.html
find_package(Boost REQUIRED COMPONENTS stacktrace_addr2line)
include_directories(${Boost_INCLUDE_DIR})
2022-01-08 23:40:31 +01:00
set(PRECOMPILE_HEADERS
2022-01-11 22:33:29 +01:00
include/gui/gui.hpp
include/gui/gui_data.hpp
include/gui/window.hpp
2022-01-08 23:40:31 +01:00
)
set(SOURCE_HEADERS
include/imgui/imconfig.h
include/imgui/imgui.h
2022-01-17 19:57:00 +01:00
include/imgui/imgui_stdlib.h
include/imgui/imgui_impl_glfw.h
include/imgui/imgui_impl_opengl3.h
include/imgui/imgui_impl_opengl3_loader.h
include/imgui/imgui_internal.h
2022-01-08 23:40:31 +01:00
include/imgui/imstb_rectpack.h
include/imgui/imstb_textedit.h
include/imgui/imstb_truetype.h
include/stb_image.h
external/ImFileDialog/ImFileDialog.h
2022-01-11 22:33:29 +01:00
include/gui/gui.hpp
include/gui/gui_data.hpp
include/gui/window.hpp
include/character_sheet.hpp
2022-01-10 21:16:05 +01:00
include/characteristic/habilete.hpp
include/characteristic/adresse.hpp
include/characteristic/endurance.hpp
include/characteristic/chance.hpp
include/gui/menu/menu.hpp
2022-01-17 19:57:00 +01:00
include/gui/menu/menu_data.hpp
include/characteristic/characteristic.hpp
include/controller.hpp
)
2022-01-08 20:02:04 +01:00
set(SOURCE_FILES
src/imgui/imgui.cpp
2022-01-17 19:57:00 +01:00
src/imgui/imgui_stdlib.cpp
src/imgui/imgui_draw.cpp
src/imgui/imgui_impl_glfw.cpp
src/imgui/imgui_impl_opengl3.cpp
src/imgui/imgui_tables.cpp
src/imgui/imgui_widgets.cpp
external/ImFileDialog/ImFileDialog.cpp
src/main.cpp
2022-01-11 22:33:29 +01:00
src/gui/gui.cpp
src/gui/gui_data.cpp
src/gui/window.cpp
src/character_sheet.cpp
2022-01-10 21:16:05 +01:00
src/characteristic/adresse.cpp
src/characteristic/endurance.cpp
src/characteristic/chance.cpp
src/gui/menu/menu.cpp
2022-01-17 19:57:00 +01:00
src/controller.cpp
2022-01-10 21:16:05 +01:00
)
set(SOURCES
${SOURCE_HEADERS}
${SOURCE_FILES})
2022-01-08 23:40:31 +01:00
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
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)
else ()
message(STATUS "ccache not found")
endif ()
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 "")
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)
add_subdirectory("Unit testing")
2022-01-08 23:40:31 +01:00
set(COMPILE_FLAGS
-pipe
-march=skylake # change to native or your architecture.
-mtune=skylake # same as above
-mrdseed # be careful about this, this is linked to the x86 architecture.
-mrdrnd # same as above
-Wall
-Wextra
-Wpedantic
2022-01-10 21:16:05 +01:00
# -Wpadded
2022-01-08 23:40:31 +01:00
-pedantic
2022-01-20 22:47:08 +01:00
-ffunction-sections
-fdata-sections
2022-01-08 23:40:31 +01:00
-fuse-ld=gold
-funroll-loops
-fdevirtualize-at-ltrans
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
)
set(LINKER_OPTIONS
2022-01-20 22:47:08 +01:00
-Wl,--sort-common,--as-needed,--gc-sections,--strip-all
2022-01-08 23:40:31 +01:00
-fuse-ld=gold
-fdevirtualize-at-ltrans
)
set(LINKER_FLAGS
jemalloc
)
add_executable(BillySheet ${SOURCES})
target_include_directories(BillySheet PRIVATE include include/imgui external/ImFileDialog)
2022-01-08 23:40:31 +01:00
set_target_properties(BillySheet spdlog PROPERTIES
2022-01-08 20:02:04 +01:00
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON
2022-01-08 23:40:31 +01:00
# UNITY_BUILD ON
)
2022-01-20 22:47:08 +01:00
set_target_properties(spdlog PROPERTIES UNITY_BUILD ON)
2022-01-08 23:40:31 +01:00
set_target_properties(glfw PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED ON
C_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON
2022-01-20 22:47:08 +01:00
UNITY_BUILD ON
2022-01-08 23:40:31 +01:00
)
2022-01-17 23:36:12 +01:00
set_target_properties(spdlog PROPERTIES UNITY_BUILD ON)
2022-01-08 23:40:31 +01:00
#target_precompile_headers(BillySheet PRIVATE ${PRECOMPILE_HEADERS})
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>)
2022-01-08 23:40:31 +01:00
2022-01-20 22:47:08 +01:00
target_compile_definitions(spdlog PRIVATE
$<$<CONFIG:Debug>:_GLIBCXX_DEBUG>
$<$<CONFIG:Debug>:SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG>
$<$<CONFIG:Release>:SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_ERROR>)
target_compile_definitions(glfw PRIVATE
$<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
2022-01-08 23:40:31 +01:00
target_compile_options(spdlog PRIVATE ${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(glfw PRIVATE ${LINKER_OPTIONS})
target_link_options(BillySheet PRIVATE ${LINKER_OPTIONS})
target_link_libraries(spdlog PRIVATE ${LINKER_FLAGS})
target_link_libraries(glfw PRIVATE ${LINKER_FLAGS})
2022-01-17 23:36:12 +01:00
target_link_libraries(BillySheet glfw spdlog OpenGL::OpenGL GLEW::GLEW nlohmann_json::nlohmann_json ${Boost_LIBRARIES} ${LINKER_FLAGS})