billy-gtk4-interface/CMakeLists.txt

90 lines
3.6 KiB
CMake
Raw Normal View History

2024-10-24 11:02:04 +02:00
cmake_minimum_required(VERSION 3.30)
project(LearnGtk4 LANGUAGES CXX)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTKMM4 REQUIRED IMPORTED_TARGET gtkmm-4.0)
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 ()
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
-pedantic
$<$<CONFIG:Release>:-ffunction-sections -fdata-sections>
-fuse-ld=gold
-funroll-loops
-fdevirtualize-at-ltrans
)
set(LINKER_OPTIONS
-Wl,--sort-common,--as-needed$<$<CONFIG:Release>:,--gc-sections,--strip-all>
-fuse-ld=gold
-fdevirtualize-at-ltrans
)
option(ENABLE_COVERAGE "Enabling coverage" OFF)
if (${ENABLE_COVERAGE})
message(STATUS "Coverage enabled")
list(APPEND COMPILE_FLAGS --coverage)
list(APPEND LINKER_OPTIONS --coverage)
list(APPEND LINKER_FLAGS gcov)
endif ()
2024-10-24 11:14:17 +02:00
option(BUILD_SHARED_LIBS "Build package with shared libraries." ON)
option(ASSIMP_NO_EXPORT "Disable Assimp's export functionality." ON)
option(ASSIMP_INSTALL "Disable this if you want to use assimp as a submodule." OFF)
option(ASSIMP_BUILD_ZLIB "Build your own zlib" OFF)
option(ASSIMP_BUILD_TESTS "If the test suite for Assimp is built in addition to the library." OFF)
option(ASSIMP_WARNINGS_AS_ERRORS "Treat all warnings as errors." OFF)
option(ASSIMP_INSTALL_PDB "Install MSVC debug files." OFF)
option(ASSIMP_INJECT_DEBUG_POSTFIX "Inject debug postfix in .a/.so/.dll lib names" OFF)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
option(ASSIMP_INJECT_DEBUG_POSTFIX "Inject debug postfix in .a/.so/.dll lib names" ON)
else ()
option(ASSIMP_INJECT_DEBUG_POSTFIX "Inject debug postfix in .a/.so/.dll lib names" OFF)
endif ()
add_subdirectory(external/assimp EXCLUDE_FROM_ALL)
2024-10-29 22:50:13 +01:00
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 EXCLUDE_FROM_ALL)
2024-10-24 11:02:04 +02:00
add_executable(LearnGtk4 main.cpp
hello_world.cpp
hello_world.hpp
2024-10-29 17:44:21 +01:00
app_win_2_back.cpp
app_win_2_back.hpp
)
2024-10-24 11:02:04 +02:00
2024-10-29 22:50:13 +01:00
set_target_properties(LearnGtk4 assimp spdlog_header_only PROPERTIES
2024-10-24 11:14:17 +02:00
CXX_STANDARD 17
2024-10-24 11:02:04 +02:00
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
INTERPROCEDURAL_OPTIMIZATION ON
)
target_compile_definitions(LearnGtk4 PUBLIC $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
2024-10-24 11:14:17 +02:00
target_compile_definitions(assimp PUBLIC $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
target_compile_options(LearnGtk4 PUBLIC ${COMPILE_FLAGS})
2024-10-24 11:02:04 +02:00
target_link_options(LearnGtk4 PUBLIC ${LINKER_OPTIONS})
2024-10-29 22:50:13 +01:00
target_link_libraries(LearnGtk4 PkgConfig::GTKMM4 assimp spdlog_header_only)