From 708d5536aec6c678cda52595d3d08a810cd0eb9d Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Mon, 15 Dec 2014 18:42:53 +0100 Subject: [PATCH] modyfied findjsoncpp cmake to look for debug library --- cmake/FindJsoncpp.cmake | 138 ++++++++++++---------------------------- 1 file changed, 41 insertions(+), 97 deletions(-) diff --git a/cmake/FindJsoncpp.cmake b/cmake/FindJsoncpp.cmake index fe72a9042..c2f0aca43 100644 --- a/cmake/FindJsoncpp.cmake +++ b/cmake/FindJsoncpp.cmake @@ -1,103 +1,47 @@ -# - try to find JSONCPP library +# Find jsoncpp # -# Cache Variables: (probably not for direct use in your scripts) -# JSONCPP_INCLUDE_DIR -# JSONCPP_LIBRARY -# -# Non-cache variables you might use in your CMakeLists.txt: -# JSONCPP_FOUND -# JSONCPP_INCLUDE_DIRS -# JSONCPP_LIBRARIES -# -# Requires these CMake modules: -# FindPackageHandleStandardArgs (known included with CMake >=2.6.2) -# -# Author: -# 2011 Philippe Crassous (ENSAM ParisTech / Institut Image) p.crassous _at_ free.fr -# -# Adapted from the Virtual Reality Peripheral Network library. -# https://github.com/rpavlik/vrpn/blob/master/README.Legal -# - -set(JSONCPP_ROOT_DIR - "${JSONCPP_ROOT_DIR}" - CACHE - PATH - "Directory to search for JSONCPP") -set(_jsoncppnames) -set(_pathsuffixes - suncc - vacpp - mingw - msvc6 - msvc7 - msvc71 - msvc80 - msvc90 - linux-gcc) -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - execute_process(COMMAND - ${CMAKE_CXX_COMPILER} - -dumpversion - OUTPUT_VARIABLE - _gnucxx_ver - OUTPUT_STRIP_TRAILING_WHITESPACE) - list(APPEND - _jsoncppnames - json_linux-gcc-${_gnucxx_ver}_libmt - json_linux-gcc_libmt) - list(APPEND _pathsuffixes linux-gcc-${_gnucxx_ver}) -elseif(MSVC) - if(MSVC_VERSION EQUAL 1200) - list(APPEND _jsoncppnames json_vc6_libmt) - elseif(MSVC_VERSION EQUAL 1300) - list(APPEND _jsoncppnames json_vc7_libmt) - elseif(MSVC_VERSION EQUAL 1310) - list(APPEND _jsoncppnames json_vc71_libmt) - elseif(MSVC_VERSION EQUAL 1400) - list(APPEND _jsoncppnames json_vc8_libmt) - elseif(MSVC_VERSION EQUAL 1500) - list(APPEND _jsoncppnames json_vc9_libmt) - elseif(MSVC_VERSION EQUAL 1600) - list(APPEND _jsoncppnames json_vc10_libmt) - endif() -else() - list(APPEND _jsoncppnames - json_suncc_libmt - json_vacpp_libmt) -endif() - -list(APPEND _jsoncppnames - json_mingw_libmt - jsoncpp) - -find_library(JSONCPP_LIBRARY - NAMES - ${_jsoncppnames} - PATHS - "${JSONCPP_ROOT_DIR}/libs" - PATH_SUFFIXES - ${_pathsuffixes}) - -find_path(JSONCPP_INCLUDE_DIR - NAMES - json/json.h - PATHS - "${JSONCPP_ROOT_DIR}" - PATH_SUFFIXES jsoncpp - include) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(JSONCPP - DEFAULT_MSG +# Find the jsoncpp includes and library +# +# if you nee to add a custom library search path, do it via via CMAKE_FIND_ROOT_PATH +# +# This module defines +# JSONCPP_INCLUDE_DIRS, where to find header, etc. +# JSONCPP_LIBRARIES, the libraries needed to use jsoncpp. +# JSONCPP_FOUND, If false, do not try to use jsoncpp. + +# only look in default directories +find_path( + JSONCPP_INCLUDE_DIR + NAMES jsoncpp/json/json.h + DOC "jsoncpp include dir" +) + +find_library( JSONCPP_LIBRARY - JSONCPP_INCLUDE_DIR) + NAMES jsoncpp + DOC "jsoncpp library" +) + +set(JSONCPP_INCLUDE_DIRS ${JSONCPP_INCLUDE_DIR}) +set(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY}) + +# debug library on windows +# same naming convention as in qt (appending debug library with d) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + find_library( + JSONCPP_LIBRARY_DEBUG + NAMES jsoncppd + DOC "jsoncpp debug library" + ) + + set(JSONCPP_LIBRARIES ${JSONCPP_LIBRARIES} ${JSONCPP_LIBRARY_DEBUG}) -if(JSONCPP_FOUND) - set(JSONCPP_LIBRARIES "${JSONCPP_LIBRARY}") - set(JSONCPP_INCLUDE_DIRS "${JSONCPP_INCLUDE_DIR}") - mark_as_advanced(JSONCPP_ROOT_DIR) endif() -mark_as_advanced(JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY) +# handle the QUIETLY and REQUIRED arguments and set GMP_FOUND to TRUE +# if all listed variables are TRUE, hide their existence from configuration view +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(jsoncpp DEFAULT_MSG + JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY) +mark_as_advanced (JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY)