Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using Google test: Cmake file ninja error

Using Google test: Cmake file ninja error

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 321 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jkwok678
    wrote on 19 Dec 2021, 11:56 last edited by jkwok678
    #1

    This is currently my CMakeList.txt but it doesn't seem to run, what am I missing?
    The current error I get is ninja: error: build.ninja:263: multiple rules generate qrc_filesaver.cpp [-w dupbuild=err]

    cmake_minimum_required(VERSION 3.8)
    set(PRO MyProject)
    set(PROLIB MyProjectLib)
    project(${PRO} CXX)
    
    # Find Qt Core, Gui & Widgets
    find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
    find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets Gui Core)
    set(CMAKE_CXX_STANDARD 11)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    enable_testing()
    add_subdirectory(googletest)
    
    set(Headers
        filesaver.h
    )
    set (Sources
        filesaver.cpp
    )
    add_library(${PROLIB} STATIC ${Sources} ${Headers})
    
    # Link the static lib to to Qt Core, Gui & Widgets
    target_link_libraries(${PROLIB} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets)
    
    add_subdirectory(test)
    
    # add the real executable with only the main.cpp
    qt6_add_resources(${Headers} ${Sources} resources.qrc)
    add_executable(${PRO} main.cpp ${Headers} ${Sources})
    set_target_properties(${PRO} PROPERTIES
        WIN32_EXECUTABLE TRUE
        MACOSX_BUNDLE TRUE
        CXX_STANDARD 11
        CXX_STANDARD_REQUIRED ON
    )
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 19 Dec 2021, 12:13 last edited by
      #2

      @jkwok678 said in Using Google test: Cmake file ninja error:

      qt6_add_resources

      You're using this macro wrong: https://doc.qt.io/qt-6/qt-add-resources.html

      qt6_add_resources(Sources resources.qrc)

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0

      1/2

      19 Dec 2021, 11:56

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved