From 4d96f4cf6aadd3e5d7b0c0f8bb1472644617e1cb Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 16 Jun 2020 20:23:01 +0200 Subject: [PATCH] :wrench: overwork CMake files --- cmake/download_test_data.cmake | 3 +-- test/cmake_fetch_content/project/CMakeLists.txt | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmake/download_test_data.cmake b/cmake/download_test_data.cmake index 7d73c6d35d..7d7ff1784d 100644 --- a/cmake/download_test_data.cmake +++ b/cmake/download_test_data.cmake @@ -1,5 +1,3 @@ -find_package(Git) - set(JSON_TEST_DATA_URL https://github.com/nlohmann/json_test_data) set(JSON_TEST_DATA_VERSION 2.0.0) @@ -9,6 +7,7 @@ if(JSON_TestDataDirectory) add_custom_target(download_test_data) file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${JSON_TestDataDirectory}\"\n") else() + find_package(Git) # target to download test data add_custom_target(download_test_data COMMAND test -d json_test_data || ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL}.git --quiet --depth 1 diff --git a/test/cmake_fetch_content/project/CMakeLists.txt b/test/cmake_fetch_content/project/CMakeLists.txt index 742a112b1a..fd8fbdd5f3 100644 --- a/test/cmake_fetch_content/project/CMakeLists.txt +++ b/test/cmake_fetch_content/project/CMakeLists.txt @@ -4,9 +4,8 @@ project(DummyImport CXX) include(FetchContent) -FetchContent_Declare(json - GIT_REPOSITORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. - GIT_TAG HEAD) +get_filename_component(GIT_REPOSITORY_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. ABSOLUTE) +FetchContent_Declare(json GIT_REPOSITORY ${GIT_REPOSITORY_DIRECTORY} GIT_TAG HEAD) FetchContent_GetProperties(json) if(NOT json_POPULATED)