1
0
Fork 0
mirror of https://github.com/systemed/tilemaker synced 2026-03-20 02:53:00 +01:00
tilemaker/cmake/Findlibshp.cmake
FunMiles 5b6bb37daa
Modernize CMake include and linking resolution. (#555)
* chore: Modernise cmake file.

In modern cmake, linking a target to a library with target_link_libraries
automatically sets the include paths.
This modern approach also resolves issues with transitive dependencies
(e.g. protobuf using abseil).

* chore: Update the required minimum CMake to a lower working value.

* fixed MSVC SQLite3 issue

* Use an alias, avoiding second IF(MSVC)
2023-10-21 19:19:06 +01:00

23 lines
920 B
CMake

# LIBSHP_FOUND - system has the LIBSHP library
# LIBSHP_INCLUDE_DIR - the LIBSHP include directory
# LIBSHP_LIBRARIES - The libraries needed to use LIBSHP
if(LIBSHP_INCLUDE_DIR AND LIBSHP_LIBRARIES)
set(LIBSHP_FOUND TRUE)
else(LIBSHP_INCLUDE_DIR AND LIBSHP_LIBRARIES)
find_path(LIBSHP_INCLUDE_DIR NAMES shapefil.h PATH_SUFFIXES libshp)
find_library(LIBSHP_LIBRARIES NAMES shp shapelib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libshp DEFAULT_MSG LIBSHP_INCLUDE_DIR LIBSHP_LIBRARIES)
mark_as_advanced(LIBSHP_INCLUDE_DIR LIBSHP_LIBRARIES)
endif(LIBSHP_INCLUDE_DIR AND LIBSHP_LIBRARIES)
if (LIBSHP_FOUND)
add_library(shapelib::shp UNKNOWN IMPORTED)
set_target_properties(shapelib::shp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${LIBSHP_INCLUDE_DIR})
set_property(TARGET shapelib::shp APPEND PROPERTY
IMPORTED_LOCATION "${LIBSHP_LIBRARIES}")
endif()