Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix paths in pkg-config file #556

Merged
merged 1 commit into from
Feb 2, 2018
Merged

Fix paths in pkg-config file #556

merged 1 commit into from
Feb 2, 2018

Conversation

jamiesnape
Copy link
Contributor

@jamiesnape jamiesnape commented Feb 1, 2018

pkg-config should be giving absolute paths rather than relative paths.

Broken by dc9c750 and in 0.6.0. If it would be possible to cut a 0.6.1 release with this fix in it, it would be very much appreciated.

Before:

$ cat yaml-cpp.pc
libdir=lib
includedir=include

Name: Yaml-cpp
Description: A YAML parser and emitter for C++
Version: 0.6.0
Requires:
Libs: -L${libdir} -lyaml-cpp
Cflags: -I${includedir}
$ pkg-config --cflags yaml-cpp 
-Iinclude
$pkg-config --libs yaml-cpp 
-Llib -lyaml-cpp

After (for example with install prefix /usr/local):

$ cat yaml-cpp.pc 
prefix=/usr/local
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib

Name: Yaml-cpp
Description: A YAML parser and emitter for C++
Version: 0.6.0
Requires:
Libs: -L${libdir} -lyaml-cpp
Cflags: -I${includedir}
$ pkg-config --cflags yaml-cpp 
-I/usr/local/include
$ pkg-config --libs yaml-cpp 
-L/usr/local/lib -lyaml-cpp

PTAL @jbeder.

pkg-config should be giving absolute paths rather than relative paths.
@jbeder
Copy link
Owner

jbeder commented Feb 2, 2018

Is there a way to automatically test stuff like this? It would be nice to avoid having these CMake changes breaking things.

@jamiesnape
Copy link
Contributor Author

Something like:

make install
mkdir /tmp/hello_world
cd /tmp/hello_world
cat << 'EOF' > hello_world.cpp
#include <yaml-cpp/yaml.h>
int main() {
  YAML::Node node = YAML::Node("Hello, World!");
  return 0;
}
EOF
$CXX hello_world.cpp -Wall -std=c++11 $(pkg-config --cflags yaml-cpp) $(pkg-config --libs yaml-cpp) -o hello_world_pkg_config
./hello_world_pkg_config

Though possibly that would still compile (with a warning from ld) if the install prefix were /usr/ or /usr/local.

To test cmake you could add something like:

make install
mkdir /tmp/hello_world
cd /tmp/hello_world
cat << 'EOF' > hello_world.cpp
#include <yaml-cpp/yaml.h>
int main() {
  YAML::Node node = YAML::Node("Hello, World!");
  return 0;
}
EOF
cat << 'EOF' > CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(hello_world)
find_package(yaml-cpp REQUIRED)
add_executable(hello_world_cmake hello_world.cpp)
target_link_libraries(hello_world_cmake yaml-cpp)
EOF
cmake .
make
./hello_world_cmake

@jamiesnape jamiesnape deleted the fix-pkg-config branch February 2, 2018 16:25
@jbeder
Copy link
Owner

jbeder commented Feb 2, 2018

I mean automatically; how do I write that test?

@jamiesnape
Copy link
Contributor Author

The quick way would be paste the above into a file my_bash_script, make it executable, and modify .travis.yml:

script:
  - make
  - test/run-tests
  - make install
  - ./my_bash_script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants