aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-09-12 08:45:30 +0200
committerJan200101 <sentrycraft123@gmail.com>2022-09-12 08:45:30 +0200
commitc051a960e6fe09e2425dc223018b87a453b2bb2a (patch)
treeb27a54f6cc1695d63bae52c16eab2e1ed8003bf9
parenteadeb9f2a13577d6cd532b2a1bd306710136322a (diff)
downloadOFQT-c051a960e6fe09e2425dc223018b87a453b2bb2a.tar.gz
OFQT-c051a960e6fe09e2425dc223018b87a453b2bb2a.zip
revert pack to custom json-c cmake package because security by age
thanks Debian and Ubuntu
-rw-r--r--cmake/FindJsonC.cmake63
-rw-r--r--src/CMakeLists.txt6
2 files changed, 67 insertions, 2 deletions
diff --git a/cmake/FindJsonC.cmake b/cmake/FindJsonC.cmake
new file mode 100644
index 0000000..1d4386b
--- /dev/null
+++ b/cmake/FindJsonC.cmake
@@ -0,0 +1,63 @@
+#
+# JSONC_INCLUDE_DIRS
+# JSONC_LIBRARIES
+# JSONC_CFLAGS
+
+find_package(PkgConfig QUIET)
+if (PKG_CONFIG_FOUND)
+ pkg_check_modules(_JSONC json-c)
+
+ if (BUILD_STATIC AND NOT _JSONC_FOUND)
+ message(FATAL_ERROR "Cannot find static build information")
+ endif()
+endif()
+
+if (_JSONC_FOUND) # we can rely on pkg-config
+ if (NOT BUILD_STATIC)
+ set(JSONC_LIBRARIES ${_JSONC_LIBRARIES})
+ set(JSONC_INCLUDE_DIRS ${_JSONC_INCLUDE_DIRS})
+ set(JSONC_CFLAGS ${_JSONC_CFLAGS_OTHER})
+ else()
+ set(JSONC_LIBRARIES ${_JSONC_STATIC_LIBRARIES})
+ set(JSONC_INCLUDE_DIRS ${_JSONC_STATIC_INCLUDE_DIRS})
+ set(JSONC_CFLAGS ${_JSONC_STATIC_CFLAGS_OTHER})
+ endif()
+else()
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(_lib_suffix 64)
+ else()
+ set(_lib_suffix 32)
+ endif()
+
+ find_path(JSONC_INC
+ NAMES json.h
+ HINTS
+ ENV jsoncPath${_lib_suffix}
+ ENV jsoncPath
+ ${_JSONC_INCLUDE_DIRS}
+ PATHS
+ /usr/include/json-c /usr/local/include/json-c)
+
+ find_library(JSONC_LIB
+ NAMES ${_JSONC_LIBRARIES} jsonc json-c
+ HINTS
+ ENV jsoncPath${_lib_suffix}
+ ENV jsoncPath
+ ${_JSONC_LIBRARY_DIRS}
+ ${_JSONC_STATIC_LIBRARY_DIRS}
+ PATHS
+ /usr/lib{_lib_suffix} /usr/local/lib{_lib_suffix}
+ /usr/lib /usr/local/lib)
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(JsonC DEFAULT_MSG JSONC_LIB JSONC_INC)
+ mark_as_advanced(JSONC_INC JSONC_LIB)
+
+ if(JSONC_FOUND)
+ set(JSONC_INCLUDE_DIRS ${JSONC_INC})
+ set(JSONC_LIBRARIES ${JSONC_LIB})
+ if (BUILD_STATIC)
+ set(JSONC_LIBRARIES ${JSONC_LIBRARIES} ${_JSONC_STATIC_LIBRARIES})
+ endif()
+ endif()
+endif() \ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0fdcce5..f3d8a13 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,6 @@
-find_package(json-c REQUIRED)
find_package(Libcurl REQUIRED)
+find_package(JsonC REQUIRED)
add_subdirectory(hash)
add_subdirectory(vdf)
add_subdirectory(threading)
@@ -14,6 +14,7 @@ set(CFLAGS
-Wmissing-declarations -Wmissing-include-dirs
-Wno-unused-parameter -Wuninitialized
${LIBCURL_CFLAGS}
+ ${JSONC_CFLAGS}
)
list(APPEND
@@ -32,9 +33,10 @@ add_library(tvn STATIC ${CORE_SOURCES})
target_compile_options(tvn PUBLIC ${CFLAGS})
target_include_directories(tvn PUBLIC ${LIBCURL_INCLUDE_DIRS})
+target_include_directories(tvn PUBLIC ${JSONC_INCLUDE_DIRS})
target_include_directories(tvn PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(tvn LINK_PUBLIC ${LIBCURL_LIBRARIES})
-target_link_libraries(tvn LINK_PUBLIC json-c::json-c)
+target_link_libraries(tvn LINK_PUBLIC ${JSONC_LIBRARIES})
target_link_libraries(tvn LINK_PUBLIC md5)
target_link_libraries(tvn LINK_PUBLIC vdf)