diff --git a/CMakeLists.txt b/CMakeLists.txt index 33bae2ed..32015a98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,16 +7,11 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) -include(CheckCXXCompilerFlag) +include(CheckCXXSymbolExists) include(CTest) -include(GNUInstallDirs) option(BUILD_EXAMPLES "Whether or not to build examples" ON) -if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - add_compile_options(-Wall) -endif() - function(cctz_target_set_cxx_standard target) set(cctz_cxx_standard 11) # CXX_STANDARD target property is only supported since CMake >= 3.1 @@ -53,13 +48,20 @@ add_library(cctz cctz_target_set_cxx_standard(cctz) add_library(cctz::cctz ALIAS cctz) -target_include_directories(cctz PUBLIC PUBLIC include) +target_include_directories(cctz PUBLIC include) -# not (yet) supported on Windows because of getopt.h -if (NOT MSVC) +# the getopt_long function used by time_tool is not available on all platforms, +# for example this is not available by default on Windows +if (NOT DEFINED HAVE_GETOPT_LONG) + set(show_time_tool_msg 1) +endif() +check_cxx_symbol_exists(getopt_long getopt.h HAVE_GETOPT_LONG) +if (HAVE_GETOPT_LONG) add_executable(time_tool src/time_tool.cc) cctz_target_set_cxx_standard(time_tool) target_link_libraries(time_tool cctz::cctz) +elseif(show_time_tool_msg) + message(STATUS "Disable time_tool as getopt_long is not available") endif() if (BUILD_EXAMPLES) diff --git a/cmake/modules/FindGMock.cmake b/cmake/modules/FindGMock.cmake index 5b57f9e8..b6f50341 100644 --- a/cmake/modules/FindGMock.cmake +++ b/cmake/modules/FindGMock.cmake @@ -17,7 +17,7 @@ find_library(GMOCK_MAIN_LIBRARY gmock_main) find_package(GTest) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GMOCK DEFAULT_MSG +find_package_handle_standard_args(GMock DEFAULT_MSG GTEST_FOUND GMOCK_INCLUDE_DIR GMOCK_LIBRARY GMOCK_MAIN_LIBRARY) mark_as_advanced(GMOCK_INCLUDE_DIR GMOCK_LIBRARY GMOCK_MAIN_LIBRARY)