Skip to content

Commit

Permalink
CMake: changes after review from @Sydius
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarcasm committed Nov 7, 2017
1 parent 793f632 commit 4d6cb4a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/FindGMock.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4d6cb4a

Please sign in to comment.