diff --git a/cmake/Modules/FindJSONC.cmake b/cmake/Modules/FindJSONC.cmake index f72e8ea1..7b96bccf 100644 --- a/cmake/Modules/FindJSONC.cmake +++ b/cmake/Modules/FindJSONC.cmake @@ -6,6 +6,9 @@ # JSONC_INCLUDE_DIR - The JSON-C include directory. # JSONC_LIBRARY - The JSON-C library to link against. +FIND_PATH(JSONC_INCLUDE_DIR_FEDORA json-c/json.h) +FIND_LIBRARY(JSONC_LIBRARY_FEDORA NAMES json-c) + FIND_PATH(JSONC_INCLUDE_DIR json/json.h) FIND_LIBRARY(JSONC_LIBRARY NAMES json) @@ -13,18 +16,33 @@ IF (JSONC_INCLUDE_DIR AND JSONC_LIBRARY) SET(JSONC_FOUND TRUE) ENDIF (JSONC_INCLUDE_DIR AND JSONC_LIBRARY) -IF (JSONC_FOUND) +IF (JSONC_INCLUDE_DIR_FEDORA AND JSONC_LIBRARY_FEDORA) + SET(JSONC_FOUND_FEDORA TRUE) + add_definitions(-DJSONC_FEDORA) +ENDIF (JSONC_INCLUDE_DIR_FEDORA AND JSONC_LIBRARY_FEDORA) + +IF (JSONC_FOUND OR JSONC_FOUND_FEDORA) + IF (JSONC_FOUND) + # show which JSON-C was found only if not quiet + IF (NOT JSONC_FIND_QUIETLY) + MESSAGE(STATUS "Found JSON-C: ${JSONC_LIBRARY}") + ENDIF (NOT JSONC_FIND_QUIETLY) + + ENDIF (JSONC_FOUND) + + IF (JSONC_FOUND_FEDORA) + # show which JSON-C was found only if not quiet + IF (NOT JSONC_FIND_QUIETLY) + MESSAGE(STATUS "Found JSON-C: ${JSONC_LIBRARY_FEDORA}") + ENDIF (NOT JSONC_FIND_QUIETLY) - # show which JSON-C was found only if not quiet - IF (NOT JSONC_FIND_QUIETLY) - MESSAGE(STATUS "Found JSON-C: ${JSONC_LIBRARY}") - ENDIF (NOT JSONC_FIND_QUIETLY) + ENDIF (JSONC_FOUND_FEDORA) -ELSE (JSONC_FOUND) +ELSE (JSONC_FOUND OR JSONC_FOUND_FEDORA) - # fatal error if JSON-C is required but not found - IF (JSONC_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find JSON-C") - ENDIF (JSONC_FIND_REQUIRED) +# fatal error if JSON-C is required but not found +IF (JSONC_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find JSON-C") +ENDIF (JSONC_FIND_REQUIRED) -ENDIF (JSONC_FOUND) +ENDIF(JSONC_FOUND OR JSONC_FOUND_FEDORA) diff --git a/libgrive/CMakeLists.txt b/libgrive/CMakeLists.txt index 3cc15742..71f76b68 100644 --- a/libgrive/CMakeLists.txt +++ b/libgrive/CMakeLists.txt @@ -12,6 +12,10 @@ find_package(CppUnit) find_package(Iberty) find_package(ZLIB) +if (JSONC_FOUND_FEDORA) + set( JSONC_LIBRARY ${JSONC_LIBRARY_FEDORA} ) +ENDIF (JSONC_FOUND_FEDORA) + # additional headers if build unit tests IF ( CPPUNIT_FOUND ) set( OPT_INCS ${CPPUNIT_INCLUDE_DIR} ) diff --git a/libgrive/src/protocol/Json.cc b/libgrive/src/protocol/Json.cc index 4c115d6a..e4993c5f 100644 --- a/libgrive/src/protocol/Json.cc +++ b/libgrive/src/protocol/Json.cc @@ -29,8 +29,13 @@ #pragma warning(push) #pragma warning(disable: 4005) #endif +#ifdef JSONC_FEDORA +#include +#include +#else #include #include +#endif #ifdef _MSC_VER #pragma warning(pop) #endif