Use prefix in mlpack.pc file
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.
Meh, I guess I forgot to bump the package version.
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.
Meh, I guess I forgot to bump the package version.
done
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?
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!
Is there anything else I can do to help close this issue? Thanks!