FindBacktrace: Search and report only when not already found

Avoid saying "... detected in default set..." each time CMake is run.

Prompted by Rolf Eike Beer on cmake-developers@.
This commit is contained in:
Vadim Zhukov 2013-12-10 15:05:02 +04:00 committed by Brad King
parent 2a384e08cc
commit 9650c09b95
1 changed files with 10 additions and 7 deletions

View File

@ -58,17 +58,20 @@ endif(Backtrace_HEADER)
find_path(Backtrace_INCLUDE_DIR "${_Backtrace_HEADER_TRY}") find_path(Backtrace_INCLUDE_DIR "${_Backtrace_HEADER_TRY}")
set(Backtrace_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR}) set(Backtrace_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR})
if (NOT DEFINED Backtrace_LIBRARY)
# First, check if we already have backtrace(), e.g., in libc # First, check if we already have backtrace(), e.g., in libc
cmake_push_check_state(RESET) cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_INCLUDES ${Backtrace_INCLUDE_DIRS}) set(CMAKE_REQUIRED_INCLUDES ${Backtrace_INCLUDE_DIRS})
check_symbol_exists("backtrace" "${_Backtrace_HEADER_TRY}" _Backtrace_SYM_FOUND) check_symbol_exists("backtrace" "${_Backtrace_HEADER_TRY}" _Backtrace_SYM_FOUND)
cmake_pop_check_state() cmake_pop_check_state()
endif()
if(_Backtrace_SYM_FOUND) if(_Backtrace_SYM_FOUND)
set(Backtrace_LIBRARY) # Avoid repeating the message() call below each time CMake is run.
if(NOT Backtrace_FIND_QUIETLY) if(NOT Backtrace_FIND_QUIETLY AND NOT DEFINED Backtrace_LIBRARY)
message(STATUS "backtrace facility detected in default set of libraries") message(STATUS "backtrace facility detected in default set of libraries")
endif() endif()
set(Backtrace_LIBRARY "" CACHE FILEPATH "Library providing backtrace(3), empty for default set of libraries")
else() else()
# Check for external library, for non-glibc systems # Check for external library, for non-glibc systems
if(Backtrace_INCLUDE_DIR) if(Backtrace_INCLUDE_DIR)