mirror of
https://github.com/HowardHinnant/date.git
synced 2024-12-27 08:31:03 +08:00
fix ONLY_C_LOCALE export from cmake (#590)
* fix ONLY_C_LOCALE export from cmake * add some comments * remove all generator expressions for target output * cmake: fewer variables, make it easier to read
This commit is contained in:
parent
6952fb50a6
commit
9537addfc4
@ -76,10 +76,25 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.15)
|
|||||||
# public headers will get installed:
|
# 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 )
|
||||||
endif ()
|
endif ()
|
||||||
target_compile_definitions( date INTERFACE
|
|
||||||
|
# These used to be set with generator expressions,
|
||||||
|
#
|
||||||
|
# ONLY_C_LOCALE=$<IF:$<BOOL:${COMPILE_WITH_C_LOCALE}>,1,0>
|
||||||
|
#
|
||||||
|
# which expand in the output target file to, e.g.
|
||||||
|
#
|
||||||
|
# ONLY_C_LOCALE=$<IF:$<BOOL:FALSE>,1,0>
|
||||||
|
#
|
||||||
|
# This string is then (somtimes?) not correctly interpreted.
|
||||||
|
if ( COMPILE_WITH_C_LOCALE )
|
||||||
# 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>
|
target_compile_definitions( date INTERFACE ONLY_C_LOCALE=1 )
|
||||||
$<$<BOOL:${DISABLE_STRING_VIEW}>:HAS_STRING_VIEW=0> )
|
else()
|
||||||
|
target_compile_definitions( date INTERFACE ONLY_C_LOCALE=0 )
|
||||||
|
endif()
|
||||||
|
if ( DISABLE_STRING_VIEW )
|
||||||
|
target_compile_definitions( date INTERFACE HAS_STRING_VIEW=0 )
|
||||||
|
endif()
|
||||||
|
|
||||||
#[===================================================================[
|
#[===================================================================[
|
||||||
tz (compiled) library
|
tz (compiled) library
|
||||||
@ -89,27 +104,40 @@ if( BUILD_TZ_LIB )
|
|||||||
target_sources( date-tz
|
target_sources( date-tz
|
||||||
PUBLIC
|
PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>$<INSTALL_INTERFACE:include>/date/tz.h
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>$<INSTALL_INTERFACE:include>/date/tz.h
|
||||||
$<$<BOOL:${IOS}>:$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>$<INSTALL_INTERFACE:include>/date/ios.h>
|
|
||||||
PRIVATE
|
PRIVATE
|
||||||
include/date/tz_private.h
|
include/date/tz_private.h
|
||||||
$<$<BOOL:${IOS}>:src/ios.mm>
|
|
||||||
src/tz.cpp )
|
src/tz.cpp )
|
||||||
|
if ( IOS )
|
||||||
|
target_sources( date-tz
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>$<INSTALL_INTERFACE:include>/date/ios.h
|
||||||
|
PRIVATE
|
||||||
|
src/ios.mm )
|
||||||
|
endif()
|
||||||
add_library( date::tz ALIAS date-tz )
|
add_library( date::tz ALIAS date-tz )
|
||||||
target_link_libraries( date-tz PUBLIC date )
|
target_link_libraries( date-tz PUBLIC date )
|
||||||
target_include_directories( date-tz PUBLIC
|
target_include_directories( date-tz PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include> )
|
$<INSTALL_INTERFACE:include> )
|
||||||
target_compile_definitions( date-tz
|
|
||||||
PRIVATE
|
if ( USE_SYSTEM_TZ_DB OR MANUAL_TZ_DB )
|
||||||
AUTO_DOWNLOAD=$<IF:$<OR:$<BOOL:${USE_SYSTEM_TZ_DB}>,$<BOOL:${MANUAL_TZ_DB}>>,0,1>
|
target_compile_definitions( date-tz PRIVATE AUTO_DOWNLOAD=0 HAS_REMOTE_API=0 )
|
||||||
HAS_REMOTE_API=$<IF:$<OR:$<BOOL:${USE_SYSTEM_TZ_DB}>,$<BOOL:${MANUAL_TZ_DB}>>,0,1>
|
else()
|
||||||
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${BUILD_SHARED_LIBS}>>:DATE_BUILD_DLL=1>
|
target_compile_definitions( date-tz PRIVATE AUTO_DOWNLOAD=1 HAS_REMOTE_API=1 )
|
||||||
$<$<BOOL:${USE_TZ_DB_IN_DOT}>:INSTALL=.>
|
endif()
|
||||||
PUBLIC
|
|
||||||
USE_OS_TZDB=$<IF:$<AND:$<BOOL:${USE_SYSTEM_TZ_DB}>,$<NOT:$<BOOL:${WIN32}>>,$<NOT:$<BOOL:${MANUAL_TZ_DB}>>>,1,0>
|
if ( USE_SYSTEM_TZ_DB AND NOT WIN32 AND NOT MANUAL_TZ_DB )
|
||||||
INTERFACE
|
target_compile_definitions( date-tz PRIVATE INSTALL=. PUBLIC USE_OS_TZDB=1 )
|
||||||
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${BUILD_SHARED_LIBS}>>:DATE_USE_DLL=1> )
|
else()
|
||||||
|
target_compile_definitions( date-tz PUBLIC USE_OS_TZDB=0 )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if ( WIN32 AND BUILD_SHARED_LIBS )
|
||||||
|
target_compile_definitions( date-tz PUBLIC DATE_BUILD_DLL=1 )
|
||||||
|
endif()
|
||||||
|
|
||||||
set(TZ_HEADERS include/date/tz.h)
|
set(TZ_HEADERS include/date/tz.h)
|
||||||
|
|
||||||
if( IOS )
|
if( IOS )
|
||||||
list(APPEND TZ_HEADERS include/date/ios.h)
|
list(APPEND TZ_HEADERS include/date/ios.h)
|
||||||
endif( )
|
endif( )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user