Skip to content

Commit

Permalink
- Interface library name changed from date to date_interface
Browse files Browse the repository at this point in the history
- Print state of set options
- cleanup on duplicate ${CMAKE_THREAD_LIBS_INIT}
  • Loading branch information
ajneu authored and HowardHinnant committed Dec 26, 2017
1 parent dbd6e6e commit 4476878
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ enable_testing( )

option( USE_SYSTEM_TZ_DB "Use the operating system's timezone database" OFF )
option( USE_TZ_DB_IN_DOT "Save the timezone database in the current folder" OFF )
option( BUILD_STATIC "Build a static version of library" ON )
option( BUILD_TZ_STATIC "Build a static version of library" ON )

function( print_option OPT )
if ( NOT DEFINED CURR_${OPT} OR ( NOT CURR_${OPT} STREQUAL ${OPT} ) )
set( CURR_${OPT} ${${OPT}} CACHE BOOL "" )
message( "# date: ${OPT} ${${OPT}}" )
endif( )
endfunction( )

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 )
Expand Down Expand Up @@ -46,7 +57,7 @@ set( HEADER_FILES
${HEADER_FOLDER}/date/tz_private.h
)

if( BUILD_STATIC )
if( BUILD_TZ_STATIC )
add_library( tz STATIC ${HEADER_FILES} ${SOURCE_FOLDER}/tz.cpp )
else( )
add_library( tz SHARED ${HEADER_FILES} ${SOURCE_FOLDER}/tz.cpp )
Expand All @@ -59,7 +70,7 @@ else( )
endif( )

set_property(TARGET tz PROPERTY CXX_STANDARD ${TZ_CXX_STANDARD})
target_link_libraries( tz ${CMAKE_THREAD_LIBS_INIT} ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
target_link_libraries( tz ${CMAKE_THREAD_LIBS_INIT} ${OPTIONAL_LIBRARIES} )

# add include folders to the library and targets that consume it
target_include_directories(tz PUBLIC
Expand All @@ -71,10 +82,10 @@ target_include_directories(tz PUBLIC
>
)

add_library(date INTERFACE) # an interface (not a library), to enable automatic include_directory (for when just date.h, but not "tz.h and its lib" are needed)
add_library(date_interface INTERFACE) # an interface (not a library), to enable automatic include_directory (for when just date.h, but not "tz.h and its lib" are needed)

# add include folders to the INTERFACE and targets that consume it
target_include_directories(date INTERFACE
target_include_directories(date_interface INTERFACE
$<BUILD_INTERFACE:
${CMAKE_CURRENT_SOURCE_DIR}/${HEADER_FOLDER}
>
Expand Down

0 comments on commit 4476878

Please sign in to comment.