Commit 20b60ac6 authored by Samuel Debionne's avatar Samuel Debionne
Browse files

Update the build sytem to support devel conda package

parent 3bdc6910
Pipeline #5863 passed with stages
in 7 minutes and 4 seconds
stages:
- build
- test
- build-noarch
- deploy
build :
.build-conda: &build-conda
stage: build
script:
- cd ..
- cp -R /root/* .
- ./install_lima_submodule
- cd lima/camera/eiger
- cp -R ../../../lima-camera-eiger/* .
- cd ../..
- ./install.sh camera/eiger python tests cbf fits tiff hdf5 config
- cd ../lima-camera-eiger
- cp -R ../lima .
artifacts:
paths:
- lima/
- dist/
tags:
- conda
build-linux:
<<: *build-conda
script:
- conda build ./conda/camera --prefix-length=80 --output-folder=dist/ --channel=http://bcu-ci.esrf.fr/stable
tags:
- linux
build-noarch:
<<: *build-conda
stage: build-noarch
script:
- conda build ./conda/tango --prefix-length=80 --output-folder=dist/ --channel=http://bcu-ci.esrf.fr/stable
dependencies:
- build-linux
deploy-devel:
stage: deploy
environment:
name: devel/$CI_COMMIT_REF_NAME
url: http://bcu-ci.esrf.fr/devel
dependencies:
- build-linux
- build-noarch
script:
- cp -Rf dist/* /conda-devel/
- conda index /conda-devel/
tags:
- conda
- linux
only:
- cmake
test :
stage: test
- branches
except:
- stable
when: manual
deploy-stable:
stage: deploy
environment:
name: production
url: http://bcu-ci.esrf.fr/stable
dependencies:
- build
- build-linux
- build-noarch
script:
- cd ..
- cp -R lima-camera-eiger/lima .
- cd lima/build/
- ctest --timeout 10
- cp -Rf dist/* /conda/
- conda index /conda/
tags:
- conda
- linux
only:
- cmake
- tags
- stable
......@@ -3,77 +3,196 @@
#
# Copyright (C) : 2009-2017
# European Synchrotron Radiation Facility
# CS40220 38043 Grenoble Cedex 9
# CS40220 38043 Grenoble Cedex 9
# FRANCE
#
#
# Contact: lima@esrf.fr
#
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
cmake_minimum_required(VERSION 3.1)
project(eiger)
set(NAME "eiger")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--add-needed")
# Include additional modules that are used inconditionnaly
include(GNUInstallDirs)
include(GenerateExportHeader)
set(EIGER_SDK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/sdk" CACHE PATH "location of eiger sdk")
# If conda build, always set lib dir to 'lib'
if($ENV{CONDA_BUILD})
set(CMAKE_INSTALL_LIBDIR "lib")
endif()
# Set lower / upper case project names
string(TOUPPER "${PROJECT_NAME}" PROJECT_NAME_UPPER)
string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER)
#SOURCES
set(${NAME}_srcs src/EigerCamera.cpp src/EigerInterface.cpp
src/EigerDetInfoCtrlObj.cpp src/EigerSyncCtrlObj.cpp
src/EigerDecompress.cpp src/EigerSavingCtrlObj.cpp
src/EigerStream.cpp src/EigerDecompress.h
src/EigerStream.h sdk/linux/EigerAPI/src/CurlLoop.cpp
sdk/linux/EigerAPI/src/Requests.cpp)
add_library(lima${NAME} SHARED ${${NAME}_srcs})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#only possible after cmake 3.1.3
#TARGET_COMPILE_FEATURES(limaeiger PRIVATE -std=c++11)
#INCLUDEs
target_include_directories(lima${NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories(lima${NAME} PUBLIC "${EIGER_SDK_ROOT}/linux/EigerAPI/include")
target_include_directories(lima${NAME} PUBLIC "/usr/include/jsoncpp")
#LIBRARIES
find_library(EIGER_CURL_LIB curl)
find_library(EIGER_LZ4_LIB lz4)
find_library(EIGER_ZMQ_LIB zmq)
find_library(EIGER_JSONCPP_LIB jsoncpp)
if (("${EIGER_CURL_LIB}" STREQUAL "EIGER_CURL_LIB-NOTFOUND"))
message(FATAL_ERROR "${NAME} : libcurl not found, you can search it in cmake-gui or try to install it if it isn't here.")
# Set targets export name (used by lima and dependencies)
set(TARGETS_EXPORT_NAME "${PROJECT_NAME_LOWER}-targets")
#set(namespace "${PROJECT_NAME}::")
# Check if project is being used directly or via add_subdirectory
set(CAMERA_MASTER_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CAMERA_MASTER_PROJECT ON)
endif()
if (("${EIGER_ZMQ_LIB}" STREQUAL "EIGER_ZMQ_LIB-NOTFOUND"))
message(FATAL_ERROR "${NAME} : libzmq not found, you can search it in cmake-gui or try to install it if it isn't here.")
if (CAMERA_MASTER_PROJECT)
find_package(Lima REQUIRED)
endif()
if (("${EIGER_JSONCPP_LIB}" STREQUAL "EIGER_JSONCPP_LIB-NOTFOUND"))
message(FATAL_ERROR "${NAME} : libjsoncpp not found, you can search it in cmake-gui or try to install it if it isn't here.")
# CMake additional macros
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${LIMA_CMAKE_INCLUDE_DIRS} ${CMAKE_MODULE_PATH})
# Set version
include(project_version)
# Enable python binding code compilation using sip generator
option(CAMERA_ENABLE_PYTHON "compile python binding code?" LIMA_ENABLE_PYTHON)
if (CAMERA_ENABLE_PYTHON)
# Find python interpreter and libs
find_package(PythonInterp)
find_package(PythonLibs)
if(${PYTHONINTERP_FOUND})
# python site-packages folder
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())"
OUTPUT_VARIABLE _PYTHON_SITE_PACKAGES_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
set(PYTHON_SITE_PACKAGES_DIR ${_PYTHON_SITE_PACKAGES_DIR} CACHE PATH "where should python modules be installed?")
find_package(SIP REQUIRED)
include(SIPMacros)
if(WIN32)
set(SIP_TAGS WIN32_PLATFORM)
elseif(UNIX)
set(SIP_TAGS POSIX_PLATFORM)
endif(WIN32)
set(SIP_EXTRA_OPTIONS -e -g)
find_package(NumPy REQUIRED)
endif()
if (("${EIGER_LZ4_LIB}" STREQUAL "EIGER_LZ4_LIB-NOTFOUND"))
message(FATAL_ERROR "${NAME} : liblz4 not found, you can search it in cmake-gui or try to install it if it isn't here.")
find_package(CURL REQUIRED)
find_package(LZ4 REQUIRED)
find_package(ZMQ REQUIRED)
find_package(JsonCpp REQUIRED)
file(GLOB_RECURSE EIGER_INCS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
set(EIGER_SDK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/sdk" CACHE PATH "location of eiger sdk")
add_library(eiger SHARED
src/EigerCamera.cpp
src/EigerInterface.cpp
src/EigerDetInfoCtrlObj.cpp
src/EigerSyncCtrlObj.cpp
src/EigerDecompress.cpp
src/EigerSavingCtrlObj.cpp
src/EigerStream.cpp
sdk/linux/EigerAPI/src/CurlLoop.cpp
sdk/linux/EigerAPI/src/Requests.cpp
${EIGER_INCS}
)
# Generate export macros
generate_export_header(eiger)
# Set version and output name
set_target_properties(eiger PROPERTIES
OUTPUT_NAME "lima${PROJECT_NAME_LOWER}"
VERSION "${VERSION}"
SOVERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
# Add dependencies
target_include_directories(eiger
PUBLIC "$<BUILD_INTERFACE:${EIGER_SDK_ROOT}/linux/EigerAPI/include>"
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tools/src>"
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>" # For export header
PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_link_libraries(eiger PUBLIC
${CURL_LIBRARIES}
${LZ4_LIBRARIES}
${ZMQ_LIBRARIES}
JsonCpp::JsonCpp
limacore
)
if(WIN32)
target_compile_definitions(eiger
PRIVATE eiger_EXPORTS
PUBLIC NOMINMAX)
set_target_properties(eiger PROPERTIES PREFIX "lib" IMPORT_PREFIX "lib")
endif()
# Binding code for python
if(CAMERA_ENABLE_PYTHON)
include(LimaTools)
limatools_run_sip_for_camera(eiger)
endif()
# Generate and install package config file and version
if(CAMERA_MASTER_PROJECT)
set(PROJECT_LIBRARIES eiger)
set(SIP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/sip/lima)
set(CMAKE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/cmake/lima)
include(package_config)
endif()
target_link_libraries(lima${NAME} limacore)
target_link_libraries(lima${NAME} ${EIGER_CURL_LIB})
target_link_libraries(lima${NAME} ${EIGER_LZ4_LIB})
target_link_libraries(lima${NAME} ${EIGER_ZMQ_LIB})
target_link_libraries(lima${NAME} ${EIGER_JSONCPP_LIB})
## Installation
limatools_set_library_soversion(lima${NAME} "VERSION")
install(TARGETS lima${NAME} LIBRARY DESTINATION lib)
install(
TARGETS eiger
EXPORT "${TARGETS_EXPORT_NAME}"
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # import library
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # .so files are libraries
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # .dll files are binaries
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # this does not actually install anything (but used by downstream projects)
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
COMPONENT devel
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/project_version.h
${PROJECT_BINARY_DIR}/eiger_export.h
COMPONENT devel
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
if(CAMERA_ENABLE_PYTHON)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/
DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima/Eiger"
)
endif()
if(LIMA_ENABLE_PYTHON)
limatools_run_sip_for_camera(${NAME})
install(FILES python/__init__.py DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima/Eiger")
## Tests
if(CAMERA_ENABLE_TESTS)
enable_testing()
#add_subdirectory(test)
endif()
This diff is collapsed.
# - Find jsoncpp - Overarching find module
# This is a over-arching find module to find older jsoncpp versions and those sadly built
# without JSONCPP_WITH_CMAKE_PACKAGE=ON, as well as those built with the cmake config file.
# It also wraps the different versions of the module.
#
# On CMake 3.0 and newer:
# JsonCpp::JsonCpp - Imported target (possibly an interface/alias) to use:
# if anything is populated, this is. If both shared and static are found, then
# this will be the static version on DLL platforms and shared on non-DLL platforms.
# JsonCpp::JsonCppShared - Imported target (possibly an interface/alias) for a
# shared library version.
# JsonCpp::JsonCppStatic - Imported target (possibly an interface/alias) for a
# static library version.
#
# On all CMake versions: (Note that on CMake 2.8.10 and earlier, you may need to use JSONCPP_INCLUDE_DIRS)
# JSONCPP_LIBRARY - wraps JsonCpp::JsonCpp or equiv.
# JSONCPP_LIBRARY_IS_SHARED - if we know for sure JSONCPP_LIBRARY is shared, this is true-ish. We try to "un-set" it if we don't know one way or another.
# JSONCPP_LIBRARY_SHARED - wraps JsonCpp::JsonCppShared or equiv.
# JSONCPP_LIBRARY_STATIC - wraps JsonCpp::JsonCppStatic or equiv.
# JSONCPP_INCLUDE_DIRS - Include directories - should (generally?) not needed if you require CMake 2.8.11+ since it handles target include directories.
#
# JSONCPP_FOUND - True if JsonCpp was found.
#
# Original Author:
# 2016 Ryan Pavlik <ryan.pavlik@gmail.com>
# Incorporates work from the module contributed to VRPN under the same license:
# 2011 Philippe Crassous (ENSAM ParisTech / Institut Image) p.crassous _at_ free.fr
#
# Copyright Philippe Crassous 2011.
# Copyright Sensics, Inc. 2016.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
set(__jsoncpp_have_namespaced_targets OFF)
set(__jsoncpp_have_interface_support OFF)
if(NOT ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 3.0))
set(__jsoncpp_have_namespaced_targets ON)
set(__jsoncpp_have_interface_support ON)
elseif(("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" EQUAL 2.8) AND "${CMAKE_PATCH_VERSION}" GREATER 10)
set(__jsoncpp_have_interface_support ON)
endif()
# sets __jsoncpp_have_jsoncpplib based on whether or not we have a real imported jsoncpp_lib target.
macro(_jsoncpp_check_for_real_jsoncpplib)
set(__jsoncpp_have_jsoncpplib FALSE)
if(TARGET jsoncpp_lib)
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.
if(NOT __jsoncpp_lib_type STREQUAL "INTERFACE_LIBRARY")
set(__jsoncpp_have_jsoncpplib TRUE)
endif()
endif()
#message(STATUS "__jsoncpp_have_jsoncpplib ${__jsoncpp_have_jsoncpplib}")
endmacro()
include(FindPackageHandleStandardArgs)
# Ensure that if this is TRUE later, it's because we set it.
set(JSONCPP_FOUND FALSE)
set(__jsoncpp_have_jsoncpplib FALSE)
# See if we find a CMake config file - there is no harm in calling this more than once,
# and we need to call it at least once every CMake invocation to create the original
# imported targets, since those don't stick around like cache variables.
find_package(jsoncpp QUIET NO_MODULE)
if(jsoncpp_FOUND)
# Build a string to help us figure out when to invalidate our cache variables.
# start with where we found jsoncpp
set(__jsoncpp_info_string "[${jsoncpp_DIR}]")
# part of the string to indicate if we found a real jsoncpp_lib (and what kind)
_jsoncpp_check_for_real_jsoncpplib()
macro(_jsoncpp_apply_map_config target)
if(MSVC)
# Can't do this - different runtimes, incompatible ABI, etc.
set(_jsoncpp_debug_fallback)
else()
set(_jsoncpp_debug_fallback DEBUG)
#osvr_stash_map_config(DEBUG DEBUG RELWITHDEBINFO RELEASE MINSIZEREL NONE)
endif()
# 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_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_NONE RELEASE RELWITHDEBINFO MINSIZEREL ${_jsoncpp_debug_fallback})
if(NOT MSVC)
set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_DEBUG DEBUG RELWITHDEBINFO RELEASE MINSIZEREL NONE)
endif()
endmacro()
if(__jsoncpp_have_jsoncpplib)
list(APPEND __jsoncpp_info_string "[${__jsoncpp_lib_type}]")
_jsoncpp_apply_map_config(jsoncpp_lib)
else()
list(APPEND __jsoncpp_info_string "[]")
endif()
# part of the string to indicate if we found jsoncpp_lib_static
if(TARGET jsoncpp_lib_static)
list(APPEND __jsoncpp_info_string "[T]")
_jsoncpp_apply_map_config(jsoncpp_lib_static)
else()
list(APPEND __jsoncpp_info_string "[]")
endif()
endif()
# If we found something, and it's not the exact same as what we've found before...
# 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)
if(jsoncpp_FOUND AND NOT __jsoncpp_info_string STREQUAL "${JSONCPP_CACHED_JSONCPP_DIR_DETAILS}")
#message("Updating jsoncpp cache variables! ${__jsoncpp_info_string}")
set(JSONCPP_CACHED_JSONCPP_DIR_DETAILS "${__jsoncpp_info_string}" CACHE INTERNAL "" FORCE)
unset(JSONCPP_IMPORTED_LIBRARY_SHARED)
unset(JSONCPP_IMPORTED_LIBRARY_STATIC)
unset(JSONCPP_IMPORTED_LIBRARY)
unset(JSONCPP_IMPORTED_INCLUDE_DIRS)
unset(JSONCPP_IMPORTED_LIBRARY_IS_SHARED)
# 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.
if(__jsoncpp_have_jsoncpplib AND TARGET jsoncpp_lib_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_STATIC jsoncpp_lib_static CACHE INTERNAL "" FORCE)
if(WIN32 OR CYGWIN OR MINGW)
# DLL platforms: static library should be default
set(JSONCPP_IMPORTED_LIBRARY ${JSONCPP_IMPORTED_LIBRARY_STATIC} CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED FALSE CACHE INTERNAL "" FORCE)
else()
# 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_IS_SHARED TRUE CACHE INTERNAL "" FORCE)
endif()
elseif(TARGET jsoncpp_lib_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 jsoncpp_lib_static CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED FALSE CACHE INTERNAL "" FORCE)
elseif(__jsoncpp_have_jsoncpplib AND __jsoncpp_lib_type STREQUAL "STATIC_LIBRARY")
# 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 jsoncpp_lib CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED FALSE CACHE INTERNAL "" FORCE)
elseif(__jsoncpp_have_jsoncpplib AND __jsoncpp_lib_type STREQUAL "SHARED_LIBRARY")
# 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 jsoncpp_lib CACHE INTERNAL "" FORCE)
set(JSONCPP_IMPORTED_LIBRARY_IS_SHARED TRUE CACHE INTERNAL "" FORCE)
elseif(__jsoncpp_have_jsoncpplib)
# 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.
set(JSONCPP_IMPORTED_LIBRARY jsoncpp_lib CACHE INTERNAL "" FORCE)
endif()
# 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.
if(__jsoncpp_have_jsoncpplib)
get_property(__jsoncpp_interface_include_dirs TARGET jsoncpp_lib PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
if(__jsoncpp_interface_include_dirs)
set(JSONCPP_IMPORTED_INCLUDE_DIRS "${__jsoncpp_interface_include_dirs}" CACHE INTERNAL "" FORCE)
endif()
endif()
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)
if(__jsoncpp_interface_include_dirs)
set(JSONCPP_IMPORTED_INCLUDE_DIRS "${__jsoncpp_interface_include_dirs}" CACHE INTERNAL "" FORCE)
endif()
endif()
endif()
# As a convenience...
if(TARGET jsoncpp_lib_static AND NOT TARGET jsoncpp_lib)
add_library(jsoncpp_lib INTERFACE)
target_link_libraries(jsoncpp_lib INTERFACE jsoncpp_lib_static)
endif()
if(JSONCPP_IMPORTED_LIBRARY)
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.
# take off the jsoncpp component
get_filename_component(__jsoncpp_import_root "${jsoncpp_DIR}/.." ABSOLUTE)
set(__jsoncpp_hints "${__jsoncpp_import_root}")
# take off the cmake component
get_filename_component(__jsoncpp_import_root "${__jsoncpp_import_root}/.." ABSOLUTE)
list(APPEND __jsoncpp_hints "${__jsoncpp_import_root}")
# take off the lib component
get_filename_component(__jsoncpp_import_root "${__jsoncpp_import_root}/.." ABSOLUTE)
list(APPEND __jsoncpp_hints "${__jsoncpp_import_root}")
# take off one more component in case of multiarch lib
get_filename_component(__jsoncpp_import_root "${__jsoncpp_import_root}/.." ABSOLUTE)
list(APPEND __jsoncpp_hints "${__jsoncpp_import_root}")
# Now, search.
find_path(JsonCpp_INCLUDE_DIR
NAMES
json/json.h
PATH_SUFFIXES include jsoncpp include/jsoncpp
HINTS ${__jsoncpp_hints})
if(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!
set(JSONCPP_IMPORTED_INCLUDE_DIRS ${JsonCpp_INCLUDE_DIR})
endif()
endif()
find_package_handle_standard_args(JsonCpp
DEFAULT_MSG
jsoncpp_DIR
JSONCPP_IMPORTED_LIBRARY
JSONCPP_IMPORTED_INCLUDE_DIRS)
endif()
if(JSONCPP_FOUND)
# Create any missing namespaced targets from the config module.
if(__jsoncpp_have_namespaced_targets)
if(JSONCPP_IMPORTED_LIBRARY AND NOT TARGET JsonCpp::JsonCpp)
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
set_target_properties(JsonCpp::JsonCpp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_IMPORTED_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${JSONCPP_IMPORTED_LIBRARY}")
endif()
if(JSONCPP_IMPORTED_LIBRARY_SHARED AND NOT TARGET JsonCpp::JsonCppShared)
add_library(JsonCpp::JsonCppShared INTERFACE IMPORTED)
set_target_properties(JsonCpp::JsonCppShared PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_IMPORTED_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${JSONCPP_IMPORTED_LIBRARY_SHARED}")
endif()
if(JSONCPP_IMPORTED_LIBRARY_STATIC AND NOT TARGET JsonCpp::JsonCppStatic)
add_library(JsonCpp::JsonCppStatic INTERFACE IMPORTED)
set_target_properties(JsonCpp::JsonCppStatic PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${JSONCPP_IMPORTED_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${JSONCPP_IMPORTED_LIBRARY_STATIC}")
endif()
# Hide the stuff we didn't, and no longer, need.
if(NOT JsonCpp_LIBRARY)
unset(JsonCpp_LIBRARY CACHE)
endif()
if(NOT JsonCpp_INCLUDE_DIR)
unset(JsonCpp_INCLUDE_DIR CACHE)
endif()
endif()
set(JSONCPP_LIBRARY ${JSONCPP_IMPORTED_LIBRARY})
set(JSONCPP_INCLUDE_DIRS ${JSONCPP_IMPORTED_INCLUDE_DIRS})
if(DEFINED JSONCPP_IMPORTED_LIBRARY_IS_SHARED)
set(JSONCPP_LIBRARY_IS_SHARED ${JSONCPP_IMPORTED_LIBRARY_IS_SHARED})
else()
unset(JSONCPP_LIBRARY_IS_SHARED)
endif()
if(JSONCPP_IMPORTED_LIBRARY_SHARED)
set(JSONCPP_LIBRARY_SHARED ${JSONCPP_IMPORTED_LIBRARY_SHARED})
endif()
if(JSONCPP_IMPORTED_LIBRARY_STATIC)
set(JSONCPP_LIBRARY_STATIC ${JSONCPP_IMPORTED_LIBRARY_STATIC})
endif()
endif()
# Still nothing after looking for the config file: must go "old-school"
if(NOT JSONCPP_FOUND)
# Invoke pkgconfig for hints
find_package(PkgConfig QUIET)
set(_JSONCPP_INCLUDE_HINTS)
set(_JSONCPP_LIB_HINTS)
if(PKG_CONFIG_FOUND)
pkg_search_module(_JSONCPP_PC QUIET jsoncpp)
if(_JSONCPP_PC_INCLUDE_DIRS)
set(_JSONCPP_INCLUDE_HINTS ${_JSONCPP_PC_INCLUDE_DIRS})
endif()
if(_JSONCPP_PC_LIBRARY_DIRS)
set(_JSONCPP_LIB_HINTS ${_JSONCPP_PC_LIBRARY_DIRS})
endif()
if(_JSONCPP_PC_LIBRARIES)
set(_JSONCPP_LIB_NAMES ${_JSONCPP_PC_LIBRARIES})
endif()
endif()
if(NOT _JSONCPP_LIB_NAMES)