|
|
3ba0a2a |
Description: Add FindPROJ4.cmake.
|
|
|
3ba0a2a |
Origin: https://salsa.debian.org/debian/openorienteering-mapper/raw/debian/0.8.4-1/cmake/FindPROJ4.cmake
|
|
|
3ba0a2a |
|
|
|
3ba0a2a |
--- /dev/null
|
|
|
3ba0a2a |
+++ b/cmake/Modules/FindPROJ4.cmake
|
|
|
3ba0a2a |
@@ -0,0 +1,152 @@
|
|
|
3ba0a2a |
+#.rst:
|
|
|
3ba0a2a |
+# FindPROJ4
|
|
|
3ba0a2a |
+# --------
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# Find the proj includes and library.
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# IMPORTED Targets
|
|
|
3ba0a2a |
+# ^^^^^^^^^^^^^^^^
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# This module defines :prop_tgt:`IMPORTED` target ``PROJ4::proj``,
|
|
|
3ba0a2a |
+# if Proj.4 has been found.
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# Result Variables
|
|
|
3ba0a2a |
+# ^^^^^^^^^^^^^^^^
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# This module defines the following variables:
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# ::
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# PROJ4_INCLUDE_DIRS - where to find proj_api.h, etc.
|
|
|
3ba0a2a |
+# PROJ4_LIBRARIES - List of libraries when using libproj.
|
|
|
3ba0a2a |
+# PROJ4_FOUND - True if libproj found.
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# ::
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# PROJ4_VERSION - The version of libproj found (x.y.z)
|
|
|
3ba0a2a |
+# PROJ4_VERSION_MAJOR - The major version of libproj
|
|
|
3ba0a2a |
+# PROJ4_VERSION_MINOR - The minor version of libproj
|
|
|
3ba0a2a |
+# PROJ4_VERSION_PATCH - The patch version of libproj
|
|
|
3ba0a2a |
+# PROJ4_VERSION_TWEAK - always 0
|
|
|
3ba0a2a |
+# PROJ4_VERSION_COUNT - The number of version components, always 3
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# Hints
|
|
|
3ba0a2a |
+# ^^^^^
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# A user may set ``PROJ4_ROOT`` to a libproj installation root to tell this
|
|
|
3ba0a2a |
+# module where to look exclusively.
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+#=============================================================================
|
|
|
3ba0a2a |
+# Copyright 2016 Kai Pastor
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# This file was derived from CMake 3.5's module FindZLIB.cmake
|
|
|
3ba0a2a |
+# which has the following terms:
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# Copyright 2001-2011 Kitware, Inc.
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# Redistribution and use in source and binary forms, with or without
|
|
|
3ba0a2a |
+# modification, are permitted provided that the following conditions are
|
|
|
3ba0a2a |
+# met:
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# * Redistributions of source code must retain the above copyright notice,
|
|
|
3ba0a2a |
+# this list of conditions and the following disclaimer.
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
3ba0a2a |
+# this list of conditions and the following disclaimer in the documentation
|
|
|
3ba0a2a |
+# and/or other materials provided with the distribution.
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# * The names of Kitware, Inc., the Insight Consortium, or the names of
|
|
|
3ba0a2a |
+# any consortium members, or of any contributors, may not be used to
|
|
|
3ba0a2a |
+# endorse or promote products derived from this software without
|
|
|
3ba0a2a |
+# specific prior written permission.
|
|
|
3ba0a2a |
+#
|
|
|
3ba0a2a |
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
|
|
|
3ba0a2a |
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
3ba0a2a |
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
3ba0a2a |
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
|
|
|
3ba0a2a |
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
3ba0a2a |
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
3ba0a2a |
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
3ba0a2a |
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
3ba0a2a |
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
3ba0a2a |
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
3ba0a2a |
+#=============================================================================
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+# Search PROJ4_ROOT exclusively if it is set.
|
|
|
3ba0a2a |
+if(PROJ4_ROOT)
|
|
|
3ba0a2a |
+ set(_PROJ4_SEARCH PATHS ${PROJ4_ROOT} NO_DEFAULT_PATH)
|
|
|
3ba0a2a |
+else()
|
|
|
3ba0a2a |
+ set(_PROJ4_SEARCH)
|
|
|
3ba0a2a |
+endif()
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+find_path(PROJ4_INCLUDE_DIR NAMES proj_api.h ${_PROJ4_SEARCH} PATH_SUFFIXES include)
|
|
|
3ba0a2a |
+mark_as_advanced(PROJ4_INCLUDE_DIR)
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+if(PROJ4_INCLUDE_DIR AND EXISTS "${PROJ4_INCLUDE_DIR}/proj_api.h")
|
|
|
3ba0a2a |
+ file(STRINGS "${PROJ4_INCLUDE_DIR}/proj_api.h" PROJ4_H REGEX "^#define PJ_VERSION [0-9]+$")
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+ string(REGEX REPLACE "^.*PJ_VERSION ([0-9]).*$" "\\1" PROJ4_VERSION_MAJOR "${PROJ4_H}")
|
|
|
3ba0a2a |
+ string(REGEX REPLACE "^.*PJ_VERSION [0-9]([0-9]).*$" "\\1" PROJ4_VERSION_MINOR "${PROJ4_H}")
|
|
|
3ba0a2a |
+ string(REGEX REPLACE "^.*PJ_VERSION [0-9][0-9]([0-9]).*$" "\\1" PROJ4_VERSION_PATCH "${PROJ4_H}")
|
|
|
3ba0a2a |
+ set(PROJ4_VERSION "${PROJ4_VERSION_MAJOR}.${PROJ4_VERSION_MINOR}.${PROJ4_VERSION_PATCH}")
|
|
|
3ba0a2a |
+ set(PROJ4_VERSION_COUNT 3)
|
|
|
3ba0a2a |
+endif()
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+# Allow PROJ4_LIBRARY to be set manually, as the location of the proj library
|
|
|
3ba0a2a |
+if(NOT PROJ4_LIBRARY)
|
|
|
3ba0a2a |
+ set(PROJ4_NAMES proj)
|
|
|
3ba0a2a |
+ set(PROJ4_NAMES_DEBUG projd)
|
|
|
3ba0a2a |
+ if(WIN32 AND DEFINED PROJ4_VERSION_MAJOR AND DEFINED PROJ4_VERSION_MINOR)
|
|
|
3ba0a2a |
+ list(APPEND PROJ4_NAMES proj_${PROJ4_VERSION_MAJOR}_${PROJ4_VERSION_MINOR})
|
|
|
3ba0a2a |
+ list(APPEND PROJ4_NAMES projd_${PROJ4_VERSION_MAJOR}_${PROJ4_VERSION_MINOR})
|
|
|
3ba0a2a |
+ endif()
|
|
|
3ba0a2a |
+ find_library(PROJ4_LIBRARY_RELEASE NAMES ${PROJ4_NAMES} ${_PROJ4_SEARCH} PATH_SUFFIXES lib)
|
|
|
3ba0a2a |
+ find_library(PROJ4_LIBRARY_DEBUG NAMES ${PROJ4_NAMES_DEBUG} ${_PROJ4_SEARCH} PATH_SUFFIXES lib)
|
|
|
3ba0a2a |
+ include(SelectLibraryConfigurations)
|
|
|
3ba0a2a |
+ select_library_configurations(PROJ4)
|
|
|
3ba0a2a |
+endif()
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+# handle the QUIETLY and REQUIRED arguments and set PROJ4_FOUND to TRUE if
|
|
|
3ba0a2a |
+# all listed variables are TRUE
|
|
|
3ba0a2a |
+include(FindPackageHandleStandardArgs)
|
|
|
3ba0a2a |
+find_package_handle_standard_args(PROJ4
|
|
|
3ba0a2a |
+ REQUIRED_VARS
|
|
|
3ba0a2a |
+ PROJ4_LIBRARY
|
|
|
3ba0a2a |
+ PROJ4_INCLUDE_DIR
|
|
|
3ba0a2a |
+ VERSION_VAR
|
|
|
3ba0a2a |
+ PROJ4_VERSION
|
|
|
3ba0a2a |
+)
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+if(PROJ4_FOUND)
|
|
|
3ba0a2a |
+ set(PROJ4_INCLUDE_DIRS ${PROJ4_INCLUDE_DIR})
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+ if(NOT PROJ4_LIBRARIES)
|
|
|
3ba0a2a |
+ set(PROJ4_LIBRARIES ${PROJ4_LIBRARY})
|
|
|
3ba0a2a |
+ endif()
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+ if(NOT TARGET PROJ4::proj)
|
|
|
3ba0a2a |
+ add_library(PROJ4::proj UNKNOWN IMPORTED)
|
|
|
3ba0a2a |
+ set_target_properties(PROJ4::proj PROPERTIES
|
|
|
3ba0a2a |
+ INTERFACE_INCLUDE_DIRECTORIES "${PROJ4_INCLUDE_DIRS}")
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+ if(PROJ4_LIBRARY_RELEASE)
|
|
|
3ba0a2a |
+ set_property(TARGET PROJ4::proj APPEND PROPERTY
|
|
|
3ba0a2a |
+ IMPORTED_CONFIGURATIONS RELEASE)
|
|
|
3ba0a2a |
+ set_target_properties(PROJ4::proj PROPERTIES
|
|
|
3ba0a2a |
+ IMPORTED_LOCATION_RELEASE "${PROJ4_LIBRARY_RELEASE}")
|
|
|
3ba0a2a |
+ endif()
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+ if(PROJ4_LIBRARY_DEBUG)
|
|
|
3ba0a2a |
+ set_property(TARGET PROJ4::proj APPEND PROPERTY
|
|
|
3ba0a2a |
+ IMPORTED_CONFIGURATIONS DEBUG)
|
|
|
3ba0a2a |
+ set_target_properties(PROJ4::proj PROPERTIES
|
|
|
3ba0a2a |
+ IMPORTED_LOCATION_DEBUG "${PROJ4_LIBRARY_DEBUG}")
|
|
|
3ba0a2a |
+ endif()
|
|
|
3ba0a2a |
+
|
|
|
3ba0a2a |
+ if(NOT PROJ4_LIBRARY_RELEASE AND NOT PROJ4_LIBRARY_DEBUG)
|
|
|
3ba0a2a |
+ set_property(TARGET PROJ4::proj APPEND PROPERTY
|
|
|
3ba0a2a |
+ IMPORTED_LOCATION "${PROJ4_LIBRARY}")
|
|
|
3ba0a2a |
+ endif()
|
|
|
3ba0a2a |
+ endif()
|
|
|
3ba0a2a |
+endif()
|