Browse Source

Fix for CMake

Per Mårtensson 2 weeks ago
parent
commit
a0a0061858
3 changed files with 21 additions and 4 deletions
  1. 4 2
      src/CMakeLists.txt
  2. 17 2
      src/CMakeModules/FindJSON.cmake
  3. 0 0
      src/CMakeModules/FindPaho.cmake

+ 4 - 2
src/CMakeLists.txt

@@ -160,8 +160,9 @@ set_target_properties(pahottpp PROPERTIES IMPORTED_LOCATION ${paho-mqttpp3})
 
 add_library(pahomqtt3as SHARED IMPORTED)
 set_property(TARGET pahomqtt3as PROPERTY IMPORTED_LOCATION ${paho-mqtt3as})
-
-
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(JSONCPP jsoncpp)
+link_libraries(${JSONCPP_LIBRARIES})
 
 if(MIRISDR)
 	find_package(MiriSDR)
@@ -325,6 +326,7 @@ add_library (rtl_airband_base OBJECT
 target_include_directories (rtl_airband_base PUBLIC
 	${CMAKE_CURRENT_BINARY_DIR} # needed for config.h
 	${rtl_airband_include_dirs}
+	${JSONCPP_INCLUDE_DIRS}
 )
 
 # can't do this per target with cmake <3.13

+ 17 - 2
src/CMakeModules/FindJSON.cmake

@@ -1,14 +1,29 @@
 
 if(NOT JSON_FOUND)
+find_path(JSON_INCLUDE_DIR NAMES json_c_version.h json.h PATHS /usr/include/json-c /usr/include/json)
+find_library(JSON_LIBRARY NAMES json-c json)
 
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(JSON DEFAULT_MSG
+        JSON_LIBRARY JSON_INCLUDE_DIR
+        )
+
+if(JSON_FOUND)
+    set(JSON_LIBRARIES ${JSON_LIBRARY})
+    set(JSON_INCLUDE_DIRS ${JSON_INCLUDE_DIR})
+endif()
 find_package(jsoncpp REQUIRED)
 link_libraries(${JSONCPP_LIBRARIES})
 link_directories(${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp/lib)
-# target_link_libraries(data_publish paho-mqtt3a paho-mqttpp3)
-#target_link_libraries(data_publish PahoMqttCpp::paho-mqttpp3)
+
 find_path(Jsoncpp_INCLUDE_DIR
   NAMES json/features.h
   PATH_SUFFIXES jsoncpp
   PATHS ${Jsoncpp_PKGCONF_INCLUDE_DIRS} # /usr/include/jsoncpp/json
 )
+mark_as_advanced(
+        JSON_LIBRARY
+        JSON_INCLUDE_DIRS
+)
+
 endif(NOT JSON_FOUND)

+ 0 - 0
src/CMakeModules/Findpaho.cmake → src/CMakeModules/FindPaho.cmake