Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Allow user to opt out of install #751

Open
OlivierLDff opened this issue Sep 26, 2022 · 2 comments · May be fixed by #752
Open

CMake: Allow user to opt out of install #751

OlivierLDff opened this issue Sep 26, 2022 · 2 comments · May be fixed by #752

Comments

@OlivierLDff
Copy link

Hi, thanks for the great work!

It would be very nice to make this part optional:

date/CMakeLists.txt

Lines 161 to 202 in 22ceabf

#[===================================================================[
installation
#]===================================================================]
set( version_config "${CMAKE_CURRENT_BINARY_DIR}/dateConfigVersion.cmake" )
include( CMakePackageConfigHelpers )
write_basic_package_version_file( "${version_config}"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion )
install( TARGETS date
EXPORT dateConfig
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/date )
export( TARGETS date NAMESPACE date:: FILE dateTargets.cmake )
if (CMAKE_VERSION VERSION_LESS 3.15)
install(
FILES include/date/date.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/date )
endif ()
if( BUILD_TZ_LIB )
install( TARGETS date-tz
EXPORT dateConfig
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/date
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) # This is for Windows
export( TARGETS date-tz NAMESPACE date:: APPEND FILE dateTargets.cmake )
endif( )
if( WIN32 AND NOT CYGWIN)
set( CONFIG_LOC CMake )
else( )
set( CONFIG_LOC "${CMAKE_INSTALL_LIBDIR}/cmake/date" )
endif( )
install( EXPORT dateConfig
FILE dateTargets.cmake
NAMESPACE date::
DESTINATION ${CONFIG_LOC} )
install (
FILES cmake/dateConfig.cmake "${version_config}"
DESTINATION ${CONFIG_LOC})

For example when installing a shared library, using date as a private dependency, we don't want to install date.
A new option should be introduced ENABLE_DATE_INSTALL to match project convention, or DATE_ENABLE_INSTALL to match cmake project conventions.

Would you consider such PR? Make ENABLE_DATE_INSTALL default to ON shouldn't change any behavior, and it would give users using date with add_subdirectory to opt-out of install.

Have a nice day.

@HowardHinnant
Copy link
Owner

I don't personally use or maintain CMake files here, so yes, a PR would be appreciated.

@OlivierLDff
Copy link
Author

Ok, will do.
I will go with ENABLE_DATE_INSTALL so that it match what is already there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants