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

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

Closed
alexshpilkin opened this issue May 9, 2022 · 2 comments · Fixed by #98
Closed

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

alexshpilkin opened this issue May 9, 2022 · 2 comments · Fixed by #98

Comments

@alexshpilkin
Copy link

As per title: CMakeLists.txt has

  set(prefix ${CMAKE_INSTALL_PREFIX})
  set(exec_prefix "\$\{prefix\}")
  set(libdir "\$\{prefix\}/${CMAKE_INSTALL_LIBDIR}")
  set(includedir "\$\{prefix\}/${CMAKE_INSTALL_INCLUDEDIR}")

and so can’t handle absolute paths in CMAKE_INSTALL_{INCLUDE,LIB}DIR. This leads to a broken .pc file on NixOS in particular.

Identical to Matroska-Org/libmatroska#62. Similar to open-source-parsers/jsoncpp#1199. See “Concatenating paths when building pkg-config files” for a discussion of the problem in a somewhat different context and a suggested fix (I don’t know CMake myself, sorry).

@robUx4
Copy link
Contributor

robUx4 commented May 15, 2022

I tried using cmake_path but cmake being cmake it doesn't work for obscure reasons

  if(${CMAKE_VERSION} VERSION_LESS "3.20.0") 
    set(libdir "\$\{prefix\}/${CMAKE_INSTALL_LIBDIR}")
    set(includedir "\$\{prefix\}/${CMAKE_INSTALL_INCLUDEDIR}")
  else()
    cmake_path(RELATIVE_PATH "${CMAKE_INSTALL_LIBDIR}" BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}" libdir)
    cmake_path(RELATIVE_PATH ${CMAKE_INSTALL_INCLUDEDIR} BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX} includedir)
  endif()
[build] CMake Error at CMakeLists.txt:135 (cmake_path):
[build]   cmake_path RELATIVE_PATH called with unexpected arguments.
[build] 
[build] 
[build] CMake Error at CMakeLists.txt:136 (cmake_path):
[build]   cmake_path RELATIVE_PATH called with unexpected arguments.
[build] 
[build] 

@robUx4
Copy link
Contributor

robUx4 commented May 15, 2022

Apparently it wants variables not paths. Luckily it's already in a variable...

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 a pull request may close this issue.

2 participants