Skip to content

Commit

Permalink
cmake: Provide deps using FetchContent
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf committed Jan 17, 2024
1 parent 68c46a4 commit b62e3d9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
51 changes: 33 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,38 @@ else()
set(WITH_COVERAGE NO)
endif()

if (NOT TARGET sfl)
FetchContent_Declare(sfl
GIT_REPOSITORY "https://github.com/slavenf/sfl-library.git"
GIT_TAG "master"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(sfl)
endif()

if (NOT TARGET stx)
FetchContent_Declare(stx
GIT_REPOSITORY "https://github.com/Klebert-Engineering/stx.git"
GIT_TAG "main"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(stx)
endif()

find_package(Bitsery REQUIRED)
FetchContent_Declare(sfl
GIT_REPOSITORY "https://github.com/slavenf/sfl-library.git"
GIT_TAG "master"
GIT_SHALLOW ON
FIND_PACKAGE_ARGS)
FetchContent_MakeAvailable(sfl)

FetchContent_Declare(stx
GIT_REPOSITORY "https://github.com/Klebert-Engineering/stx.git"
GIT_TAG "main"
GIT_SHALLOW ON
FIND_PACKAGE_ARGS)

FetchContent_Declare(Bitsery
GIT_REPOSITORY "https://github.com/fraillt/bitsery.git"
GIT_TAG "v5.2.3"
GIT_SHALLOW ON
FIND_PACKAGE_ARGS)

FetchContent_Declare(nlohmann_json
GIT_REPOSITORY "https://github.com/nlohmann/json.git"
GIT_TAG "v3.11.2"
GIT_SHALLOW ON
FIND_PACKAGE_ARGS)

FetchContent_Declare(Catch2
GIT_REPOSITORY "https://github.com/catchorg/Catch2.git"
GIT_TAG "v3.5.2"
GIT_SHALLOW ON
FIND_PACKAGE_ARGS)

FetchContent_MakeAvailable(sfl stx Bitsery)

if (NOT DEFINED SIMFIL_WITH_MODEL_JSON)
set(SIMFIL_WITH_MODEL_JSON YES)
Expand Down Expand Up @@ -117,7 +132,7 @@ if (MSVC)
endif()

if (SIMFIL_WITH_MODEL_JSON)
find_package(nlohmann_json REQUIRED)
FetchContent_MakeAvailable(nlohmann_json)

target_compile_definitions(simfil
PUBLIC
Expand Down
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
project(test.simfil)

set(CMAKE_CXX_STANDARD 17) # Required for catch2
find_package(Catch2 REQUIRED)

FetchContent_MakeAvailable(Catch2)

add_executable(test.simfil
token.cpp
Expand Down

0 comments on commit b62e3d9

Please sign in to comment.