@@ -27,7 +27,8 @@ find_package(TokyoCabinet)
2727```
2828#]=============================================================================]
2929
30- include (CheckLibraryExists)
30+ include (CheckSymbolExists)
31+ include (CMakePushCheckState)
3132include (FeatureSummary)
3233include (FindPackageHandleStandardArgs)
3334
@@ -69,15 +70,16 @@ if(NOT TokyoCabinet_LIBRARY)
6970endif ()
7071
7172# Sanity check.
72- if (TokyoCabinet_LIBRARY)
73- check_library_exists(
74- "${TokyoCabinet_LIBRARY} "
75- tcadbopen
76- ""
77- _tokyocabinet_sanity_check
78- )
73+ if (TokyoCabinet_INCLUDE_DIR AND TokyoCabinet_LIBRARY)
74+ cmake_push_check_state(RESET)
75+ set (CMAKE_REQUIRED_INCLUDES ${TokyoCabinet_INCLUDE_DIR} )
76+ set (CMAKE_REQUIRED_LIBRARIES ${TokyoCabinet_LIBRARY} )
77+ set (CMAKE_REQUIRED_QUIET TRUE )
78+
79+ check_symbol_exists(tcadbopen tcadb.h _TokyoCabinet_SANITY_CHECK)
80+ cmake_pop_check_state()
7981
80- if (NOT _tokyocabinet_sanity_check )
82+ if (NOT _TokyoCabinet_SANITY_CHECK )
8183 string (APPEND _reason "Sanity check failed: tcadbopen not found. " )
8284 endif ()
8385endif ()
@@ -102,7 +104,7 @@ find_package_handle_standard_args(
102104 REQUIRED_VARS
103105 TokyoCabinet_LIBRARY
104106 TokyoCabinet_INCLUDE_DIR
105- _tokyocabinet_sanity_check
107+ _TokyoCabinet_SANITY_CHECK
106108 VERSION_VAR TokyoCabinet_VERSION
107109 HANDLE_VERSION_RANGE
108110 REASON_FAILURE_MESSAGE "${_reason} "
0 commit comments