From a5768442636c7fe909e8afc205fd19ac13b9fbc2 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 20 Feb 2015 08:15:43 -0500
Subject: FindJsonCpp: Drop new module due to upstream jsoncpp providing
 package

Since jsoncpp 0.7.0 (2014-11-20) the upstream may provide a CMake
package configuration file such that find_package(jsoncpp) will find a
jsoncppConfig.cmake file.  In order to avoid conflicting with this
(especially on case-insensitive filesystems), and since we always prefer
projects to provide package config files (that they maintain), it is
better to not provide FindJsonCpp publicly.

Move FindJsonCpp into a private source directory that is not installed
so that we can still use it for building CMake itself.

Reported-by: Ryan Pavlik <ryan.pavlik@gmail.com>
---
 CMakeLists.txt                        |   6 +-
 Help/manual/cmake-modules.7.rst       |   1 -
 Help/module/FindJsonCpp.rst           |   1 -
 Help/release/3.2.rst                  |   3 -
 Modules/FindJsonCpp.cmake             | 117 ----------------------------------
 Source/Modules/FindJsonCpp.cmake      | 117 ++++++++++++++++++++++++++++++++++
 Tests/FindJsonCpp/Test/CMakeLists.txt |   3 +
 7 files changed, 122 insertions(+), 126 deletions(-)
 delete mode 100644 Help/module/FindJsonCpp.rst
 delete mode 100644 Modules/FindJsonCpp.cmake
 create mode 100644 Source/Modules/FindJsonCpp.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e61621d..1250a94 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -382,10 +382,8 @@ macro (CMAKE_BUILD_UTILITIES)
   #---------------------------------------------------------------------
   # Build jsoncpp library.
   if(CMAKE_USE_SYSTEM_JSONCPP)
-    if(EXISTS ${CMAKE_ROOT}/Modules/FindJsonCpp.cmake)
-      find_package(JsonCpp)
-    elseif(NOT CMAKE_VERSION VERSION_LESS 3.0)
-      include(${CMake_SOURCE_DIR}/Modules/FindJsonCpp.cmake)
+    if(NOT CMAKE_VERSION VERSION_LESS 3.0)
+      include(${CMake_SOURCE_DIR}/Source/Modules/FindJsonCpp.cmake)
     else()
       message(FATAL_ERROR "CMAKE_USE_SYSTEM_JSONCPP requires CMake >= 3.0")
     endif()
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index db56010..965eede 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -126,7 +126,6 @@ All Modules
    /module/FindJava
    /module/FindJNI
    /module/FindJPEG
-   /module/FindJsonCpp
    /module/FindKDE3
    /module/FindKDE4
    /module/FindLAPACK
diff --git a/Help/module/FindJsonCpp.rst b/Help/module/FindJsonCpp.rst
deleted file mode 100644
index ba87ece..0000000
--- a/Help/module/FindJsonCpp.rst
+++ /dev/null
@@ -1 +0,0 @@
-.. cmake-module:: ../../Modules/FindJsonCpp.cmake
diff --git a/Help/release/3.2.rst b/Help/release/3.2.rst
index ddc3d86..ef26dbe 100644
--- a/Help/release/3.2.rst
+++ b/Help/release/3.2.rst
@@ -124,9 +124,6 @@ Modules
 * A :module:`FindIntl` module was introduced to find the
   Gettext ``libintl`` library.
 
-* A :module:`FindJsonCpp` module was introduced to find the
-  JsonCpp package.
-
 * The :module:`FindLATEX` module learned to support components.
 
 * The :module:`FindMPI` module learned to find MS-MPI on Windows.
