diff --git a/cmake/FindGoogleHash.cmake b/cmake/FindGoogleHash.cmake index 767996b41..f6a81a02c 100644 --- a/cmake/FindGoogleHash.cmake +++ b/cmake/FindGoogleHash.cmake @@ -10,7 +10,14 @@ find_path(GOOGLEHASH_INCLUDES ${INCLUDE_INSTALL_DIR} ) +if(GOOGLEHASH_INCLUDES) + # let's make sure it compiles with the current compiler + file(WRITE ${CMAKE_BINARY_DIR}/googlehash_test.cpp + "#include \n#include \nint main(int argc, char** argv) { google::dense_hash_map a; google::sparse_hash_map b; return 0;}\n") + try_compile(GOOGLEHASH_COMPILE ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/googlehash_test.cpp OUTPUT_VARIABLE GOOGLEHASH_COMPILE_RESULT) +endif(GOOGLEHASH_INCLUDES) + include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GOOGLEHASH DEFAULT_MSG GOOGLEHASH_INCLUDES) +find_package_handle_standard_args(GOOGLEHASH DEFAULT_MSG GOOGLEHASH_INCLUDES GOOGLEHASH_COMPILE) mark_as_advanced(GOOGLEHASH_INCLUDES)