FindValgrind.cmake (913B)
1 if(CMAKE_HOST_APPLE) 2 find_program(BREW_COMMAND brew) 3 execute_process( 4 COMMAND ${BREW_COMMAND} --prefix valgrind 5 OUTPUT_VARIABLE valgrind_brew_prefix 6 ERROR_QUIET 7 OUTPUT_STRIP_TRAILING_WHITESPACE 8 ) 9 endif() 10 11 set(hints_paths) 12 if(valgrind_brew_prefix) 13 set(hints_paths ${valgrind_brew_prefix}/include) 14 endif() 15 16 find_path(Valgrind_INCLUDE_DIR 17 NAMES valgrind/memcheck.h 18 HINTS ${hints_paths} 19 ) 20 21 if(Valgrind_INCLUDE_DIR) 22 include(CheckCSourceCompiles) 23 set(CMAKE_REQUIRED_INCLUDES ${Valgrind_INCLUDE_DIR}) 24 check_c_source_compiles(" 25 #include <valgrind/memcheck.h> 26 #if defined(NVALGRIND) 27 # error \"Valgrind does not support this platform.\" 28 #endif 29 30 int main() {} 31 " Valgrind_WORKS) 32 endif() 33 34 include(FindPackageHandleStandardArgs) 35 find_package_handle_standard_args(Valgrind 36 REQUIRED_VARS Valgrind_INCLUDE_DIR Valgrind_WORKS 37 ) 38 39 mark_as_advanced( 40 Valgrind_INCLUDE_DIR 41 )