Skip to content

keep the path for pkg-config path if they are absolute#98

Merged
mbunkus merged 1 commit intomasterfrom
pkc-config-absolute
May 22, 2022
Merged

keep the path for pkg-config path if they are absolute#98
mbunkus merged 1 commit intomasterfrom
pkc-config-absolute

Conversation

@robUx4
Copy link
Copy Markdown
Contributor

@robUx4 robUx4 commented May 15, 2022

Fixes #97

@mbunkus
Copy link
Copy Markdown
Contributor

mbunkus commented May 15, 2022

This doesn't seem to work for me. I'm running cmake 3.23.1 with the following:

[0 mosu@sweet-chili (pkc-config-absolute) ~/prog/video/libebml] mkdir build
[0 mosu@sweet-chili (pkc-config-absolute) ~/prog/video/libebml] cd build
[0 mosu@sweet-chili (pkc-config-absolute) ~/prog/video/libebml/build] cmake -DCMAKE_INSTALL_PREFIX=$HOME/opt/ebmlmatroska -DCMAKE_INSTALL_INCLUDEDIR=$HOME/opt/ebmlmatroska/include -DCMAKE_INSTALL_LIBDIR=$HOME/opt/ebmlmatroska/lib -DBUILD_SHARED_LIBS=no ..
…
[0 mosu@sweet-chili (pkc-config-absolute) ~/prog/video/libebml/build] make
…
[0 mosu@sweet-chili (pkc-config-absolute) ~/prog/video/libebml/build] make install
…
[0 mosu@sweet-chili (pkc-config-absolute) ~/prog/video/libebml/build] cat ~/opt/ebmlmatroska/lib/pkgconfig/libebml.pc
prefix=/home/mosu/opt/ebmlmatroska
exec_prefix=${prefix}
libdir=${prefix}//home/mosu/opt/ebmlmatroska/lib
includedir=${prefix}//home/mosu/opt/ebmlmatroska/include

Name:        libebml
Description: Library for parsing EBML data structures
Version:     1.4.2
Libs:        -L${libdir} -lebml
Cflags:      -I${includedir}  -DEBML_STATIC_DEFINE
[0 mosu@sweet-chili (pkc-config-absolute) ~/prog/video/libebml/build]

@robUx4
Copy link
Copy Markdown
Contributor Author

robUx4 commented May 15, 2022

Maybe a bug in cmake_path(IS_ABSOLUTE) ? It might read the variable as $HOME/opt/ebmlmatroska/lib (rather than /home/mosu/opt/ebmlmatroska/lib) and assume it's not an absolute path.

Can you try with this ?

    set(PKG_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
    set(PKG_INCDIR "${CMAKE_INSTALL_INCLUDEDIR}")
    cmake_path(IS_ABSOLUTE PKG_LIBDIR abs_libdir)
    cmake_path(IS_ABSOLUTE PKG_INCDIR abs_incdir)

@mbunkus
Copy link
Copy Markdown
Contributor

mbunkus commented May 15, 2022

That makes no difference. And it shouldn't, as the shell already expands $HOME to /home/mosu, meaning my invocation is identical to

cmake -DCMAKE_INSTALL_PREFIX=/home/mosu/opt/ebmlmatroska -DCMAKE_INSTALL_INCLUDEDIR=/home/mosu/opt/ebmlmatroska/include -DCMAKE_INSTALL_LIBDIR=/home/mosu/opt/ebmlmatroska/lib -DBUILD_SHARED_LIBS=no ..

@robUx4 robUx4 force-pushed the pkc-config-absolute branch from 04dc9ea to 83d30f0 Compare May 15, 2022 12:21
@robUx4
Copy link
Copy Markdown
Contributor Author

robUx4 commented May 15, 2022

I tried this updated script with older cmake and 3.22.1 (Ubuntu 22.04) and they both work (using absolute path when the path given is absolute, by default the values are not absolute).

@robUx4 robUx4 force-pushed the pkc-config-absolute branch from 83d30f0 to 42fbae3 Compare May 15, 2022 15:48
@robUx4 robUx4 requested a review from mbunkus May 22, 2022 05:31
Copy link
Copy Markdown
Contributor

@mbunkus mbunkus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variant works well for me now, both with an absolute path & without specifying the paths at all. Thanks!

@mbunkus mbunkus merged commit b5ba93c into master May 22, 2022
@mbunkus mbunkus deleted the pkc-config-absolute branch May 22, 2022 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg-config file is broken when CMAKE_INSTALL_{INCLUDE,LIB}DIR is absolute

3 participants