summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-11-15 21:13:45 +0100
committerPeter Wu <peter@lekensteyn.nl>2016-11-18 17:33:53 +0000
commit58c4a4e018a3e1086ccbea773a05fa3f005a1a14 (patch)
treedcc1aef49a7b4dfebedf3fef0c079c901dd27eef /cmake
parentbba62e296bc500f2fca48aaeb0c440916ae470d9 (diff)
downloadwireshark-58c4a4e018a3e1086ccbea773a05fa3f005a1a14.tar.gz
cmake/FindPCAP: fix use of bad cached function checks
When libpcap-dev is not installed, do not look for functions like pcap_datalink_name_to_val since the negative result would be cached. Then after installing libpcap-dev, the build would fail due to redeclaration of functions. Change-Id: Ifdbad09e9cf160383b16b6459693f7ea5d65b9c3 Reviewed-on: https://code.wireshark.org/review/18834 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindPCAP.cmake94
1 files changed, 48 insertions, 46 deletions
diff --git a/cmake/modules/FindPCAP.cmake b/cmake/modules/FindPCAP.cmake
index c362cc0c3b..69dffba4a1 100644
--- a/cmake/modules/FindPCAP.cmake
+++ b/cmake/modules/FindPCAP.cmake
@@ -43,54 +43,56 @@ else()
set( PCAP_LIBRARIES )
endif()
-#Functions
-include( CMakePushCheckState )
-include( CheckFunctionExists )
-include( CheckVariableExists )
+if( PCAP_FOUND )
+ #Functions
+ include( CMakePushCheckState )
+ include( CheckFunctionExists )
+ include( CheckVariableExists )
-cmake_push_check_state()
-set( CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS} )
-set( CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARIES} )
+ cmake_push_check_state()
+ set( CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS} )
+ set( CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARIES} )
-check_function_exists( "pcap_open_dead" HAVE_PCAP_OPEN_DEAD )
-check_function_exists( "pcap_freecode" HAVE_PCAP_FREECODE )
-#
-# Note: for pcap_breakloop() and pcap_findalldevs(), the autoconf script
-# checks for more than just whether the function exists, it also checks
-# for whether pcap.h declares it; Mac OS X software/security updates can
-# update libpcap without updating the headers.
-#
-check_function_exists( "pcap_breakloop" HAVE_PCAP_BREAKLOOP )
-check_function_exists( "pcap_create" HAVE_PCAP_CREATE )
-if( HAVE_PCAP_CREATE OR WIN32 )
- #
- # If we have pcap_create(), we have pcap_set_buffer_size(), and
- # can set the capture buffer size.
- #
- # Otherwise, if this is Windows, we have pcap_setbuff(), and can
- # set the capture buffer size.
- #
- set( CAN_SET_CAPTURE_BUFFER_SIZE TRUE )
-endif()
-check_function_exists( "pcap_datalink_name_to_val" HAVE_PCAP_DATALINK_NAME_TO_VAL )
-check_function_exists( "pcap_datalink_val_to_description" HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION )
-check_function_exists( "pcap_datalink_val_to_name" HAVE_PCAP_DATALINK_VAL_TO_NAME )
-check_function_exists( "pcap_findalldevs" HAVE_PCAP_FINDALLDEVS )
-check_function_exists( "pcap_free_datalinks" HAVE_PCAP_FREE_DATALINKS )
-check_function_exists( "pcap_get_selectable_fd" HAVE_PCAP_GET_SELECTABLE_FD )
-check_function_exists( "pcap_lib_version" HAVE_PCAP_LIB_VERSION )
-check_function_exists( "pcap_list_datalinks" HAVE_PCAP_LIST_DATALINKS )
-check_function_exists( "pcap_set_datalink" HAVE_PCAP_SET_DATALINK )
-check_function_exists( "bpf_image" HAVE_BPF_IMAGE )
-check_function_exists( "pcap_setsampling" HAVE_PCAP_SETSAMPLING )
-check_function_exists( "pcap_set_tstamp_precision" HAVE_PCAP_SET_TSTAMP_PRECISION )
-# Remote pcap checks
-check_function_exists( "pcap_open" HAVE_PCAP_OPEN )
-if( HAVE_PCAP_OPEN )
- set( HAVE_PCAP_REMOTE 1 )
- set( HAVE_REMOTE 1 )
-endif()
+ check_function_exists( "pcap_open_dead" HAVE_PCAP_OPEN_DEAD )
+ check_function_exists( "pcap_freecode" HAVE_PCAP_FREECODE )
+ #
+ # Note: for pcap_breakloop() and pcap_findalldevs(), the autoconf script
+ # checks for more than just whether the function exists, it also checks
+ # for whether pcap.h declares it; Mac OS X software/security updates can
+ # update libpcap without updating the headers.
+ #
+ check_function_exists( "pcap_breakloop" HAVE_PCAP_BREAKLOOP )
+ check_function_exists( "pcap_create" HAVE_PCAP_CREATE )
+ if( HAVE_PCAP_CREATE OR WIN32 )
+ #
+ # If we have pcap_create(), we have pcap_set_buffer_size(), and
+ # can set the capture buffer size.
+ #
+ # Otherwise, if this is Windows, we have pcap_setbuff(), and can
+ # set the capture buffer size.
+ #
+ set( CAN_SET_CAPTURE_BUFFER_SIZE TRUE )
+ endif()
+ check_function_exists( "pcap_datalink_name_to_val" HAVE_PCAP_DATALINK_NAME_TO_VAL )
+ check_function_exists( "pcap_datalink_val_to_description" HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION )
+ check_function_exists( "pcap_datalink_val_to_name" HAVE_PCAP_DATALINK_VAL_TO_NAME )
+ check_function_exists( "pcap_findalldevs" HAVE_PCAP_FINDALLDEVS )
+ check_function_exists( "pcap_free_datalinks" HAVE_PCAP_FREE_DATALINKS )
+ check_function_exists( "pcap_get_selectable_fd" HAVE_PCAP_GET_SELECTABLE_FD )
+ check_function_exists( "pcap_lib_version" HAVE_PCAP_LIB_VERSION )
+ check_function_exists( "pcap_list_datalinks" HAVE_PCAP_LIST_DATALINKS )
+ check_function_exists( "pcap_set_datalink" HAVE_PCAP_SET_DATALINK )
+ check_function_exists( "bpf_image" HAVE_BPF_IMAGE )
+ check_function_exists( "pcap_setsampling" HAVE_PCAP_SETSAMPLING )
+ check_function_exists( "pcap_set_tstamp_precision" HAVE_PCAP_SET_TSTAMP_PRECISION )
+ # Remote pcap checks
+ check_function_exists( "pcap_open" HAVE_PCAP_OPEN )
+ if( HAVE_PCAP_OPEN )
+ set( HAVE_PCAP_REMOTE 1 )
+ set( HAVE_REMOTE 1 )
+ endif()
-cmake_pop_check_state()
+ cmake_pop_check_state()
+endif()
mark_as_advanced( PCAP_LIBRARIES PCAP_INCLUDE_DIRS )