melawy-welcome/CMakeLists.txt

95 lines
2.2 KiB
CMake
Raw Normal View History

2021-10-02 04:09:04 +05:00
cmake_minimum_required(VERSION 3.15)
2021-09-16 03:07:24 +05:00
2021-09-18 02:55:33 +05:00
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2021-09-16 03:07:24 +05:00
##
## PROJECT
## name and version
##
project(cachyos-hello CXX)
##
## INCLUDE
##
2021-09-22 04:44:34 +05:00
include(GNUInstallDirs)
2021-10-02 04:09:04 +05:00
include(StandardProjectSettings)
2021-09-18 02:55:33 +05:00
include(CompilerWarnings)
include(EnableCcache)
include(ClangTidy)
2021-09-17 01:20:32 +05:00
include(FetchContent)
2021-09-16 03:07:24 +05:00
find_package(PkgConfig REQUIRED)
2021-10-02 04:09:04 +05:00
pkg_check_modules(
GTKMM
REQUIRED
IMPORTED_TARGET
gtkmm-3.0)
2021-09-16 03:07:24 +05:00
2021-09-17 01:20:32 +05:00
FetchContent_Declare(fmt
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
2021-10-23 20:48:16 +05:00
GIT_TAG "3b6e409cd8573f63e4acad7717d9082bd898ec87"
2021-09-17 01:20:32 +05:00
)
FetchContent_MakeAvailable(fmt)
2021-09-16 03:07:24 +05:00
##
## CONFIGURATION
##
2021-09-18 02:55:33 +05:00
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fwhole-program")
endif()
2021-10-02 04:09:04 +05:00
# Link this 'library' to set the c++ standard / compile-time options requested
add_library(project_options INTERFACE)
target_compile_features(project_options INTERFACE cxx_std_17)
2021-09-16 03:07:24 +05:00
##
## Target
##
add_executable(${PROJECT_NAME}
2021-09-18 02:55:33 +05:00
src/hello.cpp src/hello.hpp
src/main.cpp
2021-09-16 03:07:24 +05:00
)
2021-10-02 04:09:04 +05:00
# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
add_library(project_warnings INTERFACE)
set_project_warnings(project_warnings)
2021-09-16 03:07:24 +05:00
include_directories(${CMAKE_SOURCE_DIR}/src ${GTK3_INCLUDE_DIRS})
2021-10-02 04:09:04 +05:00
target_link_libraries(${PROJECT_NAME} PRIVATE project_warnings project_options PkgConfig::GTKMM fmt::fmt)
option(ENABLE_UNITY "Enable Unity builds of projects" OFF)
if(ENABLE_UNITY)
# Add for any project you want to apply unity builds for
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD ON)
endif()
2021-09-22 04:44:34 +05:00
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
FILES ${CMAKE_SOURCE_DIR}/cachyos-hello.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/data
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/ui
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
)
# uninstall
add_custom_target(uninstall
COMMAND cat ${PROJECT_BINARY_DIR}/install_manifest.txt | xargs rm
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)