ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.06k stars 437 forks source link

Why is the CMakeLists.txt installing the ranges library? #1689

Closed theShmoo closed 2 years ago

theShmoo commented 2 years ago

I am using CMake Fetch to include the ranges library into my project. As it is header only I don't need to install it. But it is installed automatically as install is called in the root CMakeLists.txt

Thanks!

theShmoo commented 2 years ago

Fixed the issue by adding EXCLUDE_FROM_ALL in my fetch:

message(STATUS "Fetch range")

FetchContent_Declare(
  range-v3
  URL https://github.com/ericniebler/range-v3/archive/refs/tags/0.11.0.tar.gz
)

FetchContent_GetProperties(range-v3)
if (NOT range-v3_POPULATED)
  FetchContent_Populate(range-v3)
  add_subdirectory(${range-v3_SOURCE_DIR} ${range-v3_BINARY_DIR} EXCLUDE_FROM_ALL)
  target_include_directories(range-v3 SYSTEM INTERFACE $<BUILD_INTERFACE:${range-v3_SOURCE_DIR}/include>)
endif ()
starball5 commented 1 year ago

Note: CMake v3.25 has a new SYSTEM target property and accompanying arguments to FetchContent and add_subdirectory.