Fix cmake install for 3.14 or earlier (3.7 min) (#522)

* Fix cmake install for 3.14 or earlier (3.7 min)

Fixes: #504, #505

* Add find_dependency to config file

FIXES: #514
This commit is contained in:
Michael Ellery 2019-12-29 11:51:04 -08:00 committed by Howard Hinnant
parent 48433b9892
commit fc4cf092f9
2 changed files with 27 additions and 7 deletions

View File

@ -15,9 +15,7 @@
#]===================================================================] #]===================================================================]
cmake_minimum_required( VERSION 3.1.0 ) cmake_minimum_required( VERSION 3.7 )
cmake_policy( VERSION 3.14 )
project( date VERSION 2.4.1 ) project( date VERSION 2.4.1 )
@ -71,8 +69,10 @@ target_sources( date INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/date/iso_week.h> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/date/iso_week.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/date/julian.h> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/date/julian.h>
) )
# public headers will get installed: if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.15)
set_target_properties( date PROPERTIES PUBLIC_HEADER include/date/date.h ) # public headers will get installed:
set_target_properties( date PROPERTIES PUBLIC_HEADER include/date/date.h )
endif ()
target_compile_definitions( date INTERFACE target_compile_definitions( date INTERFACE
#To workaround libstdc++ issue https://github.com/HowardHinnant/date/issues/388 #To workaround libstdc++ issue https://github.com/HowardHinnant/date/issues/388
ONLY_C_LOCALE=$<IF:$<BOOL:${COMPILE_WITH_C_LOCALE}>,1,0> ONLY_C_LOCALE=$<IF:$<BOOL:${COMPILE_WITH_C_LOCALE}>,1,0>
@ -138,7 +138,12 @@ write_basic_package_version_file( "${version_config}"
install( TARGETS date install( TARGETS date
EXPORT dateConfig EXPORT dateConfig
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/date ) PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/date )
export( TARGETS date NAMESPACE date:: FILE dateConfig.cmake ) 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 ) if( BUILD_TZ_LIB )
install( TARGETS tz install( TARGETS tz
@ -147,7 +152,7 @@ if( BUILD_TZ_LIB )
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) # This is for Windows RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) # This is for Windows
export( TARGETS tz NAMESPACE date:: APPEND FILE dateConfig.cmake ) export( TARGETS tz NAMESPACE date:: APPEND FILE dateTargets.cmake )
endif( ) endif( )
if( WIN32 AND NOT CYGWIN) if( WIN32 AND NOT CYGWIN)
@ -156,8 +161,12 @@ else( )
set( CONFIG_LOC "${CMAKE_INSTALL_LIBDIR}/cmake/date" ) set( CONFIG_LOC "${CMAKE_INSTALL_LIBDIR}/cmake/date" )
endif( ) endif( )
install( EXPORT dateConfig install( EXPORT dateConfig
FILE dateTargets.cmake
NAMESPACE date:: NAMESPACE date::
DESTINATION ${CONFIG_LOC} ) DESTINATION ${CONFIG_LOC} )
install (
FILES cmake/dateConfig.cmake "${version_config}"
DESTINATION ${CONFIG_LOC})
#[===================================================================[ #[===================================================================[
testing testing

11
cmake/dateConfig.cmake Normal file
View File

@ -0,0 +1,11 @@
include( CMakeFindDependencyMacro )
include( "${CMAKE_CURRENT_LIST_DIR}/dateTargets.cmake" )
if( NOT MSVC AND TARGET date::tz )
find_dependency( Threads REQUIRED)
get_target_property( _tzill date::tz INTERFACE_LINK_LIBRARIES )
if( _tzill AND "${_tzill}" MATCHES "libcurl" )
find_dependency( CURL )
endif( )
endif( )