Browse Source

Update CMakeLists.txt (#510)

1)  add openssl version check
2) add  build option for  pcap lib : N2N_OPTION_USE_PCAPLIB
3) add build option for  libzstd  : N2N_OPTION_USE_ZSTD
pull/526/head
skyformat99 4 years ago
committed by GitHub
parent
commit
348d2baaf2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      CMakeLists.txt

48
CMakeLists.txt

@ -40,6 +40,9 @@ OPTION(BUILD_SHARED_LIBS "BUILD Shared Library" OFF)
# N2n specific params # N2n specific params
OPTION(N2N_OPTION_USE_OPENSSL "USE OPENSSL Library" OFF) OPTION(N2N_OPTION_USE_OPENSSL "USE OPENSSL Library" OFF)
OPTION(N2N_OPTION_USE_PCAPLIB "USE PCAP Library" OFF)
OPTION(N2N_OPTION_USE_ZSTD "USE ZSTD Library" OFF)
if(NOT DEFINED N2N_OPTION_USE_OPENSSL) if(NOT DEFINED N2N_OPTION_USE_OPENSSL)
set(N2N_OPTION_USE_OPENSSL OFF) set(N2N_OPTION_USE_OPENSSL OFF)
@ -52,11 +55,18 @@ if(N2N_OPTION_USE_OPENSSL)
set(N2N_OPTION_USE_OPENSSL OFF) set(N2N_OPTION_USE_OPENSSL OFF)
else() else()
MESSAGE(STATUS "Found OpenSSL ${OPENSSL_VERSION}") MESSAGE(STATUS "Found OpenSSL ${OPENSSL_VERSION}")
include_directories(${OPENSSL_INCLUDE_DIR}) string(COMPARE GREATER "${OPENSSL_VERSION}" "1.1" OPENSSL_V11)
add_definitions(-DHAVE_OPENSSL_1_1) if(OPENSSL_V11)
MESSAGE(STATUS "Use OpenSSL With -DHAVE_OPENSSL_1_1")
include_directories(${OPENSSL_INCLUDE_DIR})
add_definitions(-DHAVE_OPENSSL_1_1)
endif()
endif(NOT OPENSSL_FOUND) endif(NOT OPENSSL_FOUND)
endif(N2N_OPTION_USE_OPENSSL) endif(N2N_OPTION_USE_OPENSSL)
if(N2N_OPTION_USE_ZSTD)
add_definitions(-DN2N_HAVE_ZSTD)
endif(N2N_OPTION_USE_ZSTD)
if(NOT DEFINED CMAKE_BUILD_TYPE) if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE None) set(CMAKE_BUILD_TYPE None)
@ -125,6 +135,10 @@ if(N2N_OPTION_USE_OPENSSL)
target_link_libraries(n2n ${OPENSSL_LIBRARIES}) target_link_libraries(n2n ${OPENSSL_LIBRARIES})
endif(N2N_OPTION_USE_OPENSSL) endif(N2N_OPTION_USE_OPENSSL)
if(N2N_OPTION_USE_ZSTD)
target_link_libraries(n2n zstd)
endif(N2N_OPTION_USE_ZSTD)
if(DEFINED WIN32) if(DEFINED WIN32)
add_library(edge_utils_win32 src/edge_utils_win32.c) add_library(edge_utils_win32 src/edge_utils_win32.c)
add_subdirectory(win32) add_subdirectory(win32)
@ -146,7 +160,7 @@ target_link_libraries(example_edge_embed n2n)
add_executable(example_sn_embed src/example_sn_embed.c) add_executable(example_sn_embed src/example_sn_embed.c)
target_link_libraries(example_sn_embed n2n) target_link_libraries(example_sn_embed n2n)
if(NOT DEFINED WIN32) if(N2N_OPTION_USE_PCAPLIB AND (NOT DEFINED WIN32))
# Linux Capabilities # Linux Capabilities
find_library(CAP_LIB cap) find_library(CAP_LIB cap)
if(CAP_LIB) if(CAP_LIB)
@ -154,7 +168,7 @@ if(NOT DEFINED WIN32)
set(CMAKE_REQUIRED_LIBRARIES ${CAP_LIB}) set(CMAKE_REQUIRED_LIBRARIES ${CAP_LIB})
ADD_DEFINITIONS("-DHAVE_LIBCAP") ADD_DEFINITIONS("-DHAVE_LIBCAP")
endif() endif()
endif(NOT DEFINED WIN32) endif(N2N_OPTION_USE_PCAPLIB AND (NOT DEFINED WIN32))
install(TARGETS edge supernode install(TARGETS edge supernode
RUNTIME DESTINATION sbin RUNTIME DESTINATION sbin
@ -167,18 +181,20 @@ install(TARGETS edge supernode
add_executable(n2n-benchmark tools/benchmark.c) add_executable(n2n-benchmark tools/benchmark.c)
target_link_libraries(n2n-benchmark n2n) target_link_libraries(n2n-benchmark n2n)
find_library(PCAP_LIB pcap) if(N2N_OPTION_USE_PCAPLIB)
if(PCAP_LIB) find_library(PCAP_LIB pcap)
add_executable(n2n-decode tools/n2n_decode.c) if(PCAP_LIB)
target_link_libraries(n2n-decode n2n pcap) add_executable(n2n-decode tools/n2n_decode.c)
install(TARGETS n2n-decode RUNTIME DESTINATION bin) target_link_libraries(n2n-decode n2n pcap)
install(TARGETS n2n-decode RUNTIME DESTINATION bin)
set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIB})
check_function_exists(pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE) set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIB})
IF(HAVE_PCAP_IMMEDIATE_MODE) check_function_exists(pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE)
ADD_DEFINITIONS("-DHAVE_PCAP_IMMEDIATE_MODE") IF(HAVE_PCAP_IMMEDIATE_MODE)
ENDIF(HAVE_PCAP_IMMEDIATE_MODE) ADD_DEFINITIONS("-DHAVE_PCAP_IMMEDIATE_MODE")
endif(PCAP_LIB) ENDIF(HAVE_PCAP_IMMEDIATE_MODE)
endif(PCAP_LIB)
endif(N2N_OPTION_USE_PCAPLIB)
install(TARGETS n2n-benchmark RUNTIME DESTINATION bin) install(TARGETS n2n-benchmark RUNTIME DESTINATION bin)

Loading…
Cancel
Save