Skip to content

Commit

Permalink
CMake: fix gdal.pc and gdal-config generation when CMAKE_INSTALL_xxxx…
Browse files Browse the repository at this point in the history
… is an absolute path (fixes #6004)
  • Loading branch information
rouault committed Jul 5, 2022
1 parent 104e174 commit 2c19601
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmake/helpers/GdalGenerateConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ function(gdal_generate_config)
set(CONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}")
endif()
set(CONFIG_DATA "${CONFIG_PREFIX}/${GDAL_RESOURCE_PATH}")
set(CONFIG_CFLAGS "-I${CONFIG_PREFIX}/${GDAL_INSTALL_INCLUDEDIR}")
set(CONFIG_CFLAGS "-I${GDAL_INSTALL_FULL_INCLUDEDIR}")
gdal_join_and_quote(CONFIG_DATA)
gdal_join_and_quote(CONFIG_CFLAGS)

get_property(target_lib_name TARGET "${arg_TARGET}" PROPERTY OUTPUT_NAME)
set(CONFIG_LIBS "${CMAKE_LINK_LIBRARY_FLAG}${target_lib_name}")
if(NOT CONFIG_PREFIX IN_LIST CMAKE_C_IMPLICIT_LINK_LIBRARIES)
list(INSERT CONFIG_LIBS 0 "${CMAKE_LIBRARY_PATH_FLAG}${CONFIG_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
list(INSERT CONFIG_LIBS 0 "${CMAKE_LIBRARY_PATH_FLAG}${CMAKE_INSTALL_FULL_LIBDIR}")
endif()
gdal_join_and_quote(CONFIG_LIBS)

Expand Down
1 change: 1 addition & 0 deletions gdal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ add_subdirectory(man)

# GDAL 4.0 ? Install headers in ${CMAKE_INSTALL_INCLUDEDIR}/gdal ?
set(GDAL_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
set(GDAL_INSTALL_FULL_INCLUDEDIR ${CMAKE_INSTALL_FULL_INCLUDEDIR})

# So that GDAL can be used as a add_subdirectory() of another project
target_include_directories(
Expand Down

0 comments on commit 2c19601

Please sign in to comment.