Live-Video-Magnification icon indicating copy to clipboard operation
Live-Video-Magnification copied to clipboard

Cmake error

Open iplayfast opened this issue 10 months ago • 12 comments

cmake .. -- The CXX compiler identification is GNU 13.3.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC -- Performing Test HAVE_STDATOMIC - Success -- Found WrapAtomic: TRUE
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- Found WrapOpenGL: TRUE
-- Found XKB: /usr/lib/x86_64-linux-gnu/libxkbcommon.so (found suitable version "1.6.0", minimum required is "0.5.0") -- Found WrapVulkanHeaders: /usr/include
CMake Error at CMakeLists.txt:88 (qt6_add_ui): Unknown CMake command "qt6_add_ui".

-- Configuring incomplete, errors occurred!

iplayfast avatar Jan 09 '25 19:01 iplayfast

removing the line that contains qt6_add_ui get's by that problem as widgets are imported by the

Qt6 Setup

find_package(Qt6 REQUIRED COMPONENTS Widgets)

iplayfast avatar Jan 09 '25 19:01 iplayfast

Also SavingThread.cpp has #include "SavingThread.h " Note the space after .h #include "ui_CameraConnectDialog.h" in CameraConnectDialog.h is wrong. Was not able to get to compile even with these fixes.

iplayfast avatar Jan 09 '25 20:01 iplayfast

qt_add_ui doesn't import Widget targets but instructs Qt to compile the ui files into actual C++ objects (like the CameraConnectDialog.ui -> ui_CameraConnectDialog.h) why you can't find it.

I changed it from qt6_add_ui to the versionless command and compiled it with MinGW to fix some compiler warnings and switched to C++17. Adjust the CMakePresets.json accordingly and check if this works for you.

tschnz avatar Jan 11 '25 15:01 tschnz

Sorry, it didn't work.

git reset --hard HEAD
HEAD is now at f477c6a Update README.md
chris@FORGE:~/github/Live-Video-Magnification$ git pull
Updating f477c6a..d83a55b
Fast-forward
 CMakeLists.txt                            | 10 +++++-----
 CMakePresets.json                         | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
 src/main/magnification/Magnificator.cpp   |  6 ++++--
 src/main/magnification/TemporalFilter.cpp |  4 ++--
 src/main/threads/SavingThread.cpp         |  2 +-
 src/main/ui/FrameLabel.cpp                |  2 +-
 src/main/ui/MainWindow.cpp                |  2 +-
 7 files changed, 71 insertions(+), 26 deletions(-)
chris@FORGE:~/github/Live-Video-Magnification$ ls
build  CMakeLists.txt  CMakePresets.json  COPYING  LICENSE  pictures  README.md  src
chris@FORGE:~/github/Live-Video-Magnification$ cd build
chris@FORGE:~/github/Live-Video-Magnification/build$ ls
CMakeCache.txt  CMakeFiles  cmake_install.cmake  LiveVideoMagnification_autogen  Makefile
chris@FORGE:~/github/Live-Video-Magnification/build$ rm -rf *
chris@FORGE:~/github/Live-Video-Magnification/build$ cmake ..
-- The CXX compiler identification is GNU 13.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE  
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- Found WrapOpenGL: TRUE  
-- Found XKB: /usr/lib/x86_64-linux-gnu/libxkbcommon.so (found suitable version "1.6.0", minimum required is "0.5.0") 
-- Found WrapVulkanHeaders: /usr/include  
CMake Error at CMakeLists.txt:88 (qt_add_ui):
  Unknown CMake command "qt_add_ui".


-- Configuring incomplete, errors occurred!

also searched my qt6 install

ls /opt/qt/6.6.0/gcc_64/q^C
chris@FORGE:~/github/Live-Video-Magnification/build$ cd /opt/qt
chris@FORGE:/opt/qt$ find . -iname qt5_add_ui
chris@FORGE:/opt/qt$ 

iplayfast avatar Jan 14 '25 18:01 iplayfast

Please post your CMakePresets.json with your user defined variables

tschnz avatar Jan 14 '25 19:01 tschnz

You need to add a configure and build preset for your compiler. I'm not on a Unix system, so the example paths in the file are only working on my Windows system. If you have a standard installation of OpenCV & QT, add the respective paths to your GCC configurations and feel free to do a PR.

