Files
ucwm/CMakeLists.txt

49 lines
1.5 KiB
CMake
Raw Permalink Normal View History

cmake_minimum_required(VERSION 3.20)
project(ucwm VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# Auto-download CPM into the build directory
set(CPM_DOWNLOAD_VERSION 0.40.0)
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/CPM.cmake")
file(DOWNLOAD
"https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/CPM.cmake"
SHOW_PROGRESS
)
endif()
include("${CMAKE_CURRENT_BINARY_DIR}/CPM.cmake")
CPMAddPackage("gh:nlohmann/json@3.11.3")
CPMAddPackage("gh:gabime/spdlog@1.13.0")
CPMAddPackage(
NAME Catch2
VERSION 3.5.4
GITHUB_REPOSITORY catchorg/Catch2
)
list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/extras")
# Interface library — everything links against this
add_library(ucwm_types INTERFACE)
target_include_directories(ucwm_types INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(ucwm_types INTERFACE nlohmann_json::nlohmann_json spdlog::spdlog)
target_compile_features(ucwm_types INTERFACE cxx_std_20)
# Main executable
add_executable(ucwm src/main.cpp)
target_link_libraries(ucwm PRIVATE ucwm_types)
# Tests
enable_testing()
add_executable(ucwm_tests tests/test_types.cpp)
target_link_libraries(ucwm_tests PRIVATE ucwm_types Catch2::Catch2WithMain)
include(Catch)
catch_discover_tests(ucwm_tests)