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