I’m adding an operation to aeva-session, and I’m changing the associated .sbt file. If I just rebuild with ninja
, the changes are not picked up - I have to explicitly run cmake .
for my changes to the .sbt to be included. I’ve observed this behavior in smtk proper as well. I’m building on windows. Is this expected behavior, or is there a dependency we can add so cmake gets run automatically by ninja?
This is a known issue on all platforms.
Clippy says: It looks like you are volunteering to fix an issue! Would you like some help? You should probably start by changing the smtk_operation_xml
function in CMake/SMTKOperationXML.cmake
to add a target that writes a file instead of invoking configureFileAsCVariable()
(which happens at cmake-time, not build-time).
What’s an example of a target that writes a file, if you know one?
vtkEncodeString.cmake
has what you want . https://gitlab.kitware.com/vtk/vtk/-/blob/master/CMake/vtkEncodeString.cmake
@aron.helser Yes, what @ben.boeckel said. It would be nice to port/copy/steal the function from VTK/CMake/vtkEncodeString.cmake
that invokes add_custom_command()
rather than calling configure_file()
.
I’m stuck - I’ve refactored following the pattern from vtkEncodeString
, but I’m getting a cmake error:
-- Configuring done
CMake Error at smtk/CMakeLists.txt:107 (add_library):
Cannot find source file:
D:/akit/cmb/smtk/build/smtk/attribute/Write_xml.h
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
.hpp .hxx .in .txx
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
David looked over my shoulder, and we can’t figure out how to tell cmake to expect this generated file. Here’s my updated method. I’m only calling it in one place right now. Notice I tried to add a GENERATED
property to the file. I return the generated filename to the parent scope, then add it to the list of headers, then in the main smtk cmake I feed the header list to add_library()
. If I didn’t do this, cmake generation would complete, but the file wouldn’t generate so compilation failed.
@ben.boeckel can you take a look?
David pointed out a blog that referenced the faq so I tried adding a custom target, and I think I have it working for one target. I guess I need to name custom targets with path names to keep them from conflicting.
Added a custom target based on the file path - whatdya think?
LGTM!
This was a really annoying bug. Thanks @aron.helser for going after it!
https://gitlab.kitware.com/cmb/smtk/-/merge_requests/2017 has the final changes.