From 3933a0122d50c0def18f7bb96b2bf643ca7af1fe Mon Sep 17 00:00:00 2001 From: "carlos.alvaro" Date: Mon, 11 Jun 2018 09:14:17 +0200 Subject: [PATCH] Add option to disable string_view Also add -fPIC flag when compiling the shared version of the library. --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f025a3a..ee39c27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ 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_SHARED_LIBS "Build a shared version of library" OFF ) option( ENABLE_DATE_TESTING "Enable unit tests" ON ) +option( DISABLE_STRING_VIEW "Disable string view" OFF ) function( print_option OPT ) if ( NOT DEFINED PRINT_OPTION_CURR_${OPT} OR ( NOT PRINT_OPTION_CURR_${OPT} STREQUAL ${OPT} ) ) @@ -26,6 +27,7 @@ print_option( USE_SYSTEM_TZ_DB ) print_option( USE_TZ_DB_IN_DOT ) print_option( BUILD_SHARED_LIBS ) print_option( ENABLE_DATE_TESTING ) +print_option( DISABLE_STRING_VIEW ) set( HEADER_FOLDER "include" ) set( SOURCE_FOLDER "src" ) @@ -65,6 +67,15 @@ if( USE_TZ_DB_IN_DOT ) target_compile_definitions( tz PRIVATE -DINSTALL=. ) endif( ) +if( DISABLE_STRING_VIEW ) + target_compile_definitions( tz PRIVATE -DHAS_STRING_VIEW=0 ) +endif( ) + +if( BUILD_SHARED_LIBS ) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fPIC") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIC") +endif( ) + target_link_libraries( tz ${CMAKE_THREAD_LIBS_INIT} ${OPTIONAL_LIBRARIES} ) # add include folders to the library and targets that consume it