diff --git a/Modules/FindJsonCpp.cmake b/Modules/FindJsonCpp.cmake
deleted file mode 100644
index cbb4fb3..0000000
--- a/Modules/FindJsonCpp.cmake
+++ /dev/null
@@ -1,117 +0,0 @@
-#[=======================================================================[.rst:
-FindJsonCpp
------------
-
-Find JsonCpp includes and library.
-
-Imported Targets
-^^^^^^^^^^^^^^^^
-
-An :ref:`imported target <Imported targets>` named
-``JsonCpp::JsonCpp`` is provided if JsonCpp has been found.
-
-Result Variables
-^^^^^^^^^^^^^^^^
-
-This module defines the following variables:
-
-``JsonCpp_FOUND``
-  True if JsonCpp was found, false otherwise.
-``JsonCpp_INCLUDE_DIRS``
-  Include directories needed to include JsonCpp headers.
-``JsonCpp_LIBRARIES``
-  Libraries needed to link to JsonCpp.
-``JsonCpp_VERSION_STRING``
-  The version of JsonCpp found.
-  May not be set for JsonCpp versions prior to 1.0.
-``JsonCpp_VERSION_MAJOR``
-  The major version of JsonCpp.
-``JsonCpp_VERSION_MINOR``
-  The minor version of JsonCpp.
-``JsonCpp_VERSION_PATCH``
-  The patch version of JsonCpp.
-
-Cache Variables
-^^^^^^^^^^^^^^^
-
-This module uses the following cache variables:
-
-``JsonCpp_LIBRARY``
-  The location of the JsonCpp library file.
-``JsonCpp_INCLUDE_DIR``
-  The location of the JsonCpp include directory containing ``json/json.h``.
-
-The cache variables should not be used by project code.
-They may be set by end users to point at JsonCpp components.
-#]=======================================================================]
-
-#=============================================================================
-# Copyright 2014-2015 Kitware, Inc.
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-#  License text for the above reference.)
-
-#-----------------------------------------------------------------------------
-find_library(JsonCpp_LIBRARY
-  NAMES jsoncpp
-  )
-mark_as_advanced(JsonCpp_LIBRARY)
-
-find_path(JsonCpp_INCLUDE_DIR
-  NAMES json/json.h
-  PATH_SUFFIXES jsoncpp
-  )
-mark_as_advanced(JsonCpp_INCLUDE_DIR)
-
-#-----------------------------------------------------------------------------
-# Extract version number if possible.
-set(_JsonCpp_H_REGEX "^#[ \t]*define[ \t]+JSONCPP_VERSION_STRING[ \t]+\"(([0-9]+)\\.([0-9]+)\\.([0-9]+)[^\"]*)\".*$")
-if(JsonCpp_INCLUDE_DIR AND EXISTS "${JsonCpp_INCLUDE_DIR}/json/version.h")
-  file(STRINGS "${JsonCpp_INCLUDE_DIR}/json/version.h" _JsonCpp_H REGEX "${_JsonCpp_H_REGEX}")
-else()
-  set(_JsonCpp_H "")
-endif()
-if(_JsonCpp_H MATCHES "${_JsonCpp_H_REGEX}")
-  set(JsonCpp_VERSION_STRING "${CMAKE_MATCH_1}")
-  set(JsonCpp_VERSION_MAJOR "${CMAKE_MATCH_2}")
-  set(JsonCpp_VERSION_MINOR "${CMAKE_MATCH_3}")
-  set(JsonCpp_VERSION_PATCH "${CMAKE_MATCH_4}")
-else()
-  set(JsonCpp_VERSION_STRING "")
-  set(JsonCpp_VERSION_MAJOR "")
-  set(JsonCpp_VERSION_MINOR "")
-  set(JsonCpp_VERSION_PATCH "")
-endif()
-unset(_JsonCpp_H_REGEX)
-unset(_JsonCpp_H)
-
-#-----------------------------------------------------------------------------
-include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(JsonCpp
-  FOUND_VAR JsonCpp_FOUND
-  REQUIRED_VARS JsonCpp_LIBRARY JsonCpp_INCLUDE_DIR
-  VERSION_VAR JsonCpp_VERSION_STRING
-  )
-set(JSONCPP_FOUND ${JsonCpp_FOUND})
-
-#-----------------------------------------------------------------------------
-# Provide documented result variables and targets.
-if(JsonCpp_FOUND)
-  set(JsonCpp_INCLUDE_DIRS ${JsonCpp_INCLUDE_DIR})
-  set(JsonCpp_LIBRARIES ${JsonCpp_LIBRARY})
-  if(NOT TARGET JsonCpp::JsonCpp)
-    add_library(JsonCpp::JsonCpp UNKNOWN IMPORTED)
-    set_target_properties(JsonCpp::JsonCpp PROPERTIES
-      IMPORTED_LOCATION "${JsonCpp_LIBRARY}"
-      INTERFACE_INCLUDE_DIRECTORIES "${JsonCpp_INCLUDE_DIRS}"
-      IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
-      )
-  endif()
-endif()
diff --git a/Source/Modules/FindJsonCpp.cmake b/Source/Modules/FindJsonCpp.cmake
new file mode 100644
index 0000000..014d3bd
--- /dev/null
+++ b/Source/Modules/FindJsonCpp.cmake
@@ -0,0 +1,117 @@
+#[=======================================================================[.rst:
+FindJsonCpp
+-----------
+
+Find JsonCpp includes and library.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+An :ref:`imported target <Imported targets>` named
+``JsonCpp::JsonCpp`` is provided if JsonCpp has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+``JsonCpp_FOUND``
+  True if JsonCpp was found, false otherwise.
+``JsonCpp_INCLUDE_DIRS``
+  Include directories needed to include JsonCpp headers.
+``JsonCpp_LIBRARIES``
+  Libraries needed to link to JsonCpp.
+``JsonCpp_VERSION_STRING``
+  The version of JsonCpp found.
+  May not be set for JsonCpp versions prior to 1.0.
+``JsonCpp_VERSION_MAJOR``
+  The major version of JsonCpp.
+``JsonCpp_VERSION_MINOR``
+  The minor version of JsonCpp.
+``JsonCpp_VERSION_PATCH``
+  The patch version of JsonCpp.
+
+Cache Variables
+^^^^^^^^^^^^^^^
+
+This module uses the following cache variables:
+
+``JsonCpp_LIBRARY``
+  The location of the JsonCpp library file.
+``JsonCpp_INCLUDE_DIR``
+  The location of the JsonCpp include directory containing ``json/json.h``.
+
+The cache variables should not be used by project code.
+They may be set by end users to point at JsonCpp components.
+#]=======================================================================]
+
+#=============================================================================
+# Copyright 2014-2015 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+#-----------------------------------------------------------------------------
+find_library(JsonCpp_LIBRARY
+  NAMES jsoncpp
+  )
+mark_as_advanced(JsonCpp_LIBRARY)
+
+find_path(JsonCpp_INCLUDE_DIR
+  NAMES json/json.h
+  PATH_SUFFIXES jsoncpp
+  )
+mark_as_advanced(JsonCpp_INCLUDE_DIR)
+
+#-----------------------------------------------------------------------------
+# Extract version number if possible.
+set(_JsonCpp_H_REGEX "^#[ \t]*define[ \t]+JSONCPP_VERSION_STRING[ \t]+\"(([0-9]+)\\.([0-9]+)\\.([0-9]+)[^\"]*)\".*$")
+if(JsonCpp_INCLUDE_DIR AND EXISTS "${JsonCpp_INCLUDE_DIR}/json/version.h")
+  file(STRINGS "${JsonCpp_INCLUDE_DIR}/json/version.h" _JsonCpp_H REGEX "${_JsonCpp_H_REGEX}")
+else()
+  set(_JsonCpp_H "")
+endif()
+if(_JsonCpp_H MATCHES "${_JsonCpp_H_REGEX}")
+  set(JsonCpp_VERSION_STRING "${CMAKE_MATCH_1}")
+  set(JsonCpp_VERSION_MAJOR "${CMAKE_MATCH_2}")
+  set(JsonCpp_VERSION_MINOR "${CMAKE_MATCH_3}")
+  set(JsonCpp_VERSION_PATCH "${CMAKE_MATCH_4}")
+else()
+  set(JsonCpp_VERSION_STRING "")
+  set(JsonCpp_VERSION_MAJOR "")
+  set(JsonCpp_VERSION_MINOR "")
+  set(JsonCpp_VERSION_PATCH "")
+endif()
+unset(_JsonCpp_H_REGEX)
+unset(_JsonCpp_H)
+
+#-----------------------------------------------------------------------------
+include(${CMAKE_CURRENT_LIST_DIR}/../../Modules/FindPackageHandleStandardArgs.cmake)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(JsonCpp
+  FOUND_VAR JsonCpp_FOUND
+  REQUIRED_VARS JsonCpp_LIBRARY JsonCpp_INCLUDE_DIR
+  VERSION_VAR JsonCpp_VERSION_STRING
+  )
+set(JSONCPP_FOUND ${JsonCpp_FOUND})
+
+#-----------------------------------------------------------------------------
+# Provide documented result variables and targets.
+if(JsonCpp_FOUND)
+  set(JsonCpp_INCLUDE_DIRS ${JsonCpp_INCLUDE_DIR})
+  set(JsonCpp_LIBRARIES ${JsonCpp_LIBRARY})
+  if(NOT TARGET JsonCpp::JsonCpp)
+    add_library(JsonCpp::JsonCpp UNKNOWN IMPORTED)
+    set_target_properties(JsonCpp::JsonCpp PROPERTIES
+      IMPORTED_LOCATION "${JsonCpp_LIBRARY}"
+      INTERFACE_INCLUDE_DIRECTORIES "${JsonCpp_INCLUDE_DIRS}"
+      IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
+      )
+  endif()
+endif()
diff --git a/Tests/FindJsonCpp/Test/CMakeLists.txt b/Tests/FindJsonCpp/Test/CMakeLists.txt
index 4e1e271..d1dc647 100644
--- a/Tests/FindJsonCpp/Test/CMakeLists.txt
+++ b/Tests/FindJsonCpp/Test/CMakeLists.txt
@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.1)
 project(TestFindJsonCpp CXX)
 include(CTest)
 
