Update FindJsonCpp.cmake to solve packaging issue

This commit is contained in:
Manolis Surligas 2019-12-12 01:23:04 +02:00
parent 6f13d72769
commit 3339977b81
2 changed files with 292 additions and 288 deletions

View File

@ -35,23 +35,23 @@
set(__jsoncpp_have_namespaced_targets OFF) set(__jsoncpp_have_namespaced_targets OFF)
set(__jsoncpp_have_interface_support OFF) set(__jsoncpp_have_interface_support OFF)
if(NOT ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 3.0)) if(NOT ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 3.0))
set(__jsoncpp_have_namespaced_targets ON) set(__jsoncpp_have_namespaced_targets ON)
set(__jsoncpp_have_interface_support ON) set(__jsoncpp_have_interface_support ON)
elseif(("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" EQUAL 2.8) AND "${CMAKE_PATCH_VERSION}" GREATER 10) elseif(("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" EQUAL 2.8) AND "${CMAKE_PATCH_VERSION}" GREATER 10)
set(__jsoncpp_have_interface_support ON) set(__jsoncpp_have_interface_support ON)
endif() endif()
# sets __jsoncpp_have_jsoncpplib based on whether or not we have a real imported jsoncpp_lib target. # sets __jsoncpp_have_jsoncpplib based on whether or not we have a real imported jsoncpp_lib target.
macro(_jsoncpp_check_for_real_jsoncpplib) macro(_jsoncpp_check_for_real_jsoncpplib)
set(__jsoncpp_have_jsoncpplib FALSE) set(__jsoncpp_have_jsoncpplib FALSE)
if(TARGET jsoncpp_lib) if(TARGET jsoncpp_lib)
get_property(__jsoncpp_lib_type TARGET jsoncpp_lib PROPERTY TYPE) get_property(__jsoncpp_lib_type TARGET jsoncpp_lib PROPERTY TYPE)
# We make interface libraries. If an actual config module made it, it would be an imported library. # We make interface libraries. If an actual config module made it, it would be an imported library.
if(NOT __jsoncpp_lib_type STREQUAL "INTERFACE_LIBRARY") if(NOT __jsoncpp_lib_type STREQUAL "INTERFACE_LIBRARY")
set(__jsoncpp_have_jsoncpplib TRUE) set(__jsoncpp_have_jsoncpplib TRUE)
endif() endif()
endif() endif()
#message(STATUS "__jsoncpp_have_jsoncpplib ${__jsoncpp_have_jsoncpplib}") #message(STATUS "__jsoncpp_have_jsoncpplib ${__jsoncpp_have_jsoncpplib}")
endmacro() endmacro()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
@ -65,43 +65,43 @@ set(__jsoncpp_have_jsoncpplib FALSE)
find_package(jsoncpp QUIET NO_MODULE) find_package(jsoncpp QUIET NO_MODULE)
if(jsoncpp_FOUND) if(jsoncpp_FOUND)
# Build a string to help us figure out when to invalidate our cache variables. # Build a string to help us figure out when to invalidate our cache variables.
# start with where we found jsoncpp # start with where we found jsoncpp
set(__jsoncpp_info_string "[${jsoncpp_DIR}]") set(__jsoncpp_info_string "[${jsoncpp_DIR}]")
# part of the string to indicate if we found a real jsoncpp_lib (and what kind) # part of the string to indicate if we found a real jsoncpp_lib (and what kind)
_jsoncpp_check_for_real_jsoncpplib() _jsoncpp_check_for_real_jsoncpplib()
macro(_jsoncpp_apply_map_config target) macro(_jsoncpp_apply_map_config target)
if(MSVC) if(MSVC)
# Can't do this - different runtimes, incompatible ABI, etc. # Can't do this - different runtimes, incompatible ABI, etc.
set(_jsoncpp_debug_fallback) set(_jsoncpp_debug_fallback)
else() else()
set(_jsoncpp_debug_fallback DEBUG) set(_jsoncpp_debug_fallback DEBUG)
#osvr_stash_map_config(DEBUG DEBUG RELWITHDEBINFO RELEASE MINSIZEREL NONE) #osvr_stash_map_config(DEBUG DEBUG RELWITHDEBINFO RELEASE MINSIZEREL NONE)
endif() endif()
# Appending, just in case using project or upstream fixes this. # Appending, just in case using project or upstream fixes this.
set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_RELEASE RELEASE RELWITHDEBINFO MINSIZEREL NONE ${_jsoncpp_debug_fallback}) set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_RELEASE RELEASE RELWITHDEBINFO MINSIZEREL NONE ${_jsoncpp_debug_fallback})
set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELWITHDEBINFO RELEASE MINSIZEREL NONE ${_jsoncpp_debug_fallback}) set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELWITHDEBINFO RELEASE MINSIZEREL NONE ${_jsoncpp_debug_fallback})
set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_MINSIZEREL MINSIZEREL RELEASE RELWITHDEBINFO NONE ${_jsoncpp_debug_fallback}) set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_MINSIZEREL MINSIZEREL RELEASE RELWITHDEBINFO NONE ${_jsoncpp_debug_fallback})
set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_NONE RELEASE RELWITHDEBINFO MINSIZEREL ${_jsoncpp_debug_fallback}) set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_NONE NONE RELEASE RELWITHDEBINFO MINSIZEREL ${_jsoncpp_debug_fallback})
if(NOT MSVC) if(NOT MSVC)
set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_DEBUG DEBUG RELWITHDEBINFO RELEASE MINSIZEREL NONE) set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_DEBUG DEBUG RELWITHDEBINFO RELEASE MINSIZEREL NONE)
endif() endif()
endmacro() endmacro()
if(__jsoncpp_have_jsoncpplib) if(__jsoncpp_have_jsoncpplib)
list(APPEND __jsoncpp_info_string "[${__jsoncpp_lib_type}]") list(APPEND __jsoncpp_info_string "[${__jsoncpp_lib_type}]")
_jsoncpp_apply_map_config(jsoncpp_lib) _jsoncpp_apply_map_config(jsoncpp_lib)
else() else()
list(APPEND __jsoncpp_info_string "[]") list(APPEND __jsoncpp_info_string "[]")
endif() endif()
# part of the string to indicate if we found jsoncpp_lib_static # part of the string to indicate if we found jsoncpp_lib_static
if(TARGET jsoncpp_lib_static) if(TARGET jsoncpp_lib_static)
list(APPEND __jsoncpp_info_string "[T]") list(APPEND __jsoncpp_info_string "[T]")
_jsoncpp_apply_map_config(jsoncpp_lib_static) _jsoncpp_apply_map_config(jsoncpp_lib_static)
else() else()
list(APPEND __jsoncpp_info_string "[]") list(APPEND __jsoncpp_info_string "[]")
endif() endif()
endif() endif()
@ -109,284 +109,284 @@ endif()
# NOTE: The contents of this "if" block update only (internal) cache variables! # NOTE: The contents of this "if" block update only (internal) cache variables!
# (since this will only get run the first CMake pass that finds jsoncpp or that finds a different/updated install) # (since this will only get run the first CMake pass that finds jsoncpp or that finds a different/updated install)
if(jsoncpp_FOUND AND NOT __jsoncpp_info_string STREQUAL "${JSONCPP_CACHED_JSONCPP_DIR_DETAILS}") if(jsoncpp_FOUND AND NOT __jsoncpp_info_string STREQUAL "${JSONCPP_CACHED_JSONCPP_DIR_DETAILS}")
#message("Updating jsoncpp cache variables! ${__jsoncpp_info_string}") #message("Updating jsoncpp cache variables! ${__jsoncpp_info_string}")
set(JSONCPP_CACHED_JSONCPP_DIR_DETAILS "${__jsoncpp_info_string}" CACHE INTERNAL "" FORCE) set(JSONCPP_CACHED_JSONCPP_DIR_DETAILS "${__jsoncpp_info_string}" CACHE INTERNAL "" FORCE)
unset(JSONCPP_IMPORTED_LIBRARY_SHARED) unset(JSONCPP_IMPORTED_LIBRARY_SHARED)
unset(JSONCPP_IMPORTED_LIBRARY_STATIC) unset(JSONCPP_IMPORTED_LIBRARY_STATIC)
unset(JSONCPP_IMPORTED_LIBRARY) unset(JSONCPP_IMPORTED_LIBRARY)
unset(JSONCPP_IMPORTED_INCLUDE_DIRS) unset(JSONCPP_IMPORTED_INCLUDE_DIRS)
unset(JSONCPP_IMPORTED_LIBRARY_IS_SHARED) unset(JSONCPP_IMPORTED_LIBRARY_IS_SHARED)
# if(__jsoncpp_have_jsoncpplib) is equivalent to if(TARGET jsoncpp_lib) except it excludes our # if(__jsoncpp_have_jsoncpplib) is equivalent to if(TARGET jsoncpp_lib) except it excludes our
# "invented" jsoncpp_lib interface targets, made for convenience purposes after this block. # "invented" jsoncpp_lib interface targets, made for convenience purposes after this block.
if(__jsoncpp_have_jsoncpplib AND TARGET jsoncpp_lib_static) if(__jsoncpp_have_jsoncpplib AND TARGET jsoncpp_lib_static)
# A veritable cache of riches - we have both shared and static! # A veritable cache of riches - we have both shared and static!
set(JSONCPP_IMPORTED_LIBRARY_SHARED jsoncpp_lib CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY_SHARED jsoncpp_lib CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY_STATIC jsoncpp_lib_static CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY_STATIC jsoncpp_lib_static CACHE INTERNAL "" FORCE)
if(WIN32 OR CYGWIN OR MINGW) if(WIN32 OR CYGWIN OR MINGW)
# DLL platforms: static library should be default # DLL platforms: static library should be default
set(JSONCPP_IMPORTED_LIBRARY ${JSONCPP_IMPORTED_LIBRARY_STATIC} CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY ${JSONCPP_IMPORTED_LIBRARY_STATIC} CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED FALSE CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED FALSE CACHE INTERNAL "" FORCE)
else() else()
# Other platforms - might require PIC to be linked into shared libraries, so safest to prefer shared. # Other platforms - might require PIC to be linked into shared libraries, so safest to prefer shared.
set(JSONCPP_IMPORTED_LIBRARY ${JSONCPP_IMPORTED_LIBRARY_SHARED} CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY ${JSONCPP_IMPORTED_LIBRARY_SHARED} CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED TRUE CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED TRUE CACHE INTERNAL "" FORCE)
endif() endif()
elseif(TARGET jsoncpp_lib_static) elseif(TARGET jsoncpp_lib_static)
# Well, only one variant, but we know for sure that it's static. # Well, only one variant, but we know for sure that it's static.
set(JSONCPP_IMPORTED_LIBRARY_STATIC jsoncpp_lib_static CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY_STATIC jsoncpp_lib_static CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY jsoncpp_lib_static CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY jsoncpp_lib_static CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED FALSE CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED FALSE CACHE INTERNAL "" FORCE)
elseif(__jsoncpp_have_jsoncpplib AND __jsoncpp_lib_type STREQUAL "STATIC_LIBRARY") elseif(__jsoncpp_have_jsoncpplib AND __jsoncpp_lib_type STREQUAL "STATIC_LIBRARY")
# We were able to figure out the mystery library is static! # We were able to figure out the mystery library is static!
set(JSONCPP_IMPORTED_LIBRARY_STATIC jsoncpp_lib CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY_STATIC jsoncpp_lib CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY jsoncpp_lib CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY jsoncpp_lib CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED FALSE CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED FALSE CACHE INTERNAL "" FORCE)
elseif(__jsoncpp_have_jsoncpplib AND __jsoncpp_lib_type STREQUAL "SHARED_LIBRARY") elseif(__jsoncpp_have_jsoncpplib AND __jsoncpp_lib_type STREQUAL "SHARED_LIBRARY")
# We were able to figure out the mystery library is shared! # We were able to figure out the mystery library is shared!
set(JSONCPP_IMPORTED_LIBRARY_SHARED jsoncpp_lib CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY_SHARED jsoncpp_lib CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY jsoncpp_lib CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY jsoncpp_lib CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED TRUE CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED TRUE CACHE INTERNAL "" FORCE)
elseif(__jsoncpp_have_jsoncpplib) elseif(__jsoncpp_have_jsoncpplib)
# One variant, and we have no idea if this is just an old version or if # One variant, and we have no idea if this is just an old version or if
# this is shared based on the target name alone. Hmm. # this is shared based on the target name alone. Hmm.
set(JSONCPP_IMPORTED_LIBRARY jsoncpp_lib CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_LIBRARY jsoncpp_lib CACHE INTERNAL "" FORCE)
endif() endif()
# Now, we need include directories. Can't just limit this to old CMakes, since # Now, we need include directories. Can't just limit this to old CMakes, since
# new CMakes might be used to build projects designed to support older ones. # new CMakes might be used to build projects designed to support older ones.
if(__jsoncpp_have_jsoncpplib) if(__jsoncpp_have_jsoncpplib)
get_property(__jsoncpp_interface_include_dirs TARGET jsoncpp_lib PROPERTY INTERFACE_INCLUDE_DIRECTORIES) get_property(__jsoncpp_interface_include_dirs TARGET jsoncpp_lib PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
if(__jsoncpp_interface_include_dirs) if(__jsoncpp_interface_include_dirs)
set(JSONCPP_IMPORTED_INCLUDE_DIRS "${__jsoncpp_interface_include_dirs}" CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_INCLUDE_DIRS "${__jsoncpp_interface_include_dirs}" CACHE INTERNAL "" FORCE)
endif() endif()
endif() endif()
if(TARGET jsoncpp_lib_static AND NOT JSONCPP_IMPORTED_INCLUDE_DIRS) if(TARGET jsoncpp_lib_static AND NOT JSONCPP_IMPORTED_INCLUDE_DIRS)
get_property(__jsoncpp_interface_include_dirs TARGET jsoncpp_lib_static PROPERTY INTERFACE_INCLUDE_DIRECTORIES) get_property(__jsoncpp_interface_include_dirs TARGET jsoncpp_lib_static PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
if(__jsoncpp_interface_include_dirs) if(__jsoncpp_interface_include_dirs)
set(JSONCPP_IMPORTED_INCLUDE_DIRS "${__jsoncpp_interface_include_dirs}" CACHE INTERNAL "" FORCE) set(JSONCPP_IMPORTED_INCLUDE_DIRS "${__jsoncpp_interface_include_dirs}" CACHE INTERNAL "" FORCE)
endif() endif()
endif() endif()
endif() endif()
# As a convenience... # As a convenience...
if(TARGET jsoncpp_lib_static AND NOT TARGET jsoncpp_lib) if(TARGET jsoncpp_lib_static AND NOT TARGET jsoncpp_lib)
add_library(jsoncpp_lib INTERFACE) add_library(jsoncpp_lib INTERFACE)
target_link_libraries(jsoncpp_lib INTERFACE jsoncpp_lib_static) target_link_libraries(jsoncpp_lib INTERFACE jsoncpp_lib_static)
endif() endif()
if(JSONCPP_IMPORTED_LIBRARY) if(JSONCPP_IMPORTED_LIBRARY)
if(NOT JSONCPP_IMPORTED_INCLUDE_DIRS) if(NOT JSONCPP_IMPORTED_INCLUDE_DIRS)
# OK, so we couldn't get it from the target... maybe we can figure it out from jsoncpp_DIR. # OK, so we couldn't get it from the target... maybe we can figure it out from jsoncpp_DIR.
# take off the jsoncpp component # take off the jsoncpp component
get_filename_component(__jsoncpp_import_root "${jsoncpp_DIR}/.." ABSOLUTE) get_filename_component(__jsoncpp_import_root "${jsoncpp_DIR}/.." ABSOLUTE)
set(__jsoncpp_hints "${__jsoncpp_import_root}") set(__jsoncpp_hints "${__jsoncpp_import_root}")
# take off the cmake component # take off the cmake component
get_filename_component(__jsoncpp_import_root "${__jsoncpp_import_root}/.." ABSOLUTE) get_filename_component(__jsoncpp_import_root "${__jsoncpp_import_root}/.." ABSOLUTE)
list(APPEND __jsoncpp_hints "${__jsoncpp_import_root}") list(APPEND __jsoncpp_hints "${__jsoncpp_import_root}")
# take off the lib component # take off the lib component
get_filename_component(__jsoncpp_import_root "${__jsoncpp_import_root}/.." ABSOLUTE) get_filename_component(__jsoncpp_import_root "${__jsoncpp_import_root}/.." ABSOLUTE)
list(APPEND __jsoncpp_hints "${__jsoncpp_import_root}") list(APPEND __jsoncpp_hints "${__jsoncpp_import_root}")
# take off one more component in case of multiarch lib # take off one more component in case of multiarch lib
get_filename_component(__jsoncpp_import_root "${__jsoncpp_import_root}/.." ABSOLUTE) get_filename_component(__jsoncpp_import_root "${__jsoncpp_import_root}/.." ABSOLUTE)
list(APPEND __jsoncpp_hints "${__jsoncpp_import_root}") list(APPEND __jsoncpp_hints "${__jsoncpp_import_root}")
# Now, search. # Now, search.
find_path(JsonCpp_INCLUDE_DIR find_path(JsonCpp_INCLUDE_DIR
NAMES NAMES
json/json.h json/json.h
PATH_SUFFIXES include jsoncpp include/jsoncpp PATH_SUFFIXES include jsoncpp include/jsoncpp
HINTS ${__jsoncpp_hints}) HINTS ${__jsoncpp_hints})
if(JsonCpp_INCLUDE_DIR) if(JsonCpp_INCLUDE_DIR)
mark_as_advanced(JsonCpp_INCLUDE_DIR) mark_as_advanced(JsonCpp_INCLUDE_DIR)
# Note - this does not set it in the cache, in case we find it better at some point in the future! # Note - this does not set it in the cache, in case we find it better at some point in the future!
set(JSONCPP_IMPORTED_INCLUDE_DIRS ${JsonCpp_INCLUDE_DIR}) set(JSONCPP_IMPORTED_INCLUDE_DIRS ${JsonCpp_INCLUDE_DIR})
endif() endif()
endif() endif()
find_package_handle_standard_args(JsonCpp find_package_handle_standard_args(JsonCpp
DEFAULT_MSG DEFAULT_MSG
jsoncpp_DIR jsoncpp_DIR
JSONCPP_IMPORTED_LIBRARY JSONCPP_IMPORTED_LIBRARY
JSONCPP_IMPORTED_INCLUDE_DIRS) JSONCPP_IMPORTED_INCLUDE_DIRS)
endif() endif()
if(JSONCPP_FOUND) if(JSONCPP_FOUND)
# Create any missing namespaced targets from the config module. # Create any missing namespaced targets from the config module.
if(__jsoncpp_have_namespaced_targets) if(__jsoncpp_have_namespaced_targets)
if(JSONCPP_IMPORTED_LIBRARY AND NOT TARGET JsonCpp::JsonCpp) if(JSONCPP_IMPORTED_LIBRARY AND NOT TARGET JsonCpp::JsonCpp)
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED) add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
set_target_properties(JsonCpp::JsonCpp PROPERTIES set_target_properties(JsonCpp::JsonCpp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_IMPORTED_INCLUDE_DIRS}" INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_IMPORTED_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${JSONCPP_IMPORTED_LIBRARY}") INTERFACE_LINK_LIBRARIES "${JSONCPP_IMPORTED_LIBRARY}")
endif() endif()
if(JSONCPP_IMPORTED_LIBRARY_SHARED AND NOT TARGET JsonCpp::JsonCppShared) if(JSONCPP_IMPORTED_LIBRARY_SHARED AND NOT TARGET JsonCpp::JsonCppShared)
add_library(JsonCpp::JsonCppShared INTERFACE IMPORTED) add_library(JsonCpp::JsonCppShared INTERFACE IMPORTED)
set_target_properties(JsonCpp::JsonCppShared PROPERTIES set_target_properties(JsonCpp::JsonCppShared PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_IMPORTED_INCLUDE_DIRS}" INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_IMPORTED_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${JSONCPP_IMPORTED_LIBRARY_SHARED}") INTERFACE_LINK_LIBRARIES "${JSONCPP_IMPORTED_LIBRARY_SHARED}")
endif() endif()
if(JSONCPP_IMPORTED_LIBRARY_STATIC AND NOT TARGET JsonCpp::JsonCppStatic) if(JSONCPP_IMPORTED_LIBRARY_STATIC AND NOT TARGET JsonCpp::JsonCppStatic)
add_library(JsonCpp::JsonCppStatic INTERFACE IMPORTED) add_library(JsonCpp::JsonCppStatic INTERFACE IMPORTED)
set_target_properties(JsonCpp::JsonCppStatic PROPERTIES set_target_properties(JsonCpp::JsonCppStatic PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_IMPORTED_INCLUDE_DIRS}" INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_IMPORTED_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${JSONCPP_IMPORTED_LIBRARY_STATIC}") INTERFACE_LINK_LIBRARIES "${JSONCPP_IMPORTED_LIBRARY_STATIC}")
endif() endif()
# Hide the stuff we didn't, and no longer, need. # Hide the stuff we didn't, and no longer, need.
if(NOT JsonCpp_LIBRARY) if(NOT JsonCpp_LIBRARY)
unset(JsonCpp_LIBRARY CACHE) unset(JsonCpp_LIBRARY CACHE)
endif() endif()
if(NOT JsonCpp_INCLUDE_DIR) if(NOT JsonCpp_INCLUDE_DIR)
unset(JsonCpp_INCLUDE_DIR CACHE) unset(JsonCpp_INCLUDE_DIR CACHE)
endif() endif()
endif() endif()
set(JSONCPP_LIBRARY ${JSONCPP_IMPORTED_LIBRARY}) set(JSONCPP_LIBRARY ${JSONCPP_IMPORTED_LIBRARY})
set(JSONCPP_INCLUDE_DIRS ${JSONCPP_IMPORTED_INCLUDE_DIRS}) set(JSONCPP_INCLUDE_DIRS ${JSONCPP_IMPORTED_INCLUDE_DIRS})
if(DEFINED JSONCPP_IMPORTED_LIBRARY_IS_SHARED) if(DEFINED JSONCPP_IMPORTED_LIBRARY_IS_SHARED)
set(JSONCPP_LIBRARY_IS_SHARED ${JSONCPP_IMPORTED_LIBRARY_IS_SHARED}) set(JSONCPP_LIBRARY_IS_SHARED ${JSONCPP_IMPORTED_LIBRARY_IS_SHARED})
else() else()
unset(JSONCPP_LIBRARY_IS_SHARED) unset(JSONCPP_LIBRARY_IS_SHARED)
endif() endif()
if(JSONCPP_IMPORTED_LIBRARY_SHARED) if(JSONCPP_IMPORTED_LIBRARY_SHARED)
set(JSONCPP_LIBRARY_SHARED ${JSONCPP_IMPORTED_LIBRARY_SHARED}) set(JSONCPP_LIBRARY_SHARED ${JSONCPP_IMPORTED_LIBRARY_SHARED})
endif() endif()
if(JSONCPP_IMPORTED_LIBRARY_STATIC) if(JSONCPP_IMPORTED_LIBRARY_STATIC)
set(JSONCPP_LIBRARY_STATIC ${JSONCPP_IMPORTED_LIBRARY_STATIC}) set(JSONCPP_LIBRARY_STATIC ${JSONCPP_IMPORTED_LIBRARY_STATIC})
endif() endif()
endif() endif()
# Still nothing after looking for the config file: must go "old-school" # Still nothing after looking for the config file: must go "old-school"
if(NOT JSONCPP_FOUND) if(NOT JSONCPP_FOUND)
# Invoke pkgconfig for hints # Invoke pkgconfig for hints
find_package(PkgConfig QUIET) find_package(PkgConfig QUIET)
set(_JSONCPP_INCLUDE_HINTS) set(_JSONCPP_INCLUDE_HINTS)
set(_JSONCPP_LIB_HINTS) set(_JSONCPP_LIB_HINTS)
if(PKG_CONFIG_FOUND) if(PKG_CONFIG_FOUND)
pkg_search_module(_JSONCPP_PC QUIET jsoncpp) pkg_search_module(_JSONCPP_PC QUIET jsoncpp)
if(_JSONCPP_PC_INCLUDE_DIRS) if(_JSONCPP_PC_INCLUDE_DIRS)
set(_JSONCPP_INCLUDE_HINTS ${_JSONCPP_PC_INCLUDE_DIRS}) set(_JSONCPP_INCLUDE_HINTS ${_JSONCPP_PC_INCLUDE_DIRS})
endif() endif()
if(_JSONCPP_PC_LIBRARY_DIRS) if(_JSONCPP_PC_LIBRARY_DIRS)
set(_JSONCPP_LIB_HINTS ${_JSONCPP_PC_LIBRARY_DIRS}) set(_JSONCPP_LIB_HINTS ${_JSONCPP_PC_LIBRARY_DIRS})
endif() endif()
if(_JSONCPP_PC_LIBRARIES) if(_JSONCPP_PC_LIBRARIES)
set(_JSONCPP_LIB_NAMES ${_JSONCPP_PC_LIBRARIES}) set(_JSONCPP_LIB_NAMES ${_JSONCPP_PC_LIBRARIES})
endif() endif()
endif() endif()
if(NOT _JSONCPP_LIB_NAMES) if(NOT _JSONCPP_LIB_NAMES)
# OK, if pkg-config wasn't able to give us a library name suggestion, then we may # OK, if pkg-config wasn't able to give us a library name suggestion, then we may
# have to resort to some intense old logic. # have to resort to some intense old logic.
set(_JSONCPP_LIB_NAMES jsoncpp) set(_JSONCPP_LIB_NAMES jsoncpp)
set(_JSONCPP_PATHSUFFIXES) set(_JSONCPP_PATHSUFFIXES)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND _JSONCPP_PATHSUFFIXES list(APPEND _JSONCPP_PATHSUFFIXES
linux-gcc) # bit of a generalization but close... linux-gcc) # bit of a generalization but close...
endif() endif()
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND list(APPEND
_JSONCPP_LIB_NAMES _JSONCPP_LIB_NAMES
json_linux-gcc-${CMAKE_CXX_COMPILER_VERSION}_libmt json_linux-gcc-${CMAKE_CXX_COMPILER_VERSION}_libmt
json_linux-gcc_libmt) json_linux-gcc_libmt)
list(APPEND _JSONCPP_PATHSUFFIXES list(APPEND _JSONCPP_PATHSUFFIXES
linux-gcc-${CMAKE_CXX_COMPILER_VERSION}) linux-gcc-${CMAKE_CXX_COMPILER_VERSION})
elseif(MSVC) elseif(MSVC)
if(MSVC_VERSION EQUAL 1200) if(MSVC_VERSION EQUAL 1200)
list(APPEND _JSONCPP_LIB_NAMES json_vc6_libmt) list(APPEND _JSONCPP_LIB_NAMES json_vc6_libmt)
list(APPEND _JSONCPP_PATHSUFFIXES msvc6) list(APPEND _JSONCPP_PATHSUFFIXES msvc6)
elseif(MSVC_VERSION EQUAL 1300) elseif(MSVC_VERSION EQUAL 1300)
list(APPEND _JSONCPP_LIB_NAMES json_vc7_libmt) list(APPEND _JSONCPP_LIB_NAMES json_vc7_libmt)
list(APPEND _JSONCPP_PATHSUFFIXES msvc7) list(APPEND _JSONCPP_PATHSUFFIXES msvc7)
elseif(MSVC_VERSION EQUAL 1310) elseif(MSVC_VERSION EQUAL 1310)
list(APPEND _JSONCPP_LIB_NAMES json_vc71_libmt) list(APPEND _JSONCPP_LIB_NAMES json_vc71_libmt)
list(APPEND _JSONCPP_PATHSUFFIXES msvc71) list(APPEND _JSONCPP_PATHSUFFIXES msvc71)
elseif(MSVC_VERSION EQUAL 1400) elseif(MSVC_VERSION EQUAL 1400)
list(APPEND _JSONCPP_LIB_NAMES json_vc8_libmt) list(APPEND _JSONCPP_LIB_NAMES json_vc8_libmt)
list(APPEND _JSONCPP_PATHSUFFIXES msvc80) list(APPEND _JSONCPP_PATHSUFFIXES msvc80)
elseif(MSVC_VERSION EQUAL 1500) elseif(MSVC_VERSION EQUAL 1500)
list(APPEND _JSONCPP_LIB_NAMES json_vc9_libmt) list(APPEND _JSONCPP_LIB_NAMES json_vc9_libmt)
list(APPEND _JSONCPP_PATHSUFFIXES msvc90) list(APPEND _JSONCPP_PATHSUFFIXES msvc90)
elseif(MSVC_VERSION EQUAL 1600) elseif(MSVC_VERSION EQUAL 1600)
list(APPEND _JSONCPP_LIB_NAMES json_vc10_libmt) list(APPEND _JSONCPP_LIB_NAMES json_vc10_libmt)
list(APPEND _JSONCPP_PATHSUFFIXES msvc10 msvc100) list(APPEND _JSONCPP_PATHSUFFIXES msvc10 msvc100)
endif() endif()
elseif(MINGW) elseif(MINGW)
list(APPEND _JSONCPP_LIB_NAMES list(APPEND _JSONCPP_LIB_NAMES
json_mingw_libmt) json_mingw_libmt)
list(APPEND _JSONCPP_PATHSUFFIXES mingw) list(APPEND _JSONCPP_PATHSUFFIXES mingw)
else() else()
list(APPEND _JSONCPP_LIB_NAMES list(APPEND _JSONCPP_LIB_NAMES
json_suncc_libmt json_suncc_libmt
json_vacpp_libmt) json_vacpp_libmt)
endif() endif()
endif() # end of old logic endif() # end of old logic
# Actually go looking. # Actually go looking.
find_path(JsonCpp_INCLUDE_DIR find_path(JsonCpp_INCLUDE_DIR
NAMES NAMES
json/json.h json/json.h
PATH_SUFFIXES jsoncpp PATH_SUFFIXES jsoncpp
HINTS ${_JSONCPP_INCLUDE_HINTS}) HINTS ${_JSONCPP_INCLUDE_HINTS})
find_library(JsonCpp_LIBRARY find_library(JsonCpp_LIBRARY
NAMES NAMES
${_JSONCPP_LIB_NAMES} ${_JSONCPP_LIB_NAMES}
PATHS libs PATHS libs
PATH_SUFFIXES ${_JSONCPP_PATHSUFFIXES} PATH_SUFFIXES ${_JSONCPP_PATHSUFFIXES}
HINTS ${_JSONCPP_LIB_HINTS}) HINTS ${_JSONCPP_LIB_HINTS})
find_package_handle_standard_args(JsonCpp find_package_handle_standard_args(JsonCpp
DEFAULT_MSG DEFAULT_MSG
JsonCpp_INCLUDE_DIR JsonCpp_INCLUDE_DIR
JsonCpp_LIBRARY) JsonCpp_LIBRARY)
if(JSONCPP_FOUND) if(JSONCPP_FOUND)
# We already know that the target doesn't exist, let's make it. # We already know that the target doesn't exist, let's make it.
# TODO don't know why we get errors like: # TODO don't know why we get errors like:
# error: 'JsonCpp::JsonCpp-NOTFOUND', needed by 'bin/osvr_json_to_c', missing and no known rule to make it # error: 'JsonCpp::JsonCpp-NOTFOUND', needed by 'bin/osvr_json_to_c', missing and no known rule to make it
# when we do the imported target commented out below. So, instead, we make an interface # when we do the imported target commented out below. So, instead, we make an interface
# target with an alias. Hmm. # target with an alias. Hmm.
#add_library(JsonCpp::JsonCpp UNKNOWN IMPORTED) #add_library(JsonCpp::JsonCpp UNKNOWN IMPORTED)
#set_target_properties(JsonCpp::JsonCpp PROPERTIES #set_target_properties(JsonCpp::JsonCpp PROPERTIES
# IMPORTED_LOCATION "${JsonCpp_LIBRARY}" # IMPORTED_LOCATION "${JsonCpp_LIBRARY}"
# INTERFACE_INCLUDE_DIRECTORIES "${JsonCpp_INCLUDE_DIR}" # INTERFACE_INCLUDE_DIRECTORIES "${JsonCpp_INCLUDE_DIR}"
# IMPORTED_LINK_INTERFACE_LANGUAGES "CXX") # IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
set(JSONCPP_LIBRARY "${JsonCpp_LIBRARY}") set(JSONCPP_LIBRARY "${JsonCpp_LIBRARY}")
set(JSONCPP_INCLUDE_DIRS "${JsonCpp_INCLUDE_DIR}") set(JSONCPP_INCLUDE_DIRS "${JsonCpp_INCLUDE_DIR}")
unset(JSONCPP_LIBRARY_IS_SHARED) unset(JSONCPP_LIBRARY_IS_SHARED)
if(__jsoncpp_have_interface_support AND NOT TARGET jsoncpp_interface) if(__jsoncpp_have_interface_support AND NOT TARGET jsoncpp_interface)
add_library(jsoncpp_interface INTERFACE) add_library(jsoncpp_interface INTERFACE)
set_target_properties(jsoncpp_interface PROPERTIES set_target_properties(jsoncpp_interface PROPERTIES
INTERFACE_LINK_LIBRARIES "${JsonCpp_LIBRARY}" INTERFACE_LINK_LIBRARIES "${JsonCpp_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${JsonCpp_INCLUDE_DIR}") INTERFACE_INCLUDE_DIRECTORIES "${JsonCpp_INCLUDE_DIR}")
endif() endif()
if(__jsoncpp_have_namespaced_targets) if(__jsoncpp_have_namespaced_targets)
if(NOT TARGET JsonCpp::JsonCpp) if(NOT TARGET JsonCpp::JsonCpp)
add_library(JsonCpp::JsonCpp ALIAS jsoncpp_interface) add_library(JsonCpp::JsonCpp ALIAS jsoncpp_interface)
endif() endif()
endif() endif()
endif() endif()
endif() endif()
if(JSONCPP_FOUND) if(JSONCPP_FOUND)
mark_as_advanced(jsoncpp_DIR JsonCpp_INCLUDE_DIR JsonCpp_LIBRARY) mark_as_advanced(jsoncpp_DIR JsonCpp_INCLUDE_DIR JsonCpp_LIBRARY)
endif() endif()

View File

@ -1,10 +1,14 @@
Index: gr-satnogs/CMakeLists.txt Index: gr-satnogs/CMakeLists.txt
=================================================================== ===================================================================
--- gr-satnogs.orig/CMakeLists.txt --- a/CMakeLists.txt
+++ gr-satnogs/CMakeLists.txt +++ b/CMakeLists.txt
@@ -52,4 +52,4 @@ list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_ @@ -46,7 +46,7 @@ list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
-set(VERSION_INFO_MAINT_VERSION git) set(VERSION_MAJOR 1)
+set(VERSION_INFO_MAINT_VERSION 0) set(VERSION_API 5)
set(VERSION_ABI 1)
-set(VERSION_PATCH git)
+set(VERSION_PATCH 0)
cmake_policy(SET CMP0011 NEW)
######################################################################## ########################################################################