4
I’m trying to generate the build configuration of a simple Qt example using Cmake. The code of the example 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 Gero the configuration in Windows (v.10, 64bits), it goes well. However, when I do the same on 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 correctly installed on Ubuntu (in the local folder
/home/luiz/Qt5.5.1
). - Running the command
apt-file search Qt5CoreConfig.cmake
, i get the following path:qtbase5-dev: /usr/lib/i386-linux-gnu/cmake/Qt5Core/Qt5CoreConfig.cmake
. So I’ve tried to add/usr/lib/i386-linux-gnu/cmake/
the environment variableCMAKE_PREFIX_PATH
(as directed the documentation in the fifth paragraph of Getting Started), but the error continues. - I just didn’t try to define individually the variables
Qt5<Module>_DIR
because I believe that this approach will only take more work than necessary (and maybe there is some other wrong configuration).
Does anyone know where I might be going wrong?
@Guilhermenascimento It was normal. Really does not have in apt, the installation tutorial uses the site download directly. So I think it was installed in the local folder (but I didn’t imagine that this would possibly be a problem). About the rest, yes, I was wrong in the question. I will correct. :)
– Luiz Vieira
@Guilhermenascimento No. I installed the 5.5.1 same. : ) (the installation tutorial is a little older rs). Only in windows that I installed the 5.6 (but because of a dependency on VS 2015 - there is working well).
– Luiz Vieira
Has tried this http://askubuntu.com/q/4755/181632 ?
– Guilherme Nascimento
@Guilhermenascimento I had already seen this question (by the way, I found the tip of
apt-file
there). But I admit that the answer accepted is a little confusing for me. I even tried to change the names of the packages in thefind_package
as it suggests (in the "Qt*5-dev" pattern), but if so, it didn’t work here either.– Luiz Vieira
@Guilhermenascimento I tried too (thinking the same thing you). Only then it gives the same error in Widgets. :/
– Luiz Vieira
He even reinstalled the Cmake
apt-get remove cmake & apt-get install cmake
? Maybe something is missing since apt-search finds but cmake does not.– Guilherme Nascimento
@No, I did not. I will now after lunch.
– Luiz Vieira
@Guilhermenascimento I just reinstalled Cmake, and the error continues. :/
– Luiz Vieira
@Guilhermenascimento, thank you for your help. But I managed to resolve it (see my reply).
– Luiz Vieira