New-Cli-Installer/CMakeLists.txt

162 lines
4.1 KiB
CMake
Raw Normal View History

2021-11-26 02:34:58 +08:00
cmake_minimum_required(VERSION 3.15)
2021-11-25 22:00:14 +08:00
2021-11-26 02:34:58 +08:00
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2021-11-25 22:00:14 +08:00
2021-11-26 02:34:58 +08:00
##
## PROJECT
## name and version
##
project(cachyos-installer
2024-07-14 07:00:47 +08:00
VERSION 0.8.0
2021-12-01 12:20:39 +08:00
LANGUAGES CXX)
2021-11-25 22:00:14 +08:00
2021-11-26 02:34:58 +08:00
##
## INCLUDE
##
include(GNUInstallDirs)
include(StandardProjectSettings)
include(CompilerWarnings)
include(EnableCcache)
2021-12-01 20:37:18 +08:00
include(Linker)
include(StaticAnalyzers)
include(Sanitizers)
2022-02-12 08:38:15 +08:00
include(CPM)
2021-11-25 22:00:14 +08:00
2022-02-14 07:22:19 +08:00
#find_package(PkgConfig REQUIRED)
#pkg_check_modules(
# GLIBMM
# REQUIRED
# IMPORTED_TARGET
# glibmm-2.4>=2.56.0)
2022-02-12 08:38:15 +08:00
CPMAddPackage(
NAME ftxui
GITHUB_REPOSITORY vnepogodin/ftxui
2022-01-11 07:18:19 +08:00
GIT_TAG "c++20"
2022-02-12 08:38:15 +08:00
EXCLUDE_FROM_ALL YES
2021-12-01 12:20:39 +08:00
)
2022-02-12 08:38:15 +08:00
CPMAddPackage(
NAME fmt
GITHUB_REPOSITORY fmtlib/fmt
2024-07-04 04:39:31 +08:00
GIT_TAG 11.0.0
2022-02-12 08:38:15 +08:00
EXCLUDE_FROM_ALL YES
2021-12-01 12:20:39 +08:00
)
2023-07-01 03:45:33 +08:00
CPMAddPackage(
NAME tomlplusplus
GITHUB_REPOSITORY marzer/tomlplusplus
2024-04-30 17:05:58 +08:00
GIT_TAG 1f7884e59165e517462f922e7b6de131bd9844f3
2023-07-01 03:45:33 +08:00
EXCLUDE_FROM_ALL YES
)
2022-02-12 08:38:15 +08:00
CPMAddPackage(
NAME spdlog
GITHUB_REPOSITORY gabime/spdlog
2024-07-04 04:39:31 +08:00
GIT_TAG eeb22c13bb65f342434c991641b80ecf4821e9b9
2022-02-12 08:38:15 +08:00
EXCLUDE_FROM_ALL YES
2021-12-21 07:13:13 +08:00
)
2022-02-12 08:38:15 +08:00
CPMAddPackage(
NAME rapidjson
GITHUB_REPOSITORY Tencent/rapidjson
2024-04-30 17:05:58 +08:00
GIT_TAG ab1842a2dae061284c0a62dca1cc6d5e7e37e346
2022-02-12 08:38:15 +08:00
EXCLUDE_FROM_ALL YES
2021-12-01 12:20:39 +08:00
)
2022-02-12 08:38:15 +08:00
CPMAddPackage(
NAME cpr
GITHUB_REPOSITORY libcpr/cpr
GIT_TAG b5a21decc0cf25773fb5d742101da6b72639aa51
2022-02-12 08:38:15 +08:00
EXCLUDE_FROM_ALL YES
2021-12-01 12:20:39 +08:00
)
2022-06-06 04:36:15 +08:00
CPMAddPackage(
NAME range-v3
GITHUB_REPOSITORY ericniebler/range-v3
2024-04-30 17:05:58 +08:00
GIT_TAG 53c40dd628450c977ee1558285ff43e0613fa7a9
2022-06-06 04:36:15 +08:00
EXCLUDE_FROM_ALL YES
)
2022-08-09 08:13:25 +08:00
CPMAddPackage(
NAME ctre
GITHUB_REPOSITORY hanickadot/compile-time-regular-expressions
2024-07-04 04:39:31 +08:00
GIT_TAG v3.9.0
2022-08-09 08:13:25 +08:00
EXCLUDE_FROM_ALL YES
)
CPMAddPackage(
NAME doctest
GITHUB_REPOSITORY doctest/doctest
GIT_TAG v2.4.11
EXCLUDE_FROM_ALL YES
)
2021-11-26 02:34:58 +08:00
##
## CONFIGURATION
##
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=thin -fwhole-program-vtables")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -flto=thin -fwhole-program-vtables")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto -fwhole-program -fuse-linker-plugin")
2021-12-01 12:20:39 +08:00
endif()
2021-11-25 22:00:14 +08:00
2021-11-26 02:34:58 +08:00
# Link this 'library' to set the c++ standard / compile-time options requested
add_library(project_options INTERFACE)
2024-07-13 01:09:01 +08:00
target_compile_features(project_options INTERFACE cxx_std_23)
2021-11-25 22:00:14 +08:00
2021-11-26 02:34:58 +08:00
##
## Target
##
add_executable(${PROJECT_NAME}
2021-12-03 07:10:05 +08:00
src/view.hpp
2021-12-01 20:37:18 +08:00
src/definitions.hpp
src/config.cpp src/config.hpp
src/utils.cpp src/utils.hpp
2023-07-01 03:45:33 +08:00
src/chwd_profiles.cpp src/chwd_profiles.hpp
2022-02-12 08:38:15 +08:00
src/disk.cpp src/disk.hpp
src/drivers.cpp src/drivers.hpp
src/widgets.cpp src/widgets.hpp
2021-12-27 07:04:03 +08:00
src/follow_process_log.hpp src/follow_process_log.cpp
2022-01-09 08:41:43 +08:00
src/crypto.cpp src/crypto.hpp
src/misc.cpp src/misc.hpp
src/simple_tui.cpp src/simple_tui.hpp
2021-12-01 20:37:18 +08:00
src/tui.cpp src/tui.hpp
src/main.cpp
)
2021-11-26 02:34:58 +08:00
# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
add_library(project_warnings INTERFACE)
set_project_warnings(project_warnings)
2021-12-01 20:37:18 +08:00
# Add linker configuration
configure_linker(project_options)
# sanitizer options if supported by compiler
enable_sanitizers(project_options)
2022-08-10 01:06:36 +08:00
# Prepare RapidJSON (RapidJSON is a header-only library)
set(RAPIDJSON_INCLUDE_DIR "${rapidjson_SOURCE_DIR}/include")
2022-08-10 01:50:57 +08:00
# Prepare FTXUI depends
target_link_libraries(screen PUBLIC range-v3::range-v3)
target_link_libraries(dom PUBLIC range-v3::range-v3)
target_link_libraries(component PUBLIC range-v3::range-v3)
2022-08-10 01:50:57 +08:00
include_directories(${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/gucc/include ${RAPIDJSON_INCLUDE_DIR})
add_subdirectory(gucc)
2021-11-26 02:34:58 +08:00
2022-08-08 04:55:17 +08:00
if(COS_INSTALLER_BUILD_TESTS)
add_subdirectory(tests)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE project_warnings project_options spdlog::spdlog fmt::fmt ftxui::screen ftxui::dom ftxui::component ctre::ctre tomlplusplus::tomlplusplus gucc::gucc)
2022-11-19 08:19:55 +08:00
if(NOT ENABLE_DEVENV)
target_link_libraries(${PROJECT_NAME} PRIVATE cpr::cpr)
endif()
2021-11-26 02:34:58 +08:00
option(ENABLE_UNITY "Enable Unity builds of projects" OFF)
2021-12-01 12:20:39 +08:00
if(ENABLE_UNITY)
2021-12-01 20:37:18 +08:00
# Add for any project you want to apply unity builds for
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD ON)
2021-12-01 12:20:39 +08:00
endif()
2021-11-26 02:34:58 +08:00
install(
2021-12-01 20:37:18 +08:00
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
2021-11-26 02:34:58 +08:00
)