Skip to content

Commit

Permalink
gdal.pc generation: use CMAKE_INSTALL_INCLUDEDIR/CMAKE_INSTALL_LIBDIR…
Browse files Browse the repository at this point in the history
… for includedir/libdir (refs #8012)
  • Loading branch information
rouault committed Jul 3, 2023
1 parent b11bb61 commit 9579d8d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions cmake/helpers/GdalGenerateConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,34 @@ function(gdal_generate_config)
endif()
gdal_join_and_quote(CONFIG_LIBS)

# For gdal.pc libdir variable. Not strictly needed, but quite standard
# to have one in a .pc
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
if( "${CMAKE_INSTALL_LIBDIR}" MATCHES "^${CONFIG_PREFIX}.*")
file(RELATIVE_PATH _rel_path "${CONFIG_PREFIX}" "${CMAKE_INSTALL_LIBDIR}")
set(CONFIG_LIBDIR "\${exec_prefix}/${_rel_path}")
else()
set(CONFIG_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
endif()
else()
set(CONFIG_LIBDIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
endif()
gdal_join_and_quote(CONFIG_LIBDIR)

# For gdal.pc includedir variable. Not strictly needed, but quite standard
# to have one in a .pc
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
if( "${CMAKE_INSTALL_INCLUDEDIR}" MATCHES "^${CONFIG_PREFIX}.*")
file(RELATIVE_PATH _rel_path "${CONFIG_PREFIX}" "${CMAKE_INSTALL_INCLUDEDIR}")
set(CONFIG_INCLUDEDIR "\${exec_prefix}/${_rel_path}")
else()
set(CONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
endif()
else()
set(CONFIG_INCLUDEDIR "\${exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()
gdal_join_and_quote(CONFIG_INCLUDEDIR)

get_property(libs GLOBAL PROPERTY "${arg_GLOBAL_PROPERTY}")
if(NOT MSVC AND CMAKE_THREAD_LIBS_INIT)
list(APPEND libs ${CMAKE_THREAD_LIBS_INIT})
Expand Down
4 changes: 2 additions & 2 deletions cmake/template/gdal.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ CONFIG_INST_CFLAGS=@CONFIG_CFLAGS@
CONFIG_INST_DATA=@CONFIG_DATA@
prefix=${CONFIG_INST_PREFIX}
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include
libdir=@CONFIG_LIBDIR@
includedir=@CONFIG_INCLUDEDIR@
datadir=${CONFIG_INST_DATA}

Name: libgdal
Expand Down

0 comments on commit 9579d8d

Please sign in to comment.