@@ -10,32 +10,61 @@ find_library (GeographicLib_LIBRARIES
1010 NAMES GeographicLib Geographic
1111 PATHS "${CMAKE_INSTALL_PREFIX} /../GeographicLib/lib" )
1212
13+ find_path (GeographicLib_INCLUDE_DIRS
14+ NAMES GeographicLib/Config.h
15+ PATHS
16+ "${CMAKE_INSTALL_PREFIX} /../GeographicLib/include"
17+ "${CMAKE_INSTALL_PREFIX} /include" )
18+
19+ unset (GeographicLib_LIBRARY_DIRS)
1320if (GeographicLib_LIBRARIES)
1421 get_filename_component (GeographicLib_LIBRARY_DIRS
1522 "${GeographicLib_LIBRARIES} " PATH )
16- get_filename_component (_ROOT_DIR "${GeographicLib_LIBRARY_DIRS} " PATH )
17- set (GeographicLib_INCLUDE_DIRS "${_ROOT_DIR} /include" )
18- set (GeographicLib_BINARY_DIRS "${_ROOT_DIR} /bin" )
19- if (NOT EXISTS "${GeographicLib_INCLUDE_DIRS} /GeographicLib/Config.h" )
20- # On Debian systems the library is in e.g.,
21- # /usr/lib/x86_64-linux-gnu/libGeographic.so
22- # so try stripping another element off _ROOT_DIR
23- get_filename_component (_ROOT_DIR "${_ROOT_DIR} " PATH )
24- set (GeographicLib_INCLUDE_DIRS "${_ROOT_DIR} /include" )
25- set (GeographicLib_BINARY_DIRS "${_ROOT_DIR} /bin" )
26- if (NOT EXISTS "${GeographicLib_INCLUDE_DIRS} /GeographicLib/Config.h" )
27- unset (GeographicLib_INCLUDE_DIRS)
28- unset (GeographicLib_LIBRARIES)
29- unset (GeographicLib_LIBRARY_DIRS)
30- unset (GeographicLib_BINARY_DIRS)
31- endif ()
23+ endif ()
24+
25+ unset (GeographicLib_BINARY_DIRS)
26+ if (GeographicLib_INCLUDE_DIRS)
27+ get_filename_component (_GeographicLib_PREFIX "${GeographicLib_INCLUDE_DIRS} " PATH )
28+ if (EXISTS "${_GeographicLib_PREFIX} /bin" )
29+ set (GeographicLib_BINARY_DIRS "${_GeographicLib_PREFIX} /bin" )
3230 endif ()
33- unset (_ROOT_DIR)
31+ unset (_GeographicLib_PREFIX)
32+ endif ()
33+
34+ if (NOT GeographicLib_BINARY_DIRS)
35+ find_program (_GeographicLib_TOOL
36+ NAMES GeodSolve GeoConvert )
37+ if (_GeographicLib_TOOL)
38+ get_filename_component (GeographicLib_BINARY_DIRS "${_GeographicLib_TOOL} " PATH )
39+ endif ()
40+ unset (_GeographicLib_TOOL CACHE )
41+ unset (_GeographicLib_TOOL)
3442endif ()
3543
3644include (FindPackageHandleStandardArgs )
3745find_package_handle_standard_args (GeographicLib DEFAULT_MSG
3846 GeographicLib_LIBRARY_DIRS GeographicLib_LIBRARIES
3947 GeographicLib_INCLUDE_DIRS)
48+
49+ if (GeographicLib_FOUND)
50+ set (GEOGRAPHICLIB_FOUND TRUE )
51+ endif ()
52+
53+ if (GeographicLib_FOUND AND NOT TARGET GeographicLib::GeographicLib)
54+ # Determine the library type from the file extension so that target
55+ # introspection (get_target_property TYPE) returns the correct value.
56+ if (GeographicLib_LIBRARIES MATCHES "\\ .a$" )
57+ set (_geographiclib_lib_type STATIC)
58+ else ()
59+ set (_geographiclib_lib_type SHARED)
60+ endif ()
61+ add_library (GeographicLib::GeographicLib ${_geographiclib_lib_type} IMPORTED )
62+ set_target_properties (GeographicLib::GeographicLib PROPERTIES
63+ IMPORTED_LOCATION "${GeographicLib_LIBRARIES} "
64+ INTERFACE_INCLUDE_DIRECTORIES "${GeographicLib_INCLUDE_DIRS} "
65+ )
66+ unset (_geographiclib_lib_type)
67+ endif ()
68+
4069mark_as_advanced (GeographicLib_LIBRARY_DIRS GeographicLib_LIBRARIES
4170 GeographicLib_INCLUDE_DIRS )
0 commit comments