From 4952fd3d4896f9ca4e5bafb611eba1dee59b6d34 Mon Sep 17 00:00:00 2001 From: Lars Melchior Date: Thu, 23 May 2019 12:25:00 +0200 Subject: [PATCH] Update range v3 (#56) * update range-v3 example as the projects CMakeLists messes up the configuration * add comment * add range-v3 snipplet back --- README.md | 31 ++++++++++++++++++------------- examples/range-v3/CMakeLists.txt | 8 +++++++- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b48bbd4..c8ac816 100644 --- a/README.md +++ b/README.md @@ -123,18 +123,6 @@ CPMAddPackage( See [here](https://github.com/TheLartians/CPM/blob/master/examples/doctest/CMakeLists.txt) for doctest example. Note that we can shorten Github and Gitlab URLs by using `GITHUB_REPOSITORY` or `GITLAB_REPOSITORY`, respectively. -### [Range-v3](https://github.com/ericniebler/range-v3) - -For very large repositories it is usually best to add the release archive. - -```cmake -CPMAddPackage( - NAME range-v3 - URL https://github.com/ericniebler/range-v3/archive/0.5.0.zip - VERSION 0.5.0 -) -``` - ### [google/benchmark](https://github.com/google/benchmark.git) Has a CMakeLists.txt that supports `add_subdirectory`, but needs some configuring to work without external dependencies. @@ -166,13 +154,30 @@ CPMAddPackage( ) if (nlohmann_json_ADDED) - add_library(nlohmann_json INTERFACE) + add_library(nlohmann_json INTERFACE IMPORTED) target_include_directories(nlohmann_json INTERFACE ${nlohmann_json_SOURCE_DIR}) endif() ``` Note the check for `nlohmann_json_ADDED`, before creating the target. This ensures that the target hasn't been added before by another dependency. +### [Range-v3](https://github.com/ericniebler/range-v3) + +```Cmake +CPMAddPackage( + NAME range-v3 + URL https://github.com/ericniebler/range-v3/archive/0.5.0.zip + VERSION 0.5.0 + # the range-v3 CMakeLists screws with configuration options + DOWNLOAD_ONLY True +) + +if(range-v3_ADDED) + add_library(range-v3 INTERFACE IMPORTED) + target_include_directories(range-v3 INTERFACE "${range-v3_SOURCE_DIR}/include") +endif() +``` + ### [Lua](https://www.lua.org) Lua does not oficially support CMake, so we query the sources and create our own target. diff --git a/examples/range-v3/CMakeLists.txt b/examples/range-v3/CMakeLists.txt index bdb125e..e96b314 100644 --- a/examples/range-v3/CMakeLists.txt +++ b/examples/range-v3/CMakeLists.txt @@ -8,11 +8,17 @@ CPMAddPackage( NAME range-v3 URL https://github.com/ericniebler/range-v3/archive/0.5.0.zip VERSION 0.5.0 + # the range-v3 CMakeLists screws with configuration options + DOWNLOAD_ONLY True ) +if(range-v3_ADDED) + add_library(range-v3 INTERFACE IMPORTED) + target_include_directories(range-v3 INTERFACE "${range-v3_SOURCE_DIR}/include") +endif() + # ---- Executable ---- add_executable(CPMRangev3Example "main.cpp") set_target_properties(CPMRangev3Example PROPERTIES CXX_STANDARD 17) target_link_libraries(CPMRangev3Example range-v3) -