MINGW-packages icon indicating copy to clipboard operation
MINGW-packages copied to clipboard

Use prefix in mlpack.pc file

Open giraldeau opened this issue 3 years ago • 6 comments

The paths inside mlpack.pc should use the prefix variable, that pkg-config uses to make the library relocatable.

Tested with the small project: https://github.com/giraldeau/mingw-mlpack-issue-20220708/tree/fix-find-package

  • Error message on configuration of test project:
CMake Error in CMakeLists.txt:
  Imported target "PkgConfig::MLPACK_PKG" includes non-existent path

    "D:/a/msys64/mingw64/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.
  • Current situation inside /mingw64/lib/pkgconfig/mlpack.pc
Name: mlpack
Description: scalable C++ machine learning library
URL: http://www.mlpack.org/
Version: 3.4.2
Cflags:  -ID:/a/msys64/mingw64/include -ID:/a/msys64/mingw64/include/stb/ -I/mingw64/include/
Libs: -LD:/a/msys64/mingw64/lib -lD:/a/msys64/mingw64/lib/libarmadillo.dll.a -lD:/a/msys64/mingw64/lib/libboost_unit_test_framework-mt.dll.a -lD:/a/msys64/mingw64/lib/libboost_serialization-mt.dll.a -L/mingw64/lib/ -lmlpack

  • With this patch:
Name: mlpack
Description: scalable C++ machine learning library
URL: http://www.mlpack.org/

prefix="/mingw64"
exec_prefix="${prefix}"
libdir="${exec_prefix}/lib"
includedir="${prefix}/include"

Version: 3.4.2
CFlags: -I${includedir} -I${includedir}/stb
Libs: -L${libdir} -larmadillo -lboost_unit_test_framework-mt -lboost_serialization-mt -lmlpack

This patch works only with MinGW and is not portable or suitable for upstream.

Note: the mlpack-target.cmake file is also wrong, but I need more time to find a solution.

giraldeau avatar Jul 11 '22 19:07 giraldeau

Meh, I guess I forgot to bump the package version.

giraldeau avatar Jul 11 '22 20:07 giraldeau

OK, the file mlpack-targets.cmake is fixed now. I just reused the same sed commands after the install command as done for the SuperLU package.

  • Before:
set_target_properties(mlpack::mlpack PROPERTIES
  INTERFACE_COMPILE_FEATURES "cxx_decltype;cxx_alias_templates;cxx_auto_type;cxx_lambdas;cxx_constexpr;cxx_rvalue_references;cxx_static_assert;cxx_template_template_parameters;cxx_delegating_constructors;cxx_variadic_templates;cxx_nullptr;cxx_noexcept"
  INTERFACE_LINK_LIBRARIES "D:/a/msys64/mingw64/lib/libarmadillo.dll.a;D:/a/msys64/mingw64/lib/libboost_unit_test_framework-mt.dll.a;D:/a/msys64/mingw64/lib/libboost_serialization-mt.dll.a"
)
  • With this patch:
set_target_properties(mlpack::mlpack PROPERTIES
  INTERFACE_COMPILE_FEATURES "cxx_decltype;cxx_alias_templates;cxx_auto_type;cxx_lambdas;cxx_constexpr;cxx_rvalue_references;cxx_static_assert;cxx_template_template_parameters;cxx_delegating_constructors;cxx_variadic_templates;cxx_nullptr;cxx_noexcept"
  INTERFACE_LINK_LIBRARIES "${_IMPORT_PREFIX}/lib/libarmadillo.dll.a;${_IMPORT_PREFIX}/lib/libboost_unit_test_framework-mt.dll.a;${_IMPORT_PREFIX}/lib/libboost_serialization-mt.dll.a"
)

I confirm that the test project now works with both -DUSE_PKG_CONFIG=ON and -DUSE_PKG_CONFIG=OFF.

giraldeau avatar Jul 11 '22 21:07 giraldeau

Meh, I guess I forgot to bump the package version.

done

giraldeau avatar Jul 11 '22 21:07 giraldeau

Notice that the MINGW32 build fails because of OOM event:

  cc1plus.exe: out of memory allocating 380288 bytes

Maybe reducing the number of concurrent threads might solve the issue?

giraldeau avatar Jul 12 '22 13:07 giraldeau

Hello @Biswa96, when working on #12019 I had issue using find_package() to use the mlpack library. This MR is a fix for both pkg-config and CMake target files. Could you review the patch? Your comments are welcome and I can make adjustments if necessary. Thanks!

giraldeau avatar Jul 14 '22 13:07 giraldeau

Is there anything else I can do to help close this issue? Thanks!

giraldeau avatar Sep 12 '22 13:09 giraldeau