mirror of
https://github.com/adulau/ssldump.git
synced 2024-11-07 12:06:27 +00:00
Add FindJSONC.cmake module + fix CMakeLists.txt
This commit is contained in:
parent
45111603a7
commit
a4bfc7fb36
2 changed files with 55 additions and 6 deletions
|
@ -34,12 +34,12 @@ set(SOURCES
|
|||
pcap/sys.c
|
||||
)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules/")
|
||||
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules/" ${CMAKE_MODULE_PATH})
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(PCAP REQUIRED)
|
||||
find_package(LIBNET REQUIRED)
|
||||
find_package(json-c REQUIRED)
|
||||
find_package(JSONC REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
|
@ -63,14 +63,14 @@ target_include_directories(ssldump
|
|||
${OPENSSL_INCLUDE_DIR}
|
||||
${PCAP_INCLUDE_DIR}
|
||||
${LIBNET_INCLUDE_DIR}
|
||||
${json-c_INCLUDE_DIR}
|
||||
${JSONC_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(ssldump
|
||||
PRIVATE
|
||||
${OPENSSL_LIBRARIES}
|
||||
pcap
|
||||
net
|
||||
json-c
|
||||
${PCAP_LIBRARY}
|
||||
${LIBNET_LIBRARY}
|
||||
${JSONC_LIBRARIES}
|
||||
)
|
||||
|
||||
|
|
49
cmake/modules/FindJSONC.cmake
Normal file
49
cmake/modules/FindJSONC.cmake
Normal file
|
@ -0,0 +1,49 @@
|
|||
# From https://github.com/fastogt/cmake/blob/master/FindJSON-C.cmake
|
||||
# Copyright (c) 2018, FastoGT
|
||||
# License: BSD 3-Clause
|
||||
# Modified by: Micah Snyder
|
||||
|
||||
# JSONC_FOUND - true if library and headers were found
|
||||
# JSONC_INCLUDE_DIRS - include directories
|
||||
# JSONC_LIBRARIES - library directories
|
||||
|
||||
if(JSONC_USE_STATIC)
|
||||
add_library(jsonc STATIC IMPORTED GLOBAL)
|
||||
else()
|
||||
add_library(jsonc SHARED IMPORTED GLOBAL)
|
||||
endif(JSONC_USE_STATIC)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
PKG_CHECK_MODULES(PC_JSONC QUIET json-c)
|
||||
|
||||
find_path(JSONC_INCLUDE_DIR json.h
|
||||
HINTS ${PC_JSONC_INCLUDEDIR} ${PC_JSONC_INCLUDE_DIRS} PATH_SUFFIXES json-c json)
|
||||
|
||||
if(JSONC_USE_STATIC)
|
||||
find_library(JSONC_LIBRARY NAMES libjson-c.a libjson-c-static.a
|
||||
HINTS ${PC_JSONC_LIBDIR} ${PC_JSONC_LIBRARY_DIRS})
|
||||
else()
|
||||
find_library(JSONC_LIBRARY NAMES json-c libjson-c
|
||||
HINTS ${PC_JSONC_LIBDIR} ${PC_JSONC_LIBRARY_DIRS})
|
||||
endif(JSONC_USE_STATIC)
|
||||
|
||||
set(JSONC_LIBRARIES ${JSONC_LIBRARY})
|
||||
set(JSONC_INCLUDE_DIRS ${JSONC_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(JSONC DEFAULT_MSG JSONC_LIBRARIES JSONC_INCLUDE_DIRS)
|
||||
|
||||
if(JSONC_FOUND AND NOT TARGET JSONC::jsonc)
|
||||
add_library(JSONC::jsonc UNKNOWN IMPORTED)
|
||||
set_target_properties(JSONC::jsonc PROPERTIES
|
||||
IMPORTED_LOCATION "${JSONC_LIBRARY}"
|
||||
INTERFACE_COMPILE_OPTIONS "${PC_JSONC_CFLAGS_OTHER}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${JSONC_INCLUDE_DIRS}"
|
||||
)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
JSONC_INCLUDE_DIR
|
||||
JSONC_LIBRARY
|
||||
)
|
||||
|
Loading…
Reference in a new issue