cmake_minimum_required(VERSION 3.21) set(REI_JSON_VERSION 1.3.0) if (TARGET rei-json) get_target_property(rei-json-version rei-json VERSION) if (NOT ${rei-json-version} VERSION_EQUAL ${REI_JSON_VERSION}) message(FATAL_ERROR "You can't include two different versions of rei-json " ${REI_JSON_VERSION} " vs " ${rei-json-version}) endif() return() endif () project(rei-json LANGUAGES CXX VERSION ${REI_JSON_VERSION}) set(CMAKE_CXX_STANDARD 23) add_library(rei-json src/parse.cpp src/toString.cpp src/Object.cpp src/Array.cpp src/Field.cpp ) set_target_properties(rei-json PROPERTIES VERSION ${REI_JSON_VERSION}) target_include_directories(rei-json PRIVATE "external") target_include_directories(rei-json PRIVATE "include") Include(FetchContent) find_package(Catch2 3 QUIET) if (NOT Catch2_FOUND) FetchContent_Declare( Catch2 EXCLUDE_FROM_ALL GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v3.7.1 # or a later release ) FetchContent_MakeAvailable(Catch2) endif() add_executable(rei-json-tests tests/usage.cpp tests/parsing.cpp tests/stringify.cpp tests/errors.cpp ) set_target_properties(rei-json-tests PROPERTIES EXCLUDE_FROM_ALL True) target_include_directories(rei-json-tests PRIVATE "include") target_link_libraries(rei-json-tests PRIVATE rei-json) target_link_libraries(rei-json-tests PRIVATE Catch2::Catch2WithMain)