google / re2

RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add CMake option to disable install

eesaber opened this issue · comments

For CMake FetchContent use case, it would be great to have an option to allow user to enable/disable install

option(RE2_INSTALL "install Re2" ON)

where default is ON for backward compatibility.

if(RE2_INSTALL)
  install(TARGETS re2
        EXPORT re2Targets
        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  #...
endif()

Although I see that, for example, Abseil provides ABSL_ENABLE_INSTALL for this, https://stackoverflow.com/a/65529161 says that add_subdirectory(… EXCLUDE_FROM_ALL) suffices.

Thanks for the solution.

https://cmake.org/cmake/help/latest/module/FetchContent.html#command:fetchcontent_populate
Note
Where possible, prefer to use FetchContent_MakeAvailable() instead of implementing population manually with this command.

But, the CMake Documentation recommended to use FetchContent_MakeAvailable() where possible.

If you would be open to add CMake install option, I am willing to send PR to fix this

It seems to me like something that FetchContent_MakeAvailable() should support, not something that each project should have to work around with yet another option plus the logic to install or not, so please file an issue against CMake.