Use target_compile_definitions

It's generally preferred to use [`target_compile_definitions`](https://floooh.github.io/2016/01/12/cmake-dependency-juggling.html) over `add_definitions`.
This commit is contained in:
Tommy Nguyen 2018-01-09 20:09:11 -05:00 committed by Howard Hinnant
parent 362cd8f27e
commit 637e5d8007

View File

@ -22,26 +22,6 @@ print_option( USE_SYSTEM_TZ_DB )
print_option( USE_TZ_DB_IN_DOT )
print_option( BUILD_TZ_STATIC )
if( USE_SYSTEM_TZ_DB )
add_definitions( -DUSE_AUTOLOAD=0 )
add_definitions( -DHAS_REMOTE_API=0 )
# cannot set USE_OS_TZDB to 1 on Windows
if( NOT WIN32 )
add_definitions( -DUSE_OS_TZDB=1 )
endif( )
else( )
add_definitions( -DUSE_AUTOLOAD=1 )
add_definitions( -DHAS_REMOTE_API=1 )
add_definitions( -DUSE_OS_TZDB=0 )
find_package( CURL REQUIRED )
include_directories( SYSTEM ${CURL_INCLUDE_DIRS} )
set( OPTIONAL_LIBRARIES ${CURL_LIBRARIES} )
endif( )
if( USE_TZ_DB_IN_DOT )
add_definitions( -DINSTALL=. )
endif( )
set( HEADER_FOLDER "include" )
set( SOURCE_FOLDER "src" )
set( TEST_FOLDER "test" )
@ -64,6 +44,26 @@ else( )
add_library( tz SHARED ${HEADER_FILES} ${SOURCE_FOLDER}/tz.cpp )
endif( )
if( USE_SYSTEM_TZ_DB )
target_compile_definitions( tz PRIVATE -DUSE_AUTOLOAD=0 )
target_compile_definitions( tz PRIVATE -DHAS_REMOTE_API=0 )
# cannot set USE_OS_TZDB to 1 on Windows
if( NOT WIN32 )
target_compile_definitions( tz PRIVATE -DUSE_OS_TZDB=1 )
endif( )
else( )
target_compile_definitions( tz PRIVATE -DUSE_AUTOLOAD=1 )
target_compile_definitions( tz PRIVATE -DHAS_REMOTE_API=1 )
target_compile_definitions( tz PRIVATE -DUSE_OS_TZDB=0 )
find_package( CURL REQUIRED )
include_directories( SYSTEM ${CURL_INCLUDE_DIRS} )
set( OPTIONAL_LIBRARIES ${CURL_LIBRARIES} )
endif( )
if( USE_TZ_DB_IN_DOT )
target_compile_definitions( tz PRIVATE -DINSTALL=. )
endif( )
if( NOT TZ_CXX_STANDARD )
set( TZ_CXX_STANDARD 17 )
endif( )