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. Difficulties creating CMake project using existing source files

Difficulties creating CMake project using existing source files

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 228 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #1

    I've created a CMakeLists.txt for one of my projects:

    # Require C++20 and disable extensions for all targets.
    # NOTE: See further below for how to do this more robustly.
    set(CMAKE_CXX_STANDARD 20)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_CXX_EXTENSIONS OFF)
    
    set(CMAKE_PREFIX_PATH
    	"C:/Qt/6.8.0/msvc2022_64"
    	CACHE STRING "" FORCE
    	)
    	
    set(PROJECT_NAME DeepSkyStacker)
    
    set(COMPILE_WARNING_AS_ERROR YES)
    
    find_package(Qt6 6.8 REQUIRED COMPONENTS Gui Widgets Network Charts)
    qt_standard_project_setup()
    
      :
      :
    
    set(Ui_Files
    	"./ui/About.ui"
    	"./ui/AlignmentParameters.ui"
    	"./ui/AskRegistering.ui"
    	"./ui/BackgroundOptions.ui"
    	"./ui/BatchStacking.ui"
    	"./ui/CheckAbove.ui"
    	"./ui/CometStacking.ui"
    	"./ui/DropFilesDlg.ui"
    	"./ui/ExplorerBar.ui"
    	"./ui/ImageProperties.ui"
    	"./ui/IntermediateFiles.ui"
    	"./ui/OutputTab.ui"
    	"./ui/PictureList.ui"
    	"./ui/PostCalibration.ui"
    	"./ui/ProcessingControls.ui"
    	"./ui/ProcessingDlg.ui"
    	"./ui/ProcessingSettingsDlg.ui"
    	"./ui/ProgressDlg.ui"
    	"./ui/RawDDPSettings.ui"
    	"./ui/RecommendedSettings.ui"
    	"./ui/RegisterSettings.ui"
    	"./ui/RenameGroup.ui"
    	"./ui/resources.qrc"	
    	"./ui/ResultParameters.ui"
    	"./ui/SaveEditChanges.ui"
    	"./ui/StackingDlg.ui"
    	"./ui/StackingParameters.ui"
    	"./ui/StackRecap.ui"
    	"./ui/StackSettings.ui"
    	"./ui/StarMaskDlg.ui"
    	)
    	
    source_group("Qt\\ui" FILES ${Ui_Files})
    
    set(i18n_Files
    	"./i18n/DSS_ca.ts"
    	"./i18n/DSS_cs.ts"
    	"./i18n/DSS_de.ts"
    	"./i18n/DSS_en.ts"
    	"./i18n/DSS_es.ts"
    	"./i18n/DSS_fr.ts"
    	"./i18n/DSS_it.ts"
    	"./i18n/DSS_ja_JP.ts"
    	"./i18n/DSS_nl.ts"
    	"./i18n/DSS_pt_BR.ts"
    	"./i18n/DSS_ro.ts"
    	"./i18n/DSS_ru.ts"
    	"./i18n/DSS_tr.ts"
    	"./i18n/DSS_zh_CN.ts"
    	"./i18n/DSS_zh_TW.ts"
    	"./i18n/translations.qrc"
    	)
    	
    source_group("Qt\\i18n" FILES ${i18n_Files})
    
    set(Tools
        "../Tools/imageview.cpp"
        "../Tools/QElidedLabel.cpp"
        "../Tools/QLinearGradientCtrl.cpp"
    )
    source_group("Tools" FILES ${Tools})
    
    set(ALL_FILES
        ${Dialogs}
        ${Dialogs__Processing}
        ${Dialogs__Registering}
        ${Dialogs__Settings}
        ${Dialogs__Stacking}
        ${Header_Files}
    	${Ui_Files}
    	${i18n_Files}
        ${Source_Files}
        ${Tools}
    )
    
    ################################################################################
    # Target
    ################################################################################
    qt_add_executable(DeepSkyStacker ${ALL_FILES})
    

    If I run CMake configure that works OK, but when I try to run generate I get:

    CMake Error at C:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:703 (add_executable):
      Cannot find source file:
    
        C:/Users/amonra/Documents/GitHub/DSS/build/DeepSkyStacker/ui/resources.qrc
    
      Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
      .ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
      .f95 .f03 .hip .ispc
    Call Stack (most recent call first):
      C:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:644 (_qt_internal_create_executable)
      C:/Qt/6.8.0/msvc2022_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:957 (qt6_add_executable)
      DeepSkyStacker/CMakeLists.txt:167 (qt_add_executable)
    

    Why is it looking under the build directory for that file when all the other files are searched for and found under C:/Users/amonra/Documents/GitHub/DSS/DeepSkyStacker?

    Clearly I did something wrong ... but what?

    1 Reply Last reply
    0
    • PerdrixP Perdrix deleted this topic on
    • PerdrixP Perdrix restored this topic on
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Does your CMakeLists.txt invoke (directly or indirectly):

      set(CMAKE_AUTORCC ON)
      
      1 Reply Last reply
      0
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by Perdrix
        #3

        I found my error, the file was indeed correctly reported as "not found" (it was up one level in the heirarchy).

        But it wasn't in the build tree (even though the error message suggested it was/should have been)?????

        1 Reply Last reply
        0

        • Login

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