cmake cant find Qt5

Issue #44 resolved
Виталий Томин created an issue

When I'm trying to build itom on openSUSE 42.1 with qt5 installed I get following output:

#!

cmake .. -DBUILD_WITH_PCL=OFF -DBUILD_QTVERSION=Qt5
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- 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
-- CMake >= 3.0
-- OpenMP found and enabled for release compilation
-- OpenCV components: core
-- CMake >= 3.0
-- OpenMP found and enabled for release compilation
-- CMake >= 3.0
-- OpenMP found and enabled for release compilation
CMake Error at ItomBuildMacros.cmake:172 (MESSAGE):
  Qt5 could not be found on this computer
Call Stack (most recent call first):
  commonQt/CMakeLists.txt:45 (FIND_PACKAGE_QT)


-- OpenCV components: core
-- /home/user/devel/itom/build_debug/commonQt
CMake Error at ItomBuildMacros.cmake:350 (QT4_GET_MOC_FLAGS):
  Unknown CMake command "QT4_GET_MOC_FLAGS".
Call Stack (most recent call first):
  commonQt/CMakeLists.txt:110 (QT4_WRAP_CPP_ITOM)


-- Configuring incomplete, errors occurred!
See also "/home/user/devel/itom/build_debug/CMakeFiles/CMakeOutput.log".

Code that trying to find Qt5 located in ItomBuildMacros.cmake:163 find_package(Qt5 COMPONENTS Core QUIET)

And it works when trying with small hello world project:

CmakeLists.txt

cmake_minimum_required(VERSION 2.8.8)
project(hello-world)

# Tell CMake to run moc when necessary:
set(CMAKE_AUTOMOC ON)
# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt5 COMPONENTS Core QUIET)
message("Qt5 dir:" ${Qt5_DIR})
find_package(Qt5Core QUIET)
message("Qt5 dir:" ${Qt5_DIR})

add_executable(hello_world main.cpp)

qt5_use_modules(hello_world Core)                          

output:

#!
user@linux:~/devel/testcmake/build> cmake ..
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- 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 dir:/usr/lib64/cmake/Qt5
Qt5 dir:/usr/lib64/cmake/Qt5
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/devel/testcmake/build
#!

cmake --version
cmake version 3.3.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
#!

qmake-qt5 --version
QMake version 3.0
Using Qt version 5.5.1 in /usr/lib64

Comments (3)

  1. Виталий Томин reporter

    Issue resolved by adding -DBUILD_TARGET64=ON to cmake line, first I think cmake will detect automagically if it runs on 64bit host.

  2. M. Gronle

    Thanks for the issue and your fix. Since it is also possible to build a 32bit version on a 64bit machine, we decided to add the BUILD_TARGET64 option. However it would be possible to set it to true per default, since 64bit machines will be used more often.

  3. Log in to comment