I am very new to the cross-compiling world, and I am trying to cross compile my cmake project from Linux (specifically Arch) to Windows. I installed mingw-w64-gcc from the Arch repo, and mingw-w64-cmake and other project dependencies for mingw-w64 from the AUR.
Several find_package
calls seem to correctly locate dependencies from the mingw-w64 toolchain. But then I need to find_package(LibXslt)
from my host environment, not from the mingw-w64 environment, because this is a build dependency. The find_package docs indicate that I should add the NO_CMAKE_FIND_ROOT_PATH
option in order to find the package without the CMAKE_FIND_ROOT_PATH
that is set in the toolchain file. But hen using the NO_CMAKE_FIND_ROOT_PATH
option to find_package, cmake complains that it cannot find Gcrypt, which is a dependency of LibXslt.
Running cmake with the –debug-find flag seems to indicate by the following output that it is searching only within the mingw-w64 toolchain for gcrypt and not within my host environment like I intend.
CMake Debug Log at /usr/lib/cmake/libxslt/FindGcrypt.cmake:4 (find_path):
find_path called with the following settings:
VAR: GCRYPT_INCLUDE_DIRS
NAMES: gcrypt.h
Documentation: Path to a file.
Framework
Only Search Frameworks: 0
Search Frameworks Last: 0
Search Frameworks First: 0
AppBundle
Only Search AppBundle: 0
Search AppBundle Last: 0
Search AppBundle First: 0
CMAKE_FIND_USE_CMAKE_PATH: 1
CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1
CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
CMAKE_FIND_USE_INSTALL_PREFIX: 1
find_path considered the following locations:
/usr/x86_64-w64-mingw32/bin/gcrypt.h
/usr/x86_64-w64-mingw32/home/.../.local/bin/gcrypt.h
/usr/x86_64-w64-mingw32/home/.../bin/gcrypt.h
/usr/x86_64-w64-mingw32/usr/local/sbin/gcrypt.h
/usr/x86_64-w64-mingw32/usr/local/bin/gcrypt.h
/usr/x86_64-w64-mingw32/usr/bin/gcrypt.h
/usr/x86_64-w64-mingw32/usr/lib/jvm/default/bin/gcrypt.h
/usr/x86_64-w64-mingw32/usr/bin/site_perl/gcrypt.h
/usr/x86_64-w64-mingw32/usr/bin/vendor_perl/gcrypt.h
/usr/x86_64-w64-mingw32/usr/bin/core_perl/gcrypt.h
/usr/x86_64-w64-mingw32/usr/include/gcrypt.h
/usr/x86_64-w64-mingw32/usr/gcrypt.h
/usr/x86_64-w64-mingw32/include/gcrypt.h
/usr/x86_64-w64-mingw32/gcrypt.h
/usr/x86_64-w64-mingw32/include/gcrypt.h
The item was not found.
Call Stack (most recent call first):
/usr/share/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
/usr/lib/cmake/libxslt/libxslt-config.cmake:77 (find_dependency)
CMakeLists.txt:37 (find_package)
Called from: [4] /usr/lib/cmake/libxslt/FindGcrypt.cmake
[3] /usr/share/cmake/Modules/CMakeFindDependencyMacro.cmake
[2] /usr/lib/cmake/libxslt/libxslt-config.cmake
[1] /home/.../src/lincity-ng/CMakeLists.txt
So how can I find_package
LibXslt from my host environment while cross-compiling? Am I using NO_CMAKE_FIND_ROOT_PATH
improperly?