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 useFetchContent_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.