cmake: Use correct proj target

See-Also: https://proj.org/en/stable/development/cmake.html
This commit is contained in:
Esteban DUGUEPEROUX
2025-12-04 19:15:41 +01:00
committed by Thomas Krijnen
parent c32a6dc0ca
commit d566ba6e1f
3 changed files with 67 additions and 4 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ else()
set(CGAL_Boost_USE_STATIC_LIBS "${Boost_USE_STATIC_LIBS}")
endif()
find_package(CGAL CONFIG)
if(NOT CGAL::CGAL)
if(NOT CGAL_FOUND)
message(
FATAL_ERROR
"CGAL_SUPPORT enabled, but CGAL_INCLUDE_DIR wasn't provided and CGAL package couldn't be found."
@@ -56,5 +56,5 @@ else()
message(STATUS "CGAL: found config at '${CGAL_DIR}'.")
endif()
target_compile_definitions(CGAL::CGAL INTERFACE IFOPSH_WITH_CGAL)
target_compile_definitions(CGAL INTERFACE IFOPSH_WITH_CGAL)
set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_CGAL)
+63
View File
@@ -0,0 +1,63 @@
#
# Input variables:
# - `PROJ_INCLUDE_DIR`
# - `PROJ_LIBRARIES`
# If input variables are not specified, try to find PROJ config.
# Input variables could also be provided as environment variables.
#
# Output variables:
# - `PROJ_INCLUDE_DIR`
# - `PROJ_LIBRARIES`
#
# To avoid cyclic calls to this file
list(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
UNIFY_ENVVARS_AND_CACHE(PROJ_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(PROJ_LIBRARIES)
if((NOT PROJ_INCLUDE_DIR AND NOT PROJ_LIBRARIES))
find_package(PROJ QUIET CONFIG)
if(NOT PROJ_FOUND)
find_path(PROJ_INCLUDE_DIR proj.h
PATHS
/usr/include/proj
REQUIRED
)
if(PROJ_INCLUDE_DIR)
message(STATUS "Found PROJ include files in: ${PROJ_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Unable to find PROJ include directory, specify PROJ_INCLUDE_DIR manually.")
endif()
find_library(PROJ_LIBRARY
NAMES proj
PATHS /usr/lib/x86_64-linux-gnu)
if(PROJ_LIBRARY)
message(STATUS "PROJ libraries ${PROJ_LIBRARY} found in: ${PROJ_LIBRARY_DIR}")
set(PROJ_LIBRARIES ${PROJ_LIBRARY})
else()
message(FATAL_ERROR "Unable to find PROJ libraries in: ${PROJ_LIBRARY_DIR}")
endif()
add_library(PROJ::proj INTERFACE IMPORTED)
target_include_directories(PROJ::proj INTERFACE "${PROJ_INCLUDE_DIR}")
target_link_libraries(PROJ::proj INTERFACE ${PROJ_LIBRARIES})
target_link_directories(PROJ::proj INTERFACE "${PROJ_LIBRARY}")
endif()
else()
find_library(PROJ_LIBRARY
NAMES proj
PATHS ${PROJ_LIBRARY_DIR})
if(PROJ_LIBRARY)
message(STATUS "PROJ libraries ${PROJ_LIBRARY} found in: ${PROJ_LIBRARY_DIR}")
set(PROJ_LIBRARIES ${PROJ_LIBRARY})
else()
message(FATAL_ERROR "Unable to find PROJ libraries in: ${PROJ_LIBRARY_DIR}")
endif()
set(PROJ_INCLUDE_DIR ${PROJ_INCLUDE_DIR} CACHE FILEPATH "PROJ header files")
message(STATUS "Looking for PROJ include files in: ${PROJ_INCLUDE_DIR}")
include_directories(${PROJ_INCLUDE_DIR})
endif()
+2 -2
View File
@@ -9,12 +9,12 @@ set_target_properties(Serializers PROPERTIES COMPILE_FLAGS "-DSERIALIZERS_EXPORT
set(SERIALIZER_SCHEMA_LIBRARIES Serializers ${SERIALIZER_SCHEMA_LIBRARIES} PARENT_SCOPE)
if(WITH_PROJ)
find_package(proj REQUIRED)
find_package(PROJ REQUIRED)
target_compile_definitions(Serializers PRIVATE "WITH_PROJ")
if(PROJ_STATIC)
target_compile_definitions(Serializers PRIVATE "PROJ_DLL=")
endif()
target_link_libraries(Serializers PRIVATE proj::proj)
target_link_libraries(Serializers PRIVATE PROJ::proj)
endif()
target_link_libraries(Serializers