Started adding test building

This commit is contained in:
Darrell Wright 2017-11-24 23:07:39 -05:00 committed by Howard Hinnant
parent 9c39772731
commit 9c67d94f2f

View File

@ -2,20 +2,22 @@ cmake_minimum_required( VERSION 2.8.12 )
project( date_prj ) project( date_prj )
#add_definitions( -DUSE_AUTOLOAD=1 ) find_package( Threads REQUIRED )
#add_definitions( -DHAS_REMOTE_API=1 )
#add_definitions( -DUSE_OS_TZDB=0 )
#add_definitions( -DINSTALL=. )
option( USE_SYSTEM_TZ_DB "Use the operating system's timezone database" OFF ) 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 )
find_package( Threads REQUIRED ) option( BUILD_TESTS "Build Tests" OFF )
option( RUN_TESTS "Build Tests" OFF )
if( USE_SYSTEM_TZ_DB ) if( USE_SYSTEM_TZ_DB )
add_definitions( -DUSE_AUTOLOAD=0 ) add_definitions( -DUSE_AUTOLOAD=0 )
add_definitions( -DHAS_REMOTE_API=0 ) add_definitions( -DHAS_REMOTE_API=0 )
add_definitions( -DUSE_OS_TZDB=1 ) add_definitions( -DUSE_OS_TZDB=1 )
else( ) else( )
add_definitions( -DUSE_AUTOLOAD=1 )
add_definitions( -DHAS_REMOTE_API=1 )
add_definitions( -DUSE_OS_TZDB=0 )
find_package( CURL REQUIRED ) find_package( CURL REQUIRED )
find_package( OpenSSL REQUIRED ) find_package( OpenSSL REQUIRED )
include_directories( SYSTEM ${OPENSSL_INCLUDE_DIR} ) include_directories( SYSTEM ${OPENSSL_INCLUDE_DIR} )
@ -23,6 +25,14 @@ else( )
set( OPTIONAL_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ) set( OPTIONAL_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} )
endif( ) endif( )
if( USE_TZ_DB_IN_DOT )
add_definitions( -DINSTALL=. )
endif( )
if( RUN_TESTS )
set( BUILD_TESTS ON )
endif( )
set( HEADER_FOLDER "include" ) set( HEADER_FOLDER "include" )
set( SOURCE_FOLDER "src" ) set( SOURCE_FOLDER "src" )
set( TEST_FOLDER "test" ) set( TEST_FOLDER "test" )
@ -45,6 +55,13 @@ add_library( tz SHARED ${HEADER_FILES} ${SOURCE_FOLDER}/tz.cpp )
set_property(TARGET tz PROPERTY CXX_STANDARD 14) set_property(TARGET tz PROPERTY CXX_STANDARD 14)
target_link_libraries( tz ${CMAKE_THREAD_LIBS_INIT} ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) target_link_libraries( tz ${CMAKE_THREAD_LIBS_INIT} ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
install( TARGETS tz DESTINATION lib ) install( TARGETS tz DESTINATION lib )
install( DIRECTORY ${HEADER_FOLDER}/ DESTINATION include/ ) install( DIRECTORY ${HEADER_FOLDER}/ DESTINATION include/ )
if( BUILD_TESTS )
file( GLOB_RECURSE TEST_FILES ${TEST_FOLDER} *.cpp )
foreach( CUR_TEST ${TEST_FILES} )
MESSAGE(STATUS "Process file: ${CUR_TEST}")
endforeach( CUR_TEST )
endif( )