2024-11-11 16:36:37 +01:00
|
|
|
cmake_minimum_required(VERSION 3.21)
|
2025-06-24 16:08:05 +02:00
|
|
|
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})
|
2024-11-11 16:36:37 +01:00
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
set(SLINT_FEATURE_RENDERER_SKIA ON)
|
|
|
|
set(SLINT_FEATURE_RENDERER_SOFTWARE ON)
|
|
|
|
|
|
|
|
add_library(rei-json
|
|
|
|
src/parse.cpp
|
|
|
|
src/toString.cpp
|
|
|
|
src/Object.cpp
|
|
|
|
src/Array.cpp
|
|
|
|
src/Field.cpp
|
|
|
|
)
|
2025-06-24 16:08:05 +02:00
|
|
|
|
|
|
|
set_target_properties(rei-json PROPERTIES VERSION ${REI_JSON_VERSION})
|
2024-11-11 16:36:37 +01:00
|
|
|
target_include_directories(rei-json PRIVATE "external")
|
|
|
|
target_include_directories(rei-json PRIVATE "include")
|
|
|
|
|
|
|
|
Include(FetchContent)
|
|
|
|
|
2025-06-24 16:08:05 +02:00
|
|
|
find_package(Catch2 3 QUIET)
|
|
|
|
if (NOT Catch2_FOUND)
|
2024-11-11 16:36:37 +01:00
|
|
|
FetchContent_Declare(
|
|
|
|
Catch2
|
2025-06-24 16:08:05 +02:00
|
|
|
EXCLUDE_FROM_ALL
|
2024-11-11 16:36:37 +01:00
|
|
|
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
2024-11-29 10:50:49 +01:00
|
|
|
GIT_TAG v3.7.1 # or a later release
|
2024-11-11 16:36:37 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
FetchContent_MakeAvailable(Catch2)
|
2025-06-24 16:08:05 +02:00
|
|
|
endif()
|
|
|
|
|
2024-11-11 16:36:37 +01:00
|
|
|
|
2025-06-24 16:08:05 +02:00
|
|
|
add_executable(rei-json-tests
|
2024-11-11 16:36:37 +01:00
|
|
|
tests/usage.cpp
|
|
|
|
tests/parsing.cpp
|
|
|
|
tests/stringify.cpp
|
2024-11-29 10:50:49 +01:00
|
|
|
tests/errors.cpp
|
2024-11-11 16:36:37 +01:00
|
|
|
)
|
2025-06-24 16:08:05 +02:00
|
|
|
|
|
|
|
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)
|