melawy-welcome/CMakeLists.txt

101 lines
2.3 KiB
CMake
Raw Normal View History

2021-09-17 01:20:32 +05:00
cmake_minimum_required(VERSION 3.14)
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)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
message(STATUS "BUILD: ${CMAKE_BUILD_TYPE}")
##
## INCLUDE
##
2021-09-22 04:44:34 +05:00
include(GNUInstallDirs)
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)
pkg_check_modules(GTK3 REQUIRED gtkmm-3.0)
2021-09-17 01:20:32 +05:00
FetchContent_Declare(fmt
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
2021-09-18 02:55:33 +05:00
GIT_TAG "2742611cad4aee6b1a5638bd1ebf132908f4a3d9"
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_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
2021-09-16 03:07:24 +05:00
if(UNIX AND CMAKE_GENERATOR STREQUAL "Ninja")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "-fcolor-diagnostics ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-fcolor-diagnostics ${CMAKE_C_FLAGS}")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "-fdiagnostics-color ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-fdiagnostics-color ${CMAKE_C_FLAGS}")
endif()
endif()
2021-09-18 02:55:33 +05:00
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fwhole-program")
endif()
add_library(project_warnings INTERFACE)
set_project_warnings(project_warnings)
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
)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
include_directories(${CMAKE_SOURCE_DIR}/src ${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS_OTHER})
2021-09-17 01:20:32 +05:00
target_link_libraries(${PROJECT_NAME} ${GTK3_LIBRARIES} fmt::fmt)
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}
)