I'm upgrading from cmake 3.5.1 and am trying to understand the new FetchContent command. So far I have:
cmake_minimum_required(VERSION 3.14) project (json_test) include(FetchContent) set(JSON_BuildTests OFF) #if I try this I get a warning as it appears to be deprecated FetchContent_Declare( nlohmann_json_fc GIT_REPOSITORY https://github.com/nlohmann/json.git GIT_TAG v3.6.1 GIT_SHALLOW TRUE # CMAKE_ARGS -DJSON_BuildTests=OFF #doesn't work ) FetchContent_MakeAvailable(nlohmann_json_fc) add_executable(main src/main.cpp) target_link_libraries(main nlohmann_json::nlohmann_json) I first tried sending in the JSON_BuildTests=OFF with CMAKE_ARGS in the FetchContent_Declare command but that didn't work. On this post https://cmake.org/pipermail/cmake/2018-July/067804.html it appears this is because only the download portion of FetchContent_Declare is enabled with the intent to not do too much during configure time. How does specifying how the external project is configured fit that rationale? If I execute cmake -DJSON_BuildTests=OFF .. the argument successfully makes it through to the external project. I guess I'm trying to understand why it's ok to specify it on the command line but not permanently in the CMakeLists.txt, particularly if you have many libraries each potentially with their options that need to be configured. Thanks, Jason
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake