diff --git a/cmake/Modules/FindHinnantDate.cmake b/cmake/Modules/FindHinnantDate.cmake index 0d44df51..7ae59c96 100644 --- a/cmake/Modules/FindHinnantDate.cmake +++ b/cmake/Modules/FindHinnantDate.cmake @@ -9,11 +9,14 @@ # # HinnantDate_FOUND - True if the system has the library # HinnantDate_INCLUDE_DIR - The directory which includes the header +# HinnantDate_ROOT_DIR - The base directory of the library # # and the following imported targets:: # # HinnantDate::Date - The target to use date.h # +# You can set HinnantDate_ROOT_DIR as hint to the location of the library. +# # The target will enable the required C++11 standard in your compiler. You can # use any later standard but you have to enable them explicitly. @@ -44,10 +47,16 @@ cmake_minimum_required(VERSION 3.1) +# ensure cache entry +set(HinnantDate_ROOT_DIR "${HinnantDate_ROOT_DIR}" CACHE PATH "Root directory of Howard Hinnant's date library") +set(HinnantDate_NOT_FOUND_MESSAGE "Could NOT find HinnantDate. +Maybe you need to adjust the search paths or HinnantDate_ROOT_DIR.") + find_file(HinnantDate_INCLUDE_FILE date.h - HINTS ${HinnantDate_INCLUDE_DIR} + HINTS ${HinnantDate_ROOT_DIR} ) +mark_as_advanced(HinnantDate_INCLUDE_FILE) if (HinnantDate_INCLUDE_FILE) # Validate that correct file is found @@ -57,11 +66,15 @@ if (HinnantDate_INCLUDE_FILE) ) if("${check_result}" STREQUAL "") - message(STATUS "FindHinnantDate: Rejecting found '${HinnantDate_INCLUDE_FILE}', it seems to be a name twin.") - unset(HinnantDate_INCLUDE_FILE) + string(APPEND HinnantDate_NOT_FOUND_MESSAGE "\nRejecting found '${HinnantDate_INCLUDE_FILE}', it seems to be a name twin.") + unset(HinnantDate_INCLUDE_FILE CACHE) else() # Check succeeded, create target get_filename_component(HinnantDate_INCLUDE_DIR "${HinnantDate_INCLUDE_FILE}" DIRECTORY CACHE) + mark_as_advanced(HinnantDate_INCLUDE_DIR) + set(HinnantDate_ROOT_DIR "${HinnantDate_INCLUDE_DIR}") + unset(HinnantDate_NOT_FOUND_MESSAGE) + if(NOT TARGET HinnantDate::Date) add_library(HinnantDate::Date INTERFACE IMPORTED) set_target_properties(HinnantDate::Date PROPERTIES @@ -78,6 +91,6 @@ endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(HinnantDate - REQUIRED_VARS - HinnantDate_INCLUDE_DIR + REQUIRED_VARS HinnantDate_ROOT_DIR HinnantDate_INCLUDE_DIR + FAIL_MESSAGE ${HinnantDate_NOT_FOUND_MESSAGE} )