AutowareV2X/cmake/FindGeographicLib.cmake

55 lines
2.5 KiB
CMake
Raw Normal View History

2021-10-27 21:56:21 +00:00
option(GeographicLib_PREFER_PACKAGE_CONFIG "Prefer CMake config mode" ON)
mark_as_advanced(GeographicLib_PREFER_PACKAGE_CONFIG)
if(GeographicLib_PREFER_PACKAGE_CONFIG)
find_package(GeographicLib ${GeographicLib_FIND_VERSION} QUIET CONFIG)
if (GeographicLib_FOUND)
message(STATUS "GeographicLib: using found CMake configuration")
return()
endif()
endif()
message(STATUS "GeographicLib: using lookup code by Vanetza")
find_path(GeographicLib_INCLUDE_DIR NAMES GeographicLib/Config.h DOC "GeographicLib include directory")
find_library(GeographicLib_LIBRARY_RELEASE NAMES Geographic DOC "GeographicLib library (release)")
find_library(GeographicLib_LIBRARY_DEBUG NAMES Geographic_d DOC "GeographicLib library (debug)")
include(SelectLibraryConfigurations)
select_library_configurations(GeographicLib)
if(GeographicLib_INCLUDE_DIR)
file(STRINGS ${GeographicLib_INCLUDE_DIR}/GeographicLib/Config.h _config_version REGEX "GEOGRAPHICLIB_VERSION_STRING")
string(REGEX MATCH "\"([0-9.]+)\"$" _match_version ${_config_version})
set(GeographicLib_VERSION_STRING ${CMAKE_MATCH_1})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GeographicLib
REQUIRED_VARS GeographicLib_INCLUDE_DIR GeographicLib_LIBRARY
FOUND_VAR GeographicLib_FOUND
VERSION_VAR GeographicLib_VERSION_STRING)
if(GeographicLib_FOUND AND NOT TARGET GeographicLib::GeographicLib)
add_library(GeographicLib::GeographicLib UNKNOWN IMPORTED)
set_target_properties(GeographicLib::GeographicLib PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${GeographicLib_INCLUDE_DIR}"
IMPORTED_LOCATION "${GeographicLib_LIBRARY}"
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
if(EXISTS "${GeographicLib_LIBRARY_RELEASE}")
set_property(TARGET GeographicLib::GeographicLib APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(GeographicLib::GeographicLib PROPERTIES
IMPORTED_LOCATION_RELEASE "${GeographicLib_LIBRARY_RELEASE}")
endif()
if(EXISTS "${GeographicLib_LIBRARY_DEBUG}")
set_property(TARGET GeographicLib::GeographicLib APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(GeographicLib::GeographicLib PROPERTIES
IMPORTED_LOCATION_DEBUG "${GeographicLib_LIBRARY_DEBUG}")
endif()
endif()
mark_as_advanced(GeographicLib_INCLUDE_DIR GeographicLib_LIBRARY)
set(GeographicLib_INCLUDE_DIRS ${GeographicLib_INCLUDE_DIR})
# GeographicLib_LIBRARIES is set by SelectLibraryConfigurations