I am trying to make the Qt build folder portable so that it can be built on one machine and shared with others. I'm running into an issue on macOS actually using the Qt uic tool in CMake with an error like this:
dyld[74739]: Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore
Referenced from: /path_to_moved_Qt_build_folder/qtbase/bin/uic
Reason: tried: '/path_to_moved_Qt_build_folder/qtbase/bin/../Frameworks/QtCore.framework/Versions/5/QtCore' (no such file), '/original_Qt_build_folder/qtbase/lib/QtCore.framework/Versions/5/QtCore' (no such file)
... (some other paths)
otool -l /path_to_moved_Qt_build_folder/qtbase/bin/uic shows me that the path to the framework in the original Qt build folder is hardcoded. I can get uic to run correctly if I set DYLD_FRAMEWORK_PATH=/path_to_moved_Qt_build_folder/qtbase/lib but I can't get this to work in the actual CMake build. I've tried both of the following:
export DYLD_FRAMEWORK_PATH=/path_to_moved_Qt_build_folder/qtbase/lib cmake --build BUILD --target app
as well as setting the environment in the CMakeLists.txt file:
set(ENV{DYLD_FRAMEWORK_PATH} /path_to_moved_Qt_build_folder/qtbase/lib)
I've also tried setting the Libraries path in qt.conf but this also does not seem to affect how uic runs.
But in both cases when running my build I am getting the original error again. How can I get this variable exported so uic will use it?
Found a solution - for me, CMake is generating a Makefile, so I found that you can pass environment variables to it, for example:
make target FOO=BARIf using CMake itself to build, then do this:
cmake --build BUILD --target target -- FOO=BAR