Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. CMAKE_PREFIX_PATH does not work as expected
Forum Updated to NodeBB v4.3 + New Features

CMAKE_PREFIX_PATH does not work as expected

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 3 Posters 25.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Ahmed Yarub Hani Al NuaimiA Ahmed Yarub Hani Al Nuaimi

    Tried doing it like this:

    cmake -DCMAKE_TOOLCHAIN_FILE=~/Documents/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_PREFIX_PATH=~/Qt/5.15.0/wasm_32/lib/cmake ~/Documents/cpp/basic_qml
    

    Still had the same error:

    CMake Error at CMakeLists.txt:10 (find_package):
      By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
      asked CMake to find a package configuration file provided by "Qt5", but
      CMake did not find one.
    
      Could not find a package configuration file provided by "Qt5" with any of
      the following names:
    
        Qt5Config.cmake
        qt5-config.cmake
    
      Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
      to a directory containing one of the above files.  If "Qt5" provides a
      separate development package or SDK, be sure it has been installed.
    
    
    -- Configuring incomplete, errors occurred!
    
    JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by JoeCFD
    #4

    @Ahmed-Yarub-Hani-Al-Nuaimi On linux, add QT_DIR/bin to PATH and QT_DIR/lib to LD_LIBRARY_PATH and cmake is able to find it. For example: QT_DIR=/opt/thirdParties/Qt-5.14/5.14.0/gcc_64/

    Ahmed Yarub Hani Al NuaimiA 1 Reply Last reply
    0
    • JoeCFDJ JoeCFD

      @Ahmed-Yarub-Hani-Al-Nuaimi On linux, add QT_DIR/bin to PATH and QT_DIR/lib to LD_LIBRARY_PATH and cmake is able to find it. For example: QT_DIR=/opt/thirdParties/Qt-5.14/5.14.0/gcc_64/

      Ahmed Yarub Hani Al NuaimiA Offline
      Ahmed Yarub Hani Al NuaimiA Offline
      Ahmed Yarub Hani Al Nuaimi
      wrote on last edited by
      #5

      @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!

      JoeCFDJ 2 Replies Last reply
      0
      • Ahmed Yarub Hani Al NuaimiA Offline
        Ahmed Yarub Hani Al NuaimiA Offline
        Ahmed Yarub Hani Al Nuaimi
        wrote on last edited by Ahmed Yarub Hani Al Nuaimi
        #6

        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")

        1 Reply Last reply
        1
        • Ahmed Yarub Hani Al NuaimiA Ahmed Yarub Hani Al Nuaimi

          @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!

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by JoeCFD
          #7

          @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_PATH

          if 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 NuaimiA 1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            @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_PATH

            if 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 NuaimiA Offline
            Ahmed Yarub Hani Al NuaimiA Offline
            Ahmed Yarub Hani Al Nuaimi
            wrote on last edited by
            #8

            @JoeCFD I tried that and didn't work. I'm doing a cross-compilation for WebAssembly on Ubuntu.

            JoeCFDJ 1 Reply Last reply
            0
            • Ahmed Yarub Hani Al NuaimiA Ahmed Yarub Hani Al Nuaimi

              @JoeCFD I tried that and didn't work. I'm doing a cross-compilation for WebAssembly on Ubuntu.

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by JoeCFD
              #9

              @Ahmed-Yarub-Hani-Al-Nuaimi show me your CMakeLists.txt
              show me the output of
              echo $PATH
              echo $LD_LIBRARY_PATH

              1 Reply Last reply
              0
              • Ahmed Yarub Hani Al NuaimiA Offline
                Ahmed Yarub Hani Al NuaimiA Offline
                Ahmed Yarub Hani Al Nuaimi
                wrote on last edited by
                #10

                Here you go:
                https://github.com/ahmedyarub/basic_qml/blob/master/CMakeLists.txt

                1 Reply Last reply
                0
                • Ahmed Yarub Hani Al NuaimiA Ahmed Yarub Hani Al Nuaimi

                  @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!

                  JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on last edited by
                  #11

                  @Ahmed-Yarub-Hani-Al-Nuaimi Try to use full path of ~/Qt/5.15.0/wasm_32 to set PATH and LD_LIBRARY_PATH

                  Ahmed Yarub Hani Al NuaimiA 1 Reply Last reply
                  0
                  • JoeCFDJ JoeCFD

                    @Ahmed-Yarub-Hani-Al-Nuaimi Try to use full path of ~/Qt/5.15.0/wasm_32 to set PATH and LD_LIBRARY_PATH

                    Ahmed Yarub Hani Al NuaimiA Offline
                    Ahmed Yarub Hani Al NuaimiA Offline
                    Ahmed Yarub Hani Al Nuaimi
                    wrote on last edited by
                    #12

                    @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/.bin

                    echo $LD_LIBRARY_PATH
                    /home/fifothekid/Qt/5.15.0/wasm_32/lib/

                    and then tried /home/fifothekid/Qt/5.15.0/wasm_32

                    JoeCFDJ 1 Reply Last reply
                    0
                    • Ahmed Yarub Hani Al NuaimiA Ahmed Yarub Hani Al Nuaimi

                      @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/.bin

                      echo $LD_LIBRARY_PATH
                      /home/fifothekid/Qt/5.15.0/wasm_32/lib/

                      and then tried /home/fifothekid/Qt/5.15.0/wasm_32

                      JoeCFDJ Offline
                      JoeCFDJ Offline
                      JoeCFD
                      wrote on last edited by JoeCFD
                      #13

                      @Ahmed-Yarub-Hani-Al-Nuaimi type
                      which qmake

                      this 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)

                      1 Reply Last reply
                      0
                      • Ahmed Yarub Hani Al NuaimiA Offline
                        Ahmed Yarub Hani Al NuaimiA Offline
                        Ahmed Yarub Hani Al Nuaimi
                        wrote on last edited by
                        #14

                        which qmake
                        /home/fifothekid/Qt/5.15.0/wasm_32/bin//qmake

                        JoeCFDJ 1 Reply Last reply
                        0
                        • Ahmed Yarub Hani Al NuaimiA Ahmed Yarub Hani Al Nuaimi

                          which qmake
                          /home/fifothekid/Qt/5.15.0/wasm_32/bin//qmake

                          JoeCFDJ Offline
                          JoeCFDJ Offline
                          JoeCFD
                          wrote on last edited by
                          #15

                          @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:

                          1 Reply Last reply
                          0
                          • Ahmed Yarub Hani Al NuaimiA Offline
                            Ahmed Yarub Hani Al NuaimiA Offline
                            Ahmed Yarub Hani Al Nuaimi
                            wrote on last edited by
                            #16

                            Are you cross-compiling for wasm32?

                            JoeCFDJ 1 Reply Last reply
                            0
                            • Ahmed Yarub Hani Al NuaimiA Ahmed Yarub Hani Al Nuaimi

                              Are you cross-compiling for wasm32?

                              JoeCFDJ Offline
                              JoeCFDJ Offline
                              JoeCFD
                              wrote on last edited by
                              #17

                              @Ahmed-Yarub-Hani-Al-Nuaimi this is only on linux ubuntu

                              1 Reply Last reply
                              0
                              • Ahmed Yarub Hani Al NuaimiA Offline
                                Ahmed Yarub Hani Al NuaimiA Offline
                                Ahmed Yarub Hani Al Nuaimi
                                wrote on last edited by
                                #18

                                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.

                                JoeCFDJ 1 Reply Last reply
                                0
                                • Ahmed Yarub Hani Al NuaimiA Ahmed Yarub Hani Al Nuaimi

                                  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.

                                  JoeCFDJ Offline
                                  JoeCFDJ Offline
                                  JoeCFD
                                  wrote on last edited by JoeCFD
                                  #19

                                  @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.

                                  1 Reply Last reply
                                  0
                                  • Ahmed Yarub Hani Al NuaimiA Offline
                                    Ahmed Yarub Hani Al NuaimiA Offline
                                    Ahmed Yarub Hani Al Nuaimi
                                    wrote on last edited by
                                    #20

                                    Can you try compiling for wasm32?

                                    JoeCFDJ 1 Reply Last reply
                                    0
                                    • Ahmed Yarub Hani Al NuaimiA Ahmed Yarub Hani Al Nuaimi

                                      Can you try compiling for wasm32?

                                      JoeCFDJ Offline
                                      JoeCFDJ Offline
                                      JoeCFD
                                      wrote on last edited by
                                      #21

                                      @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.

                                      1 Reply Last reply
                                      0

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved