Skip to content

Conversation

@sjh26
Copy link

@sjh26 sjh26 commented Nov 12, 2025

When building against current Slicer we see many of this type of warning:

CMake Warning (dev) in Beams/Widgets/CMakeLists.txt:
    Policy CMP0071 is not set: Let AUTOMOC and AUTOUIC process GENERATED files.
    Run "cmake --help-policy CMP0071" for policy details.  Use the cmake_policy
    command to set the policy and suppress this warning.
  
    For compatibility, CMake is excluding the GENERATED source file(s):
  
      "D:/srt-broken/inner-build/Beams/Widgets/generated_cpp/osm_qSlicerBeamsModuleWidgets/osm_qSlicerBeamsModuleWidgets_init.cpp"
      "D:/srt-broken/inner-build/Beams/Widgets/generated_cpp/osm_qSlicerBeamsModuleWidgets/osm_qSlicerBeamsModuleWidgets_module_init.cpp"
      "D:/srt-broken/inner-build/Beams/Widgets/generated_cpp/osm_qSlicerBeamsModuleWidgets/osm_qSlicerBeamsModuleWidgets.h"
  
    from processing by AUTOMOC.  If any of the files should be processed, set
    CMP0071 to NEW.  If any of the files should not be processed, explicitly
    exclude them by setting the source file property SKIP_AUTOMOC:
  
      set_property(SOURCE file.h PROPERTY SKIP_AUTOMOC ON)
  
  This warning is for project developers.  Use -Wno-dev to suppress it.

We then later see errors of this type:

Creating library D:/srt-broken/inner-build/lib/Slicer-5.11/qt-loadable-modules/Release/qSlicerBeamsModuleWidgetsPythonQt.lib and object D:/srt-broken/inner-build/lib/Slicer-5.11/qt-loadable-modules/Release/qSlicerBeamsModuleWidgetsPythonQt.exp
osm_qSlicerBeamsModuleWidgets_init.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl PythonQtWrapper_qMRMLBeamParametersTabWidget::metaObject(void)const " (?metaObject@PythonQtWrapper_qMRMLBeamParametersTabWidget@@UEBAPEBUQMetaObject@@XZ) [D:\srt-broken\inner-build\Beams\Widgets\qSlicerBeamsModuleWidgetsPythonQt.vcxproj] [D:\srt-broken\inner.vcxproj]
osm_qSlicerBeamsModuleWidgets_init.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl PythonQtWrapper_qMRMLBeamParametersTabWidget::qt_metacast(char const *)" (?qt_metacast@PythonQtWrapper_qMRMLBeamParametersTabWidget@@UEAAPEAXPEBD@Z) [D:\srt-broken\inner-build\Beams\Widgets\qSlicerBeamsModuleWidgetsPythonQt.vcxproj] [D:\srt-broken\inner.vcxproj]
osm_qSlicerBeamsModuleWidgets_init.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl PythonQtWrapper_qMRMLBeamParametersTabWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@PythonQtWrapper_qMRMLBeamParametersTabWidget@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z) [D:\srt-broken\inner-build\Beams\Widgets\qSlicerBeamsModuleWidgetsPythonQt.vcxproj] [D:\srt-broken\inner.vcxproj]
osm_qSlicerBeamsModuleWidgets_init.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl PythonQtWrapper_qMRMLBeamsTableView::metaObject(void)const " (?metaObject@PythonQtWrapper_qMRMLBeamsTableView@@UEBAPEBUQMetaObject@@XZ) [D:\srt-broken\inner-build\Beams\Widgets\qSlicerBeamsModuleWidgetsPythonQt.vcxproj] [D:\srt-broken\inner.vcxproj]
osm_qSlicerBeamsModuleWidgets_init.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl PythonQtWrapper_qMRMLBeamsTableView::qt_metacast(char const *)" (?qt_metacast@PythonQtWrapper_qMRMLBeamsTableView@@UEAAPEAXPEBD@Z) [D:\srt-broken\inner-build\Beams\Widgets\qSlicerBeamsModuleWidgetsPythonQt.vcxproj] [D:\srt-broken\inner.vcxproj]
osm_qSlicerBeamsModuleWidgets_init.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl PythonQtWrapper_qMRMLBeamsTableView::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@PythonQtWrapper_qMRMLBeamsTableView@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z) [D:\srt-broken\inner-build\Beams\Widgets\qSlicerBeamsModuleWidgetsPythonQt.vcxproj] [D:\srt-broken\inner.vcxproj]
D:\srt-broken\inner-build\lib\Slicer-5.11\qt-loadable-modules\Release\qSlicerBeamsModuleWidgetsPythonQt.pyd : fatal error LNK1120: 6 unresolved externals [D:\srt-broken\inner-build\Beams\Widgets\qSlicerBeamsModuleWidgetsPythonQt.vcxproj] [D:\srt-broken\inner.vcxproj]

By explicitly setting CMP0071 to new for the extension, these errors seem to resolve

@jcfr
Copy link
Contributor

jcfr commented Nov 12, 2025

That makes sense.
See https://cmake.org/cmake/help/latest/policy/CMP0071.html

You could do:

If(POLICY CMP0071)
   set(...)
endif()

Later, we could ensure all extension have the option set ... there is way to set policy through cmake option.

@sjh26
Copy link
Author

sjh26 commented Nov 12, 2025

The mystery here is why we don't have to set this anywhere in the Slicer or CTK CMake files and they work fine. Also I don't really understand what the code snippet you are suggesting is supposed to do.

@sjh26
Copy link
Author

sjh26 commented Nov 12, 2025

Ah, I see what is happening. It is the difference in the cmake_minimum_required that is triggering the old behavior for the extension

Slicer's: cmake_minimum_required(VERSION 3.20.6...3.22.6 FATAL_ERROR) vs 3.5 here. Updating the minimum required should also fix

@sjh26
Copy link
Author

sjh26 commented Nov 12, 2025

Yep, updating the minimum cmake required fixes it. Will push new commit that updates it to what is currently used in the extension template

@sjh26 sjh26 changed the title COMP: Fix AUTOMOC by setting CMP0071 to NEW COMP: Fix AUTOMOC by updating the minimum cmake version Nov 12, 2025
Older minimum versions enable the OLD behavior on CMP0071, which
breaks AUTOMOC compilation
@sjh26 sjh26 changed the title COMP: Fix AUTOMOC by updating the minimum cmake version COMP: Fix AUTOMOC by updating the minimum CMake version Nov 12, 2025
@sjh26
Copy link
Author

sjh26 commented Nov 12, 2025

First pass at fix within Slicer: Slicer/Slicer#8845

@lassoan
Copy link
Member

lassoan commented Nov 12, 2025

Thanks a lot for working on this. Is the plan that we integrate the fix in Slicer and then this change will not be necessary?

@sjh26
Copy link
Author

sjh26 commented Nov 12, 2025

Yes, but updating the cmake minimum version to match Slicer is a good idea anyway I think

@sjh26
Copy link
Author

sjh26 commented Nov 12, 2025

Also, I will need to backport the Slicer fix to 5.10, fixing it here will fix both Stable and Preview immediately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants