Files
IfcOpenShell/cmake/FindPROJ.cmake
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
2.0 KiB
CMake
Raw Normal View History

2025-12-04 19:15:41 +01:00
#
# 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.
#
2025-12-10 19:55:27 +05:00
# Output targets:
# - `PROJ::proj`
2025-12-04 19:15:41 +01:00
#
# 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)
2025-12-20 13:27:35 +05:00
find_path(PROJ_INCLUDE_DIR proj.h PATHS /usr/include/proj REQUIRED)
2025-12-04 19:15:41 +01:00
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()
2025-12-20 13:27:35 +05:00
find_library(PROJ_LIBRARY NAMES proj PATHS /usr/lib/x86_64-linux-gnu)
2025-12-04 19:15:41 +01:00
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()
2025-12-20 13:27:35 +05:00
find_library(PROJ_LIBRARY NAMES proj PATHS ${PROJ_LIBRARY_DIR})
2025-12-04 19:15:41 +01:00
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()
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})