Update FindLibPROJ.cmake from master to set LibPROJ_MAJOR_VERSION

This commit is contained in:
Orion Poplawski 2019-09-12 08:23:55 -06:00
parent a1d022bddf
commit 6911e8921c
2 changed files with 122 additions and 5 deletions

View File

@ -141,3 +141,124 @@
# include <proj_api.h>
# include <geodesic.h>
#else
--- VTK-8.2.0/CMake/FindLibPROJ.cmake 2019-09-11 22:13:29.493741215 -0600
+++ vtk/CMake/FindLibPROJ.cmake 2019-09-11 19:56:57.465802610 -0600
@@ -1,55 +1,67 @@
-# Find LibPROJ library and header file
-# Sets
-# LibPROJ_FOUND to 0 or 1 depending on the result
-# LibPROJ_INCLUDE_DIR to directories required for using libproj4
-# LibPROJ_LIBRARIES to libproj4 and any dependent libraries
-# If LibPROJ_REQUIRED is defined, then a fatal error message will be generated if libproj4 is not found
-
-if ( NOT LibPROJ_INCLUDE_DIR OR NOT LibPROJ_LIBRARIES OR NOT LibPROJ_FOUND )
+find_path(LibPROJ_INCLUDE_DIR
+ NAMES proj_api.h proj.h
+ DOC "libproj include directories")
+mark_as_advanced(LibPROJ_INCLUDE_DIR)
- if ( $ENV{LibPROJ_DIR} )
- file( TO_CMAKE_PATH "$ENV{LibPROJ_DIR}" _LibPROJ_DIR )
+find_library(LibPROJ_LIBRARY_RELEASE
+ NAMES proj
+ DOC "libproj release library")
+mark_as_advanced(LibPROJ_LIBRARY_RELEASE)
+
+find_library(LibPROJ_LIBRARY_DEBUG
+ NAMES projd
+ DOC "libproj debug library")
+mark_as_advanced(LibPROJ_LIBRARY_DEBUG)
+
+include(SelectLibraryConfigurations)
+select_library_configurations(LibPROJ)
+
+if (LibPROJ_INCLUDE_DIR)
+ if (EXISTS "${LibPROJ_INCLUDE_DIR}/proj.h")
+ file(STRINGS "${LibPROJ_INCLUDE_DIR}/proj.h" _libproj_version_lines REGEX "#define[ \t]+PROJ_VERSION_(MAJOR|MINOR|PATCH)")
+ string(REGEX REPLACE ".*PROJ_VERSION_MAJOR *\([0-9]*\).*" "\\1" _libproj_version_major "${_libproj_version_lines}")
+ string(REGEX REPLACE ".*PROJ_VERSION_MINOR *\([0-9]*\).*" "\\1" _libproj_version_minor "${_libproj_version_lines}")
+ string(REGEX REPLACE ".*PROJ_VERSION_PATCH *\([0-9]*\).*" "\\1" _libproj_version_patch "${_libproj_version_lines}")
+ else ()
+ file(STRINGS "${LibPROJ_INCLUDE_DIR}/proj_api.h" _libproj_version_lines REGEX "#define[ \t]+PJ_VERSION")
+ string(REGEX REPLACE ".*PJ_VERSION *\([0-9]*\).*" "\\1" _libproj_version "${_libproj_version_lines}")
+ math(EXPR _libproj_version_major "${_libproj_version} / 100")
+ math(EXPR _libproj_version_minor "(${_libproj_version} % 100) / 10")
+ math(EXPR _libproj_version_patch "${_libproj_version} % 10")
endif ()
-
- set(LibPROJ_LIBRARY_SEARCH_PATHS
- ${_LibPROJ_DIR}
- ${_LibPROJ_DIR}/lib64
- ${_LibPROJ_DIR}/lib
- )
-
- find_library( LibPROJ_LIBRARY_RELEASE
- NAMES proj
- HINTS
- ${LibPROJ_LIBRARY_SEARCH_PATHS}
- )
-
- find_library( LibPROJ_LIBRARY_DEBUG
- NAMES projd
- PATHS
- ${LibPROJ_LIBRARY_SEARCH_PATHS}
- )
-
- find_path( LibPROJ_INCLUDE_DIR
- NAMES proj_api.h proj.h
- HINTS
- ${_LibPROJ_DIR}
- ${_LibPROJ_DIR}/include
- )
-
- include(SelectLibraryConfigurations)
- select_library_configurations(LibPROJ)
-
- include(FindPackageHandleStandardArgs)
- find_package_handle_standard_args(LibPROJ
- REQUIRED_VARS LibPROJ_LIBRARY LibPROJ_INCLUDE_DIR)
-
- if(LibPROJ_FOUND)
- set(LibPROJ_INCLUDE_DIRS ${LibPROJ_INCLUDE_DIR})
-
- if(NOT LibPROJ_LIBRARIES)
- set(LibPROJ_LIBRARIES ${LibPROJ_LIBRARY})
- endif()
- endif()
+ set(LibPROJ_VERSION "${_libproj_version_major}.${_libproj_version_minor}.${_libproj_version_patch}")
+ set(LibPROJ_MAJOR_VERSION "${_libproj_version_major}")
+ unset(_libproj_version_major)
+ unset(_libproj_version_minor)
+ unset(_libproj_version_patch)
+ unset(_libproj_version)
+ unset(_libproj_version_lines)
endif ()
-mark_as_advanced(LibPROJ_INCLUDE_DIR)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LibPROJ
+ REQUIRED_VARS LibPROJ_LIBRARY LibPROJ_INCLUDE_DIR
+ VERSION_VAR LibPROJ_VERSION)
+
+if (LibPROJ_FOUND)
+ set(LibPROJ_INCLUDE_DIRS "${LibPROJ_INCLUDE_DIR}")
+ set(LibPROJ_LIBRARIES "${LibPROJ_LIBRARY}")
+
+ if (NOT TARGET LibPROJ::LibPROJ)
+ add_library(LibPROJ::LibPROJ UNKNOWN IMPORTED)
+ set_target_properties(LibPROJ::LibPROJ PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${LibPROJ_INCLUDE_DIR}")
+ if (LibPROJ_LIBRARY_RELEASE)
+ set_property(TARGET LibPROJ::LibPROJ APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(LibPROJ::LibPROJ PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${LibPROJ_LIBRARY_RELEASE}")
+ endif ()
+ if (LibPROJ_LIBRARY_DEBUG)
+ set_property(TARGET LibPROJ::LibPROJ APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(LibPROJ::LibPROJ PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${LibPROJ_LIBRARY_DEBUG}")
+ endif ()
+ endif ()
+endif ()

View File

@ -631,8 +631,7 @@ export JAVA_TOOL_OPTIONS=-Xmx2048m
%{?vtk_use_system_gl2ps} \\\
-DVTK_USE_SYSTEM_HDF5:BOOL=ON \\\
-DVTK_USE_SYSTEM_LIBHARU=OFF \\\
-DVTK_USE_SYSTEM_NETCDF:BOOL=ON \\\
-DLibPROJ_MAJOR_VERSION=6
-DVTK_USE_SYSTEM_NETCDF:BOOL=ON
# Commented old flags in case we'd like to reactive some of them
# -DVTK_USE_DISPLAY:BOOL=OFF \ # This prevents building of graphics tests
@ -867,7 +866,6 @@ cat xorg.log
%files qt
%{_libdir}/lib*Qt*.so.*
#exclude %{_libdir}/*TCL.so.*
%exclude %{_libdir}/*Python??D.so.*
%{_libdir}/qt?/plugins/designer/libQVTKWidgetPlugin.so
@ -917,7 +915,6 @@ cat xorg.log
%files mpich-qt
%{_libdir}/mpich/lib/lib*Qt*.so.*
#exclude %{_libdir}/mpich/lib/*TCL.so.*
%exclude %{_libdir}/mpich/lib/*Python??D.so.*
%{_libdir}/mpich/lib/qt?/
@ -969,7 +966,6 @@ cat xorg.log
%files openmpi-qt
%{_libdir}/openmpi/lib/lib*Qt*.so.*
#exclude %{_libdir}/openmpi/lib/*TCL.so.*
%exclude %{_libdir}/openmpi/lib/*Python27D.so.*
%{_libdir}/openmpi/lib/qt?/