build: introduce ENABLE_DATE_INSTALL to allow user opt-out of install

When using `date` as a PRIVATE dependency, it is not required to install it. This flag give user using `date` with add_subdirectory the opportunity to disable install target Default behavior is conserved since ENABLE_DATE_INSTALL is ON
This commit is contained in:
Olivier Le Doeuff
2022-09-26 16:35:13 +02:00
committed by Howard Hinnant
parent 3286289bf6
commit 7c151cdb6a

View File

@@ -20,8 +20,6 @@ cmake_minimum_required( VERSION 3.7 )
project( date VERSION 3.0.1 )
set(ABI_VERSION 3) # used as SOVERSION, increment when ABI changes
include( GNUInstallDirs )
get_directory_property( has_parent PARENT_DIRECTORY )
if (POLICY CMP0077)
@@ -40,12 +38,17 @@ option( ENABLE_DATE_TESTING "Enable unit tests" OFF )
option( DISABLE_STRING_VIEW "Disable string view" OFF )
option( COMPILE_WITH_C_LOCALE "define ONLY_C_LOCALE=1" OFF )
option( BUILD_TZ_LIB "build/install of TZ library" OFF )
option( ENABLE_DATE_INSTALL "Enable unit tests" ON )
if( ENABLE_DATE_TESTING AND NOT BUILD_TZ_LIB )
message(WARNING "Testing requested, but BUILD_TZ_LIB not ON - forcing the latter")
set (BUILD_TZ_LIB ON CACHE BOOL "required for testing" FORCE)
endif( )
if( ENABLE_DATE_INSTALL )
include( GNUInstallDirs )
endif( )
function( print_option OPT )
if ( NOT DEFINED PRINT_OPTION_CURR_${OPT} OR ( NOT PRINT_OPTION_CURR_${OPT} STREQUAL ${OPT} ) )
set( PRINT_OPTION_CURR_${OPT} ${${OPT}} CACHE BOOL "" )
@@ -168,6 +171,7 @@ endif( )
#[===================================================================[
installation
#]===================================================================]
if( ENABLE_DATE_INSTALL )
set( version_config "${CMAKE_CURRENT_BINARY_DIR}/dateConfigVersion.cmake" )
include( CMakePackageConfigHelpers )
@@ -207,6 +211,7 @@ install( EXPORT dateConfig
install (
FILES cmake/dateConfig.cmake "${version_config}"
DESTINATION ${CONFIG_LOC})
endif( )
#[===================================================================[
testing