CMAKE_PREFIX_PATH does not work as expected
-
@JoeCFD said in CMAKE_PREFIX_PATH does not work as expected:
LD_LIBRARY_PATH
export PATH=~/Qt/5.15.0/wasm_32/bin/:$PATH which qmake ~/Qt/5.15.0/wasm_32/bin//qmake export LD_LIBRARY_PATH=~/Qt/5.15.0/wasm_32/lib/
Still had the error.
It does mention here https://doc.qt.io/qt-5.15/cmake-get-started.html clearly:Set your CMAKE_PREFIX_PATH environment variable to the Qt 5 installation prefix. This is the recommended way.
Still, I could not find anybody who could get it working using this variable on Linux!
-
I could solve the problem by adding this to the beginning of my CMake script:
list(APPEND CMAKE_PREFIX_PATH "~/Qt/5.15.0/wasm_32")
Neither passing it as a command-line parameter nor as an env variable worked.Now I'm sure that I found it:
The toolchains had this:
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)It doesn't look like setting CMAKE_PREFIX_PATH was enough. I had to do this also:
list(APPEND CMAKE_FIND_ROOT_PATH "~/Qt/5.15.0/wasm_32") -
@Ahmed-Yarub-Hani-Al-Nuaimi you can find cmake is inside lib dir of qt installation: /opt/thirdParties/Qt-5.14/5.14.0/gcc_64/lib/cmake. Therefore, add QT_DIR/bin to PATH and
QT_DIR/lib to LD_LIBRARY_PATHif you can not make it manually, use cmake-gui to add it manually. It can detected it automatically from Qt lib path setting. When you install cmake, there is an option to add cmake-gui which is very useful for you to install packages.
-
@Ahmed-Yarub-Hani-Al-Nuaimi show me your CMakeLists.txt
show me the output of
echo $PATH
echo $LD_LIBRARY_PATH -
-
@Ahmed-Yarub-Hani-Al-Nuaimi Try to use full path of ~/Qt/5.15.0/wasm_32 to set PATH and LD_LIBRARY_PATH
-
@JoeCFD
echo $PATH
/home/fifothekid/Downloads/cmake-3.18.0-Linux-x86_64/bin:/home/fifothekid/Qt/5.15.0/wasm_32/bin/:/home/fifothekid/.wasmer/bin:/home/fifothekid/.wasienv/bin:/home/fifothekid/Documents/emsdk:/home/fifothekid/Documents/emsdk/upstream/emscripten:/home/fifothekid/Documents/emsdk/node/12.18.1_64bit/bin:/home/fifothekid/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/fifothekid/.wasmer/globals/wapm_packages/.binecho $LD_LIBRARY_PATH
/home/fifothekid/Qt/5.15.0/wasm_32/lib/and then tried /home/fifothekid/Qt/5.15.0/wasm_32
-
@Ahmed-Yarub-Hani-Al-Nuaimi type
which qmakethis is the only line in my cmake file to find Qt 5
find_package(Qt5 REQUIRED Core Gui Widgets Svg Xml Network DBus OpenGL Multimedia WebEngineWidgets) -
which qmake
/home/fifothekid/Qt/5.15.0/wasm_32/bin//qmake -
@Ahmed-Yarub-Hani-Al-Nuaimi
I tried this
cmake_minimum_required(VERSION 3.10)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
project(basic_qml)set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)set(CMAKE_CXX_STANDARD 17)
set (Qt5_FOUND false)
find_package(Qt5 COMPONENTS Core
Gui
Svg
Xml
Qml
Quick
QuickControls2 REQUIRED)if(Qt5_FOUND)
message("QT5 framework found")
else(Qt5_FOUND)
message(FATAL_ERROR "No QT5 framework found")
endif(Qt5_FOUND)==========================================================
the output:
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
QT5 framework found
-- Configuring done
-- Generating done
-- Build files have been written to: -
Are you cross-compiling for wasm32?
-
@Ahmed-Yarub-Hani-Al-Nuaimi this is only on linux ubuntu
-
I know. It does work if you are building for Ubuntu on Ubuntu. It's cross-compilation that doesn't work. According to official documentations, setting CMAKE_PREFIX_PATH should be enough, but it's not.
I had the same problem compiling for Android on Ubuntu and Windows, for iOS on MacOS, and for WebAssembly on Ubuntu. -
@Ahmed-Yarub-Hani-Al-Nuaimi
cmake -DCMAKE_PREFIX_PATH=$QT_DIR/lib/cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
QT5 framework found
-- Configuring done
-- Generating done
-- Build files have been written to:works as well without PATH and LIB settings. But this does not set qmake path. It is safe to set path and lib manually. Sure it is not needed if you install qt under root.
-
Can you try compiling for wasm32?
-
@Ahmed-Yarub-Hani-Al-Nuaimi I only confirmed that Qt 5 can be found. If it can be found, you will be able to compile it.