I'm trying to generate the build configuration from a simple example in Qt using CMake. The example code is this:
#include <QApplication>
#include <QTextEdit>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QTextEdit textEdit;
textEdit.setText("Olá mundo!");
textEdit.show();
return app.exec();
}
And the CMake configuration file is this:
cmake_minimum_required(VERSION 2.8.11)
project (teste)
# Configuracao do Qt
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Core)
find_package(Qt5Widgets)
# Configuracao especifica para o gcc
if(NOT WIN32)
set(CMAKE_C_FLAGS "-Wall -g")
endif()
# Adiciona todos os fontes na variavel SRCS
file(GLOB SRCS *.cpp *.h)
# Nome do executavel
if(WIN32)
add_executable(teste WIN32 ${SRCS})
else()
add_executable(teste ${SRCS})
endif()
# Usa os modulos do Qt 5
target_link_libraries(teste Qt5::Core)
target_link_libraries(teste Qt5::Widgets)
When I build the configuration in Windows (v.10, 64bits), it works fine. However, when I do the same in Ubuntu (v.14.04, 32bits), CMake produces the following error message:
CMake Warning at CMakeLists.txt: 8 (find_package): By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Core", but CMake did not find one.
Could not find a package configuration file provided by "Qt5Core" with any of the following names:
Qt5CoreConfig.cmake qt5core-config.cmake
Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set "Qt5Core_DIR" to a directory containing one of the above files. If "Qt5Core" provides a separate development package or SDK, be sure it has been installed.
Some additional information:
- Qt 5.5.1 is properly installed on Ubuntu (in the local
/home/luiz/Qt5.5.1
folder). - Running the
apt-file search Qt5CoreConfig.cmake
command, I get the following path:qtbase5-dev: /usr/lib/i386-linux-gnu/cmake/Qt5Core/Qt5CoreConfig.cmake
. So I've already tried to add/usr/lib/i386-linux-gnu/cmake/
to the environment variableCMAKE_PREFIX_PATH
(as directed the documentation in the 5th paragraph of Getting Started ), but the error continues. - I just did not try to individually define the
Qt5<Module>_DIR
variables because I believe this approach will only give more work than necessary (and maybe there is some other misconfiguration).
Does anyone know where I might be going wrong?