1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

CMake compilation now works on Windows.

This commit is contained in:
Matias Fontanini
2014-08-24 18:06:58 -03:00
parent 443974335a
commit f5b0603799
7 changed files with 62 additions and 19 deletions

View File

@@ -29,7 +29,7 @@ find_path(PCAP_INCLUDE_DIR
)
find_library(PCAP_LIBRARY
NAMES pcap
NAMES pcap wpcap
HINTS ${PCAP_ROOT_DIR}/lib
)
@@ -39,9 +39,9 @@ find_package_handle_standard_args(PCAP DEFAULT_MSG
PCAP_INCLUDE_DIR
)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})
check_c_source_compiles("int main() { return 0; }" PCAP_LINKS_SOLO)
check_cxx_source_compiles("int main() { return 0; }" PCAP_LINKS_SOLO)
set(CMAKE_REQUIRED_LIBRARIES)
# check if linking against libpcap also needs to link against a thread library
@@ -49,18 +49,18 @@ if (NOT PCAP_LINKS_SOLO)
find_package(Threads)
if (THREADS_FOUND)
set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
check_c_source_compiles("int main() { return 0; }" PCAP_NEEDS_THREADS)
check_cxx_source_compiles("int main() { return 0; }" PCAP_NEEDS_THREADS)
set(CMAKE_REQUIRED_LIBRARIES)
endif ()
endif (THREADS_FOUND)
if (THREADS_FOUND AND PCAP_NEEDS_THREADS)
set(_tmp ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
list(REMOVE_DUPLICATES _tmp)
set(PCAP_LIBRARY ${_tmp}
CACHE STRING "Libraries needed to link against libpcap" FORCE)
else ()
else (THREADS_FOUND AND PCAP_NEEDS_THREADS)
message(FATAL_ERROR "Couldn't determine how to link against libpcap")
endif ()
endif ()
endif (THREADS_FOUND AND PCAP_NEEDS_THREADS)
endif (NOT PCAP_LINKS_SOLO)
include(CheckFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})