tschnz avatar Jan 14 '25 20:01 tschnz

PR done!

iplayfast avatar Jan 15 '25 20:01 iplayfast

Is there no simpler way to compile this program. I've tried several thousands of times now. I was only able to successfully compile this program under Ubuntu 22.04 LTS. Every other attempt in VS fails because of some compiler mismanagement. There has to be a simpler way to do this.

nincube8 avatar Feb 17 '25 11:02 nincube8

@nincube8 The switch to cmake was effectively exactly that: A switch to the current QT6+ build system recommendation. I tested this on VSCode on Windows 11 without any problems.

But please help me a little solve your issue! What is your current setup, the error (messages) you run into, what have you tried and what's your gut feeling on why it's failing? As I wrote somewhere else: This is my Bachelor project and I can not be bothered to rewrite that shitty code...

tschnz avatar Feb 17 '25 16:02 tschnz

I'll post some errors I'm getting. It's probably just because I don't really understand since I'm not formally educated in the issues of code compilation. I load the project by selecting the "Workspace Folder" then selecting the "Live-Video-Magnification" folder.... The option to build the project is greyed out... Visual Studio offers to auto generate the CMake Cache... in the solution explorer with a Debug option Upon clicking that button this happens

-When I'm compiling for the "Local Machine" as a "x64 Release, or any other option available", VS doesn't have a target to build, it's just greyed out. -"Build + Intellisense" Generates an error @ Line 73 in the file "CMakeTestCXXCompiler.cmake" Line 73: "message(FATAL_ERROR "The C++ compiler\n "${CMAKE_CXX_COMPILER}"\n"" "is not able to compile a simple test program.\nIt fails " "with the following output:\n ${_output}\n\n" "CMake will not be able to correctly generate this project.") -Then it goes back to line 1 And outputs this error..... Visual Studio supports CMakePresets.json files versions 2 to 9. Please update your CMakePresets.json file. More info: aka.ms/cmakepresetsversion -If I attempt to change the version # in code @ line 2 from 10 to any other number in "CmakePresets.json", the first error in intellisense disappears, but it still generates the second error about versions 2-9 are supported. "Visual Studio supports CMakePresets.json files versions 2 to 9. Please update your CMakePresets.json file. More info: aka.ms/cmakepresetsversion"

So I attempt to use cmake-gui 3.31.5 to configure the toolchain file for configuring cmakelists.txt -I specify the generator to Ninja and get this error. "CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage Configuring incomplete, errors occurred!"

nincube8 avatar Feb 18 '25 21:02 nincube8

@nincube8 I advise you using VSCode as is written in the Build section in the README

Install Qt >= 6 Download precompiled OpenCV binaries or compile OpenCV >= 4 yourself In CMakePresets.json Set CMAKE_PREFIX_PATH to the Qt installation directory which should be the same compiler as your OpenCV binaries Set CMAKE_MAKE_PROGRAM to the generator of your choice, Ninja is recommended Set OpenCV_DIR to the directory where the OpenCVConfig.cmake is located Append the path to the OpenCV and Qt binaries to the PATH variable

I only tested this on Windows with VSCode. Make sure to install Qt msvc2022 and Tools, use pre-built OpenCV 4.10 from their website, make sure to install all VSCode Qt Extensions and set User Preferences > CMake: Use VS Developer Environment to "always".

tschnz avatar Mar 21 '25 08:03 tschnz

According to https://doc.qt.io/qt-6/qt-add-ui.html qt_add_ui() was added in Qt 6.8, @iplayfast is using Qt 6.6.

I had the same issue on Debian 12 (Qt 6.4.2 even). set(CMAKE_AUTOUIC ON) and commenting the qt_add_ui() line worked for me.

I am using the following Presets. CMakePresets.json

Modiug avatar Oct 12 '25 09:10 Modiug

@nincube8 were you successfull in the meantime? I added a .exe to the releases. It is now also possible to build a standalone with OpenCV and Qt being statically compiled via vcpkg. I also updated the readme on how to build with prebuild libraries.

tschnz avatar Oct 27 '25 01:10 tschnz

This is updated to be build with vcpkg or prebuild binaries. Please open a new issue if it persists

tschnz avatar Oct 27 '25 23:10 tschnz