1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
Description: Fix CMake support for PROJ.
Origin: https://salsa.debian.org/debian/openorienteering-mapper/raw/debian/0.8.4-1/cmake/FindPROJ4.cmake
Forwarded: not-needed
--- /dev/null
+++ b/cmake/Modules/FindPROJ.cmake
@@ -0,0 +1,164 @@
+#.rst:
+# FindPROJ
+# --------
+#
+# Find the proj includes and library.
+#
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines :prop_tgt:`IMPORTED` target ``PROJ::proj``,
+# if PROJ has been found.
+#
+# Result Variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the following variables:
+#
+# ::
+#
+# PROJ_INCLUDE_DIRS - where to find proj_api.h, etc.
+# PROJ_LIBRARIES - List of libraries when using libproj.
+# PROJ_FOUND - True if libproj found.
+#
+# ::
+#
+# PROJ_VERSION - The version of libproj found (x.y.z)
+# PROJ_VERSION_MAJOR - The major version of libproj
+# PROJ_VERSION_MINOR - The minor version of libproj
+# PROJ_VERSION_PATCH - The patch version of libproj
+# PROJ_VERSION_TWEAK - always 0
+# PROJ_VERSION_COUNT - The number of version components, always 3
+#
+# Hints
+# ^^^^^
+#
+# A user may set ``PROJ_ROOT`` to a libproj installation root to tell this
+# module where to look exclusively.
+
+#=============================================================================
+# Copyright 2016 Kai Pastor
+#
+#
+# This file was derived from CMake 3.5's module FindZLIB.cmake
+# which has the following terms:
+#
+# Copyright 2001-2011 Kitware, Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# * The names of Kitware, Inc., the Insight Consortium, or the names of
+# any consortium members, or of any contributors, may not be used to
+# endorse or promote products derived from this software without
+# specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+# Search PROJ_ROOT exclusively if it is set.
+if(PROJ_ROOT)
+ set(_PROJ_SEARCH PATHS ${PROJ_ROOT} NO_DEFAULT_PATH)
+else()
+ set(_PROJ_SEARCH)
+endif()
+
+find_path(PROJ_INCLUDE_DIR NAMES proj_api.h ${_PROJ_SEARCH} PATH_SUFFIXES include)
+mark_as_advanced(PROJ_INCLUDE_DIR)
+
+if(PROJ_INCLUDE_DIR AND EXISTS "${PROJ_INCLUDE_DIR}/proj_api.h")
+ file(STRINGS "${PROJ_INCLUDE_DIR}/proj_api.h" PROJ_H REGEX "^#define PJ_VERSION [0-9]+$")
+
+ string(REGEX REPLACE "^.*PJ_VERSION ([0-9]).*$" "\\1" PROJ_VERSION_MAJOR "${PROJ_H}")
+ string(REGEX REPLACE "^.*PJ_VERSION [0-9]([0-9]).*$" "\\1" PROJ_VERSION_MINOR "${PROJ_H}")
+ string(REGEX REPLACE "^.*PJ_VERSION [0-9][0-9]([0-9]).*$" "\\1" PROJ_VERSION_PATCH "${PROJ_H}")
+ set(PROJ_VERSION "${PROJ_VERSION_MAJOR}.${PROJ_VERSION_MINOR}.${PROJ_VERSION_PATCH}")
+ set(PROJ_VERSION_COUNT 3)
+else()
+ find_path(PROJ_INCLUDE_DIR NAMES proj.h ${_PROJ_SEARCH} PATH_SUFFIXES include)
+ mark_as_advanced(PROJ_INCLUDE_DIR)
+
+ if(PROJ_INCLUDE_DIR AND EXISTS "${PROJ_INCLUDE_DIR}/proj.h")
+ file(READ ${PROJ_INCLUDE_DIR}/proj.h proj_version)
+ string(REGEX REPLACE "^.*PROJ_VERSION_MAJOR +([0-9]+).*$" "\\1" PROJ_VERSION_MAJOR "${proj_version}")
+ string(REGEX REPLACE "^.*PROJ_VERSION_MINOR +([0-9]+).*$" "\\1" PROJ_VERSION_MINOR "${proj_version}")
+ string(REGEX REPLACE "^.*PROJ_VERSION_PATCH +([0-9]+).*$" "\\1" PROJ_VERSION_PATCH "${proj_version}")
+ set(PROJ_VERSION "${PROJ_VERSION_MAJOR}.${PROJ_VERSION_MINOR}.${PROJ_VERSION_PATCH}")
+ set(PROJ_VERSION_COUNT 3)
+ endif()
+endif()
+
+# Allow PROJ_LIBRARY to be set manually, as the location of the proj library
+if(NOT PROJ_LIBRARY)
+ set(PROJ_NAMES proj)
+ set(PROJ_NAMES_DEBUG projd)
+ if(WIN32 AND DEFINED PROJ_VERSION_MAJOR AND DEFINED PROJ_VERSION_MINOR)
+ list(APPEND PROJ_NAMES proj_${PROJ_VERSION_MAJOR}_${PROJ_VERSION_MINOR})
+ list(APPEND PROJ_NAMES projd_${PROJ_VERSION_MAJOR}_${PROJ_VERSION_MINOR})
+ endif()
+ find_library(PROJ_LIBRARY_RELEASE NAMES ${PROJ_NAMES} ${_PROJ_SEARCH} PATH_SUFFIXES lib)
+ find_library(PROJ_LIBRARY_DEBUG NAMES ${PROJ_NAMES_DEBUG} ${_PROJ_SEARCH} PATH_SUFFIXES lib)
+ include(SelectLibraryConfigurations)
+ select_library_configurations(PROJ)
+endif()
+
+# handle the QUIETLY and REQUIRED arguments and set PROJ_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(PROJ
+ REQUIRED_VARS
+ PROJ_LIBRARY
+ PROJ_INCLUDE_DIR
+ VERSION_VAR
+ PROJ_VERSION
+)
+
+if(PROJ_FOUND)
+ set(PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIR})
+
+ if(NOT PROJ_LIBRARIES)
+ set(PROJ_LIBRARIES ${PROJ_LIBRARY})
+ endif()
+
+ if(NOT TARGET PROJ::proj)
+ add_library(PROJ::proj UNKNOWN IMPORTED)
+ set_target_properties(PROJ::proj PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${PROJ_INCLUDE_DIRS}")
+
+ if(PROJ_LIBRARY_RELEASE)
+ set_property(TARGET PROJ::proj APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(PROJ::proj PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${PROJ_LIBRARY_RELEASE}")
+ endif()
+
+ if(PROJ_LIBRARY_DEBUG)
+ set_property(TARGET PROJ::proj APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(PROJ::proj PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${PROJ_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT PROJ_LIBRARY_RELEASE AND NOT PROJ_LIBRARY_DEBUG)
+ set_property(TARGET PROJ::proj APPEND PROPERTY
+ IMPORTED_LOCATION "${PROJ_LIBRARY}")
+ endif()
+ endif()
+endif()
|