+# CMake does not actually provide FindJsonCpp publicly.
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../Source/Modules)
+
 find_package(JsonCpp REQUIRED)
 
 add_executable(test_jsoncpp_tgt main.cxx)
-- 
cgit v0.12


From a41d621d30f73d4a17e4fd2d3ff30f87f1ed4ccc Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 20 Feb 2015 08:28:03 -0500
Subject: bootstrap: Add --(no-)system-jsoncpp options

Provide bootstrap-time control for using a system JsonCpp library.
---
 bootstrap | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/bootstrap b/bootstrap
index e7d0496..5f12ee0 100755
--- a/bootstrap
+++ b/bootstrap
@@ -398,6 +398,8 @@ Configuration:
   --no-system-curl        use cmake-provided curl library (default)
   --system-expat          use system-installed expat library
   --no-system-expat       use cmake-provided expat library (default)
+  --system-jsoncpp        use system-installed jsoncpp library
+  --no-system-jsoncpp     use cmake-provided jsoncpp library (default)
   --system-zlib           use system-installed zlib library
   --no-system-zlib        use cmake-provided zlib library (default)
   --system-bzip2          use system-installed bzip2 library
@@ -637,10 +639,10 @@ while test $# != 0; do
   --init=*) cmake_init_file=`cmake_arg "$1"` ;;
   --system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" ;;
   --no-system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" ;;
-  --system-bzip2|--system-curl|--system-expat|--system-libarchive|--system-zlib)
+  --system-bzip2|--system-curl|--system-expat|--system-jsoncpp|--system-libarchive|--system-zlib)
     lib=`cmake_arg "$1" "--system-"`
     cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=1" ;;
-  --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-libarchive|--no-system-zlib)
+  --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-jsoncpp|--no-system-libarchive|--no-system-zlib)
     lib=`cmake_arg "$1" "--no-system-"`
     cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=0" ;;
   --qt-gui) cmake_bootstrap_qt_gui="1" ;;
-- 
cgit v0.12