diff --git a/FindGEOS.cmake b/FindGEOS.cmake index d4708a5..cc99adf 100644 --- a/FindGEOS.cmake +++ b/FindGEOS.cmake @@ -8,14 +8,30 @@ find_path(GEOS_INCLUDE_DIR NAMES geos_c.h /usr/local/include ) -find_library(GEOS_LIBRARIES NAMES geos geos_c +find_library(GEOS_LIBRARIES NAMES geos_c PATHS ${GEOS_PREFIX}/lib - /opt/local/include + /opt/local/lib /usr/lib + /usr/local/lib +) + +find_path(GEOSPP_INCLUDE_DIR NAMES geos/constants.h + PATHS + ${GEOS_PREFIX}/include + /opt/local/include + /usr/include /usr/local/include ) +find_library(GEOSPP_LIBRARIES NAMES geos + PATHS + ${GEOS_PREFIX}/lib + /opt/local/lib + /usr/lib + /usr/local/lib +) + if(GEOS_INCLUDE_DIR AND GEOS_LIBRARIES AND NOT TARGET GEOS) get_filename_component(GEOS_LIBRARY_DIR ${GEOS_LIBRARIES} PATH) set(GEOS_FOUND TRUE) @@ -26,6 +42,16 @@ if(GEOS_INCLUDE_DIR AND GEOS_LIBRARIES AND NOT TARGET GEOS) ) endif() +if(GEOSPP_INCLUDE_DIR AND GEOSPP_LIBRARIES AND NOT TARGET GEOSPP) + get_filename_component(GEOSPP_LIBRARY_DIR ${GEOSPP_LIBRARIES} PATH) + set(GEOSPP_FOUND TRUE) + add_library(GEOS::GeosPP INTERFACE IMPORTED) + set_target_properties(GEOS::GeosPP PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${GEOSPP_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${GEOSPP_LIBRARIES}" + ) +endif() + if(GEOS_FOUND) if(NOT GEOS_FIND_QUIETLY) MESSAGE(STATUS "Found Geos: ${GEOS_LIBRARIES}") @@ -36,3 +62,14 @@ elseif(GEOS_FOUND) message(FATAL_ERROR "Could not find Geos") endif() endif() + +if(GEOSPP_FOUND) + if(NOT GEOSP_FIND_QUIETLY) + MESSAGE(STATUS "Found Geos++: ${GEOSPP_LIBRARIES}") + endif() + set(HAVE_GEOSPP 1) +elseif(GEOSPP_FOUND) + if(GEOSPP_FIND_REQUIRED) + message(FATAL_ERROR "Could not find Geos++") + endif() +endif()