diff options
author | Ali Abdulkadir <autostart.ini@gmail.com> | 2017-11-22 05:24:22 +0300 |
---|---|---|
committer | Ali Abdulkadir <autostart.ini@gmail.com> | 2017-11-22 05:24:22 +0300 |
commit | 691a8974e4da741e95617819f383c0369e91233f (patch) | |
tree | 4c478c73d9bf12c0886cb2246694e96f2bf8c9bb /cmake | |
parent | 7de1e9cb69798b22f6c09c39908efd1a4568f053 (diff) | |
download | libpcap-691a8974e4da741e95617819f383c0369e91233f.tar.gz |
Avoid using the library's full path on the linker command-line
(Try to) avoid cmake's sloppy practice of using the library's full path on the linker command-line.
"e.g. -lC:\User\projects\WpdPack\Lib\Packet.lib"
This line also ends up in pcap-config, giving other build systems/compiler a very hard time.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Modules/FindPacket.cmake | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/cmake/Modules/FindPacket.cmake b/cmake/Modules/FindPacket.cmake index a5968b4a..a84e4cd3 100644 --- a/cmake/Modules/FindPacket.cmake +++ b/cmake/Modules/FindPacket.cmake @@ -49,7 +49,28 @@ # if(NOT PACKET_DLL_DIR) - set(PACKET_DLL_DIR $ENV{PACKET_DLL_DIR}) +# Compile a source file to see if the library and include files are +# already reachable. + include(CheckCSourceCompiles) + include(CMakePushCheckState) + + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET true) + set(CMAKE_REQUIRED_LIBRARIES packet) + check_c_source_compiles( +"#include <Packet32.h> + +int main() +{ + return 0; +}" PACKET_SYSTEM_LIBRARY) + cmake_pop_check_state() + + if(PACKET_SYSTEM_LIBRARY) + set(PACKET_LIBRARY packet) + else() + set(PACKET_DLL_DIR $ENV{PACKET_DLL_DIR}) + endif() endif() # The 64-bit Packet.lib is located under /x64 @@ -64,12 +85,14 @@ find_path(PACKET_INCLUDE_DIR Packet32.h PATH_SUFFIXES include Include ) +if(PACKET_SYSTEM_LIBRARY) # Find the library -find_library(PACKET_LIBRARY - NAMES Packet packet - HINTS "${PACKET_DLL_DIR}" - PATH_SUFFIXES Lib${64BIT_SUBDIR} lib${64BIT_SUBDIR} -) + find_library(PACKET_LIBRARY + NAMES Packet packet + HINTS "${PACKET_DLL_DIR}" + PATH_SUFFIXES Lib${64BIT_SUBDIR} lib${64BIT_SUBDIR} + ) +endif() # Set PACKET_FOUND to TRUE if PACKET_INCLUDE_DIR and PACKET_LIBRARY are TRUE. include(FindPackageHandleStandardArgs) |