From 9c67d94f2f7ea06b38774ffa5d34252a2ec06424 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 24 Nov 2017 23:07:39 -0500 Subject: [PATCH] Started adding test building --- CMakeList.txt | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/CMakeList.txt b/CMakeList.txt index 878cc88..332e3a3 100644 --- a/CMakeList.txt +++ b/CMakeList.txt @@ -2,20 +2,22 @@ cmake_minimum_required( VERSION 2.8.12 ) project( date_prj ) -#add_definitions( -DUSE_AUTOLOAD=1 ) -#add_definitions( -DHAS_REMOTE_API=1 ) -#add_definitions( -DUSE_OS_TZDB=0 ) -#add_definitions( -DINSTALL=. ) +find_package( Threads REQUIRED ) + option( USE_SYSTEM_TZ_DB "Use the operating system's timezone database" OFF ) - -find_package( Threads REQUIRED ) +option( USE_TZ_DB_IN_DOT "Save the timezone database in the current folder" OFF ) +option( BUILD_TESTS "Build Tests" OFF ) +option( RUN_TESTS "Build Tests" OFF ) if( USE_SYSTEM_TZ_DB ) add_definitions( -DUSE_AUTOLOAD=0 ) add_definitions( -DHAS_REMOTE_API=0 ) add_definitions( -DUSE_OS_TZDB=1 ) else( ) + add_definitions( -DUSE_AUTOLOAD=1 ) + add_definitions( -DHAS_REMOTE_API=1 ) + add_definitions( -DUSE_OS_TZDB=0 ) find_package( CURL REQUIRED ) find_package( OpenSSL REQUIRED ) include_directories( SYSTEM ${OPENSSL_INCLUDE_DIR} ) @@ -23,6 +25,14 @@ else( ) set( OPTIONAL_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} ) endif( ) +if( USE_TZ_DB_IN_DOT ) + add_definitions( -DINSTALL=. ) +endif( ) + +if( RUN_TESTS ) + set( BUILD_TESTS ON ) +endif( ) + set( HEADER_FOLDER "include" ) set( SOURCE_FOLDER "src" ) 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) target_link_libraries( tz ${CMAKE_THREAD_LIBS_INIT} ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) - install( TARGETS tz DESTINATION lib ) 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( ) +