Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Auto MOC doesn't catch headers



  • I currently have a project with this structure:

    - project
    --- include/
    --- src/
    --- qml/
    --- CMakeLists.txt
    --- qml.qrc
    

    With this as my CMakeLists.txt:

    cmake_minimum_required(VERSION 3.1)
    
    cmake_policy(SET CMP0071 NEW)
    
    include_directories(${Qt5Widgets_INCLUDE_DIRS} ${QtQml_INCLUDE_DIRS})
    add_definitions(${Qt5Widgets_DEFINITIONS} ${QtQml_DEFINITIONS} ${${Qt5Quick_DEFINITIONS}})
    
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    project(wormhole_qt)
    
    find_package(Qt5 COMPONENTS Core Quick Qml OpenGL REQUIRED)
    find_package(Qt5QuickCompiler)
    
    find_package(VTK REQUIRED)
    include(${VTK_USE_FILE})
    
    include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
    
    MACRO(HEADER_DIRECTORIES sub_dir return_list)
        FILE(GLOB_RECURSE new_list ${sub_dir}/*.h)
        SET(dir_list "")
        FOREACH(file_path ${new_list})
            GET_FILENAME_COMPONENT(dir_path ${file_path} PATH)
            SET(dir_list ${dir_list} ${dir_path})
        ENDFOREACH()
        LIST(REMOVE_DUPLICATES dir_list)
        SET(${return_list} ${dir_list})
    ENDMACRO()
    
    HEADER_DIRECTORIES(include mylist)
    include_directories(include)
    include_directories(lib)
    include_directories(${mylist})
    
    file(GLOB INCLUDES *.h)
    file(GLOB_RECURSE CPP_FILES src/*.cpp)
    
    qtquick_compiler_add_resources(QT_RESOURCES qml.qrc)
    qt5_wrap_cpp(MOC_SOURCE ${INCLUDES})
    add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${MOC_SOURCE} ${CPP_FILES} ${QT_RESOURCES})
    
    target_link_libraries(${PROJECT_NAME} ${VTK_LIBRARIES})
    qt5_use_modules(${PROJECT_NAME} Quick Core Qml OpenGL)
    

    But when I go to compile, I get this:

    14:18:45: Running steps for project wormhole_qt...
    14:18:45: Starting: "/usr/local/bin/cmake" --build . --target all
    [  1%] Generating qmlcache_loader.cpp
    [  2%] Generating qml_Empty_qml.cpp
    [  4%] Generating qml_Style_qml.cpp
    [  5%] Generating qml_main_qml.cpp
    [  7%] Generating qml_setup_NewProject_qml.cpp
    [  8%] Generating qml_setup_Setup_qml.cpp
    [  9%] Generating qml_setup_Startup_qml.cpp
    [ 11%] Generating qml_workspace_AnimationWindow_qml.cpp
    [ 12%] Generating qml_workspace_DepthChartControls_qml.cpp
    [ 14%] Generating qml_workspace_NewAnimationWindow_qml.cpp
    [ 15%] Generating qml_workspace_TraceWindow_qml.cpp
    [ 16%] Generating qml_workspace_WorkspaceMenuBar_qml.cpp
    [ 18%] Generating qml_workspace_Workspace_qml.cpp
    [ 19%] Automatic MOC for target wormhole_qt
    [ 19%] Built target wormhole_qt_autogen
    [ 21%] Generating qrc_qml_qmlcache.cpp
    Scanning dependencies of target wormhole_qt
    [ 22%] Building CXX object CMakeFiles/wormhole_qt.dir/src/controllers/AnimationsController.cpp.o
    [ 23%] Building CXX object CMakeFiles/wormhole_qt.dir/src/controllers/ApplicationController.cpp.o
    

    Which is telling me that no MOC files are being created. Why is this?


Log in to reply