diff --git a/CMakeLists.txt b/CMakeLists.txt index 012512ae..31af15c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,15 +67,20 @@ target_include_directories( date INTERFACE # adding header sources just helps IDEs target_sources( date INTERFACE $$/date/date.h - # the rest of these are not currently part of the public interface of the library: - $ - $ - $ - $ ) + +add_library(extra INTERFACE) +add_library(date::extra ALIAS extra) +target_sources(extra INTERFACE + $$/date/solar_hijri.h + $$/date/islamic.h + $$/date/julian.h +) + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.15) # public headers will get installed: - set_target_properties( date PROPERTIES PUBLIC_HEADER include/date/date.h ) + set_target_properties( date PROPERTIES PUBLIC_HEADER include/date/date.h) + set_target_properties( extra PROPERTIES PUBLIC_HEADER "include/date/islamic.h;include/date/solar_hijri.h;include/date/julian.h") endif () # These used to be set with generator expressions, @@ -97,6 +102,24 @@ if ( DISABLE_STRING_VIEW ) target_compile_definitions( date INTERFACE HAS_STRING_VIEW=0 -DHAS_DEDUCTION_GUIDES=0 ) endif() +#[===================================================================[ + iso_week (header only) library +#]===================================================================] +add_library( iso_week INTERFACE ) +add_library( date::iso_week ALIAS iso_week ) +target_include_directories( iso_week INTERFACE + $ + $ ) +target_sources( iso_week INTERFACE + $$/date/iso_week.h + ) +# public headers will get installed: +set_target_properties( iso_week PROPERTIES PUBLIC_HEADER include/date/iso_week.h ) +target_compile_definitions( iso_week INTERFACE + #To workaround libstdc++ issue https://github.com/HowardHinnant/date/issues/388 + ONLY_C_LOCALE=$,1,0> + $<$:HAS_STRING_VIEW=0> ) + #[===================================================================[ tz (compiled) library #]===================================================================] @@ -108,6 +131,7 @@ if( BUILD_TZ_LIB ) PRIVATE include/date/tz_private.h src/tz.cpp ) + if ( IOS ) target_sources( date-tz PUBLIC @@ -147,10 +171,10 @@ if( BUILD_TZ_LIB ) PUBLIC_HEADER "${TZ_HEADERS}" VERSION "${PROJECT_VERSION}" SOVERSION "${ABI_VERSION}" ) - if( NOT MSVC ) - find_package( Threads ) - target_link_libraries( date-tz PUBLIC Threads::Threads ) - endif( ) + + find_package( Threads ) + target_link_libraries( date-tz PUBLIC Threads::Threads ) + if( NOT USE_SYSTEM_TZ_DB AND NOT MANUAL_TZ_DB ) find_package( CURL REQUIRED ) target_include_directories( date-tz SYSTEM PRIVATE ${CURL_INCLUDE_DIRS} ) @@ -169,13 +193,30 @@ write_basic_package_version_file( "${version_config}" COMPATIBILITY SameMajorVersion ) install( TARGETS date - EXPORT dateConfig + EXPORT dateTargets PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/date ) export( TARGETS date NAMESPACE date:: FILE dateTargets.cmake ) + +install( TARGETS extra + EXPORT dateTargets + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/date) +export(TARGETS extra NAMESPACE date:: APPEND FILE dateTargets.cmake) + +install( TARGETS iso_week + EXPORT dateTargets + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/date ) +export( TARGETS iso_week NAMESPACE date:: APPEND FILE dateTargets.cmake ) + + if (CMAKE_VERSION VERSION_LESS 3.15) install( FILES include/date/date.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/date ) + + install( + FILES include/date/islamic.h include/date/solar_hijri.h include/date/julian.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/date ) + endif () if( BUILD_TZ_LIB ) @@ -185,6 +226,7 @@ if( BUILD_TZ_LIB ) 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( ) @@ -193,13 +235,17 @@ if( WIN32 AND NOT CYGWIN) else( ) set( CONFIG_LOC "${CMAKE_INSTALL_LIBDIR}/cmake/date" ) endif( ) -install( EXPORT dateConfig + +install( EXPORT dateTargets FILE dateTargets.cmake NAMESPACE date:: DESTINATION ${CONFIG_LOC} ) -install ( - FILES cmake/dateConfig.cmake "${version_config}" - DESTINATION ${CONFIG_LOC}) + +configure_file(cmake/dateConfig.cmake.in dateConfig.cmake @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dateConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/dateConfigVersion.cmake" + DESTINATION ${CONFIG_LOC} + ) #[===================================================================[ testing diff --git a/cmake/dateConfig.cmake.in b/cmake/dateConfig.cmake.in new file mode 100644 index 00000000..46643580 --- /dev/null +++ b/cmake/dateConfig.cmake.in @@ -0,0 +1,13 @@ +include(CMakeFindDependencyMacro) + +set(USE_SYSTEM_TZ_DB @USE_SYSTEM_TZ_DB@) +set(BUILD_TZ_LIB @BUILD_TZ_LIB@) + +find_dependency( Threads REQUIRED ) + +if( NOT USE_SYSTEM_TZ_DB ) + find_dependency( CURL REQUIRED ) +endif( ) + +include("${CMAKE_CURRENT_LIST_DIR}/dateTargets.cmake") + diff --git a/include/date/iso_week.h b/include/date/iso_week.h index 4a0a4a9b..8b2d8618 100644 --- a/include/date/iso_week.h +++ b/include/date/iso_week.h @@ -422,7 +422,7 @@ inline unsigned char weekday::to_iso_encoding(unsigned char z) NOEXCEPT { - return z != 0 ? z : (unsigned char)7; + return z != 0 ? z : static_cast(7); } CONSTCD11 @@ -451,7 +451,7 @@ weekday::weekday(unsigned wd) NOEXCEPT CONSTCD11 inline weekday::weekday(date::weekday wd) NOEXCEPT - : wd_(wd.iso_encoding()) + : wd_(static_cast(wd.iso_encoding())) {} CONSTCD11