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