mirror of
https://codeberg.org/vyn/rei-json.git
synced 2025-07-02 01:43:19 +00:00
Add target guards to prevent adding different version of the lib
This commit is contained in:
parent
2639dba60a
commit
f057dc28b8
1 changed files with 22 additions and 5 deletions
|
@ -1,5 +1,13 @@
|
|||
cmake_minimum_required(VERSION 3.21)
|
||||
project(rei-json LANGUAGES CXX)
|
||||
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)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
@ -13,25 +21,34 @@ add_library(rei-json
|
|||
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(tests
|
||||
|
||||
add_executable(rei-json-tests
|
||||
tests/usage.cpp
|
||||
tests/parsing.cpp
|
||||
tests/stringify.cpp
|
||||
tests/errors.cpp
|
||||
)
|
||||
target_include_directories(tests PRIVATE "include")
|
||||
target_link_libraries(tests PRIVATE rei-json)
|
||||
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
|
||||
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue