На основании теста conan-qt Я изменил CMakeLists.txt:
cmake_minimum_required(VERSION 3.8.2)
project(helloworld)
# Find includes in the build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
<b>include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()</b>
# Turn on automatic invocation of the MOC, UIC & RCC
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# There may be a way to tell up front if Qt5 is going to be found, but I haven't found
# a foolproof way to do it yet, so settle for the default error message for now.
#if(NOT CMAKE_PREFIX_PATH AND NOT Qt5Widgets_DIR)
# message(WARNING "CMAKE_PREFIX_PATH is not defined, so find_package may not work. Set the CMAKE_PREFIX_PATH "
# "environment variable to the install prefix of Qt 5, either on the command line as "
# "-DCMAKE_PREFIX_PATH=\"path/to/Qt5/lib/cmake\" or with set(CMAKE_PREFIX_PATH path/to/Qt5/lib/cmake)")
#endif(NOT CMAKE_PREFIX_PATH AND NOT Qt5Widgets_DIR)
# Add a compiler flag
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# Make this a GUI application on Windows
if(WIN32)
set(CMAKE_WIN32_EXECUTABLE ON)
endif()
# Find the QtWidgets library
find_package(Qt5 REQUIRED COMPONENTS Widgets)
# Tell CMake to create the helloworld executable
add_executable(helloworld main.cpp mainwindow.cpp mainwindow.ui resources.qrc)
# Add the Qt5 Widgets for linking
target_link_libraries(helloworld Qt5::Widgets)
и conanfile.txt, который вы используете для теста:
[requires]
qt/5.14.1@bincrafters/stable
[generators]
cmake
qt
[options]
*:shared=True
И вам нужно выполнить команду:
mkdir build
cd build
conan install ..
cmake ..
make
Плагину Qt xcb нужны некоторые библиотеки, поэтому некоторые пакеты должен быть установлен с помощью следующей команды:
sudo apt-get install libgl1-mesa-dev libxcb-xinerama0 libxcb-shm0 libxcb-xinput0
Qt 5.14 имеет требования, которые недоступны в Ubuntu 16.04, поэтому Qt 5.9 должно быть установлено:
<b>cmake_minimum_required(VERSION 3.1.0)</b>
project(helloworld)
# Find includes in the build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# add conan
<b>include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()</b>
# Turn on automatic invocation of the MOC, UIC & RCC
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# There may be a way to tell up front if Qt5 is going to be found, but I haven't found
# a foolproof way to do it yet, so settle for the default error message for now.
#if(NOT CMAKE_PREFIX_PATH AND NOT Qt5Widgets_DIR)
# message(WARNING "CMAKE_PREFIX_PATH is not defined, so find_package may not work. Set the CMAKE_PREFIX_PATH "
# "environment variable to the install prefix of Qt 5, either on the command line as "
# "-DCMAKE_PREFIX_PATH=\"path/to/Qt5/lib/cmake\" or with set(CMAKE_PREFIX_PATH path/to/Qt5/lib/cmake)")
#endif(NOT CMAKE_PREFIX_PATH AND NOT Qt5Widgets_DIR)
# Add a compiler flag
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# Make this a GUI application on Windows
if(WIN32)
set(CMAKE_WIN32_EXECUTABLE ON)
endif()
# Find the QtWidgets library
find_package(Qt5 REQUIRED COMPONENTS Widgets)
# Tell CMake to create the helloworld executable
add_executable(helloworld main.cpp mainwindow.cpp mainwindow.ui resources.qrc)
# Add the Qt5 Widgets for linking
target_link_libraries(helloworld Qt5::Widgets)
[requires]
Qt/5.9@bincrafters/stable
[generators]
cmake
[options]
*:shared=True
И вы должны выполнить команду:
mkdir build
cd build
conan install .. --build Qt
cmake ..
make
Также устанавливаются зависимости:
sudo apt-get install -y --no-install-recommends \
libxcursor-dev \
libxfixes-dev \
libxi-dev \
libgl1-mesa-dev \
libxrandr-dev \
libx11-xcb-dev \
libxcb-keysyms1 \
libxcb-keysyms1-dev \
libxcb-image0 \
libxcb-image0-dev \
libxcb-icccm4 \
libxcb-icccm4-dev \
libxcb-sync-dev \
libxcb-xfixes0-dev \
libxcb-shape0-dev \
libxcb-render-util0-dev \
libxcb-randr0-dev \
libxcb-render-util0 \
libxcb-glx0-dev \
libxcb-xinerama0 \
libxcb-xinerama0-dev