Skip to content

Fix cmake features#566

Merged
robertosfield merged 3 commits into
vsg-dev:masterfrom
rhabacker:fix-cmake-features
Nov 11, 2022
Merged

Fix cmake features#566
robertosfield merged 3 commits into
vsg-dev:masterfrom
rhabacker:fix-cmake-features

Conversation

@rhabacker
Copy link
Copy Markdown
Contributor

@rhabacker rhabacker commented Nov 9, 2022

Description

With the changes from this pull, the vsg_add_target_xxx macros now work again with the submodule/fetchcontent build mode.

This is achieved by creating a project-specific cmake target named x-<project> (e.g. docs-vsg) for each available x in vsg_add_target_x (currently docs, cppcheck, clang-format, clobber and 'uninstall') when vsg_add_target_x() is called and adding it as a dependency to a parent target named x (see custem-target-deps.pdf for an example)

To avoid possible conflicts with possibly already existing cmake targets like docs, cppcheck, clang-format, clobber and 'uninstall' when they are integrated as submodules into other projects, these parent targets are only created if they do not already exist.

Conversely, if a project already provides a cmake target e.g. named docs and builds the documentation with it, the documentation for included vsg[XXX] projects will also be built.

Fixes #565

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Building vsg and vsgXchange with associated changes
  • running some vsg_add_target related target e.g. clang-format and doc
  • inspected the resulting cmake dependencies custom-target-deps.pdf

Test Configuration:

  • OS: openSUSE Leap 15.4 x86_64
  • Toolchain: gcc

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules (pending, needs to be applied afterwards)

Additional information

  • Please note that the changes made by the dependent pull requests listed below are independent of this pull request
  • intended for version 1.0.1

@rhabacker
Copy link
Copy Markdown
Contributor Author

@robertosfield If you run https://github.com/vsg-dev/VulkanSceneGraph/actions/workflows/build-docs.yml on this branch, you will see now two lines indicating at the end of the build log indicating that the patches are working as expected.

 [100%] Built target docs-vsg
 [100%] Built target docs

@robertosfield
Copy link
Copy Markdown
Collaborator

VSG master and VulkanSceneGraph-1.0 branch are now in feature freeze, only bugs in the code or cmake build will be addressed from this point onward s.

Enabling cmake features in ancillary projects that use FetchContent/sumodules is not something that clears this hurdle. If I have time tomorrow I'll merge this PR as a branch that we can look at merging with VSG master the release goes out, earliest this would be would be next week.

This also fixes an issue with out of source or submodule based builds
of vsg not installing uninstall.cmake.
A separate cmake target is created for each submodule, e.g. 'cppcheck-vsg'
for the vsg library and a total of one target named 'cppcheck' that depends
on each submodule specific target.
@robertosfield
Copy link
Copy Markdown
Collaborator

I have merged this PR as rhabacker-fix-cmake-features branch, and will do the same for the other projects that you've provided a PR for.

I will then test the branches as is, then revert back to respective master and test out the out of source builds with a view of creating the problems, then try cherry-picking the commits into master to resolve the more critical problems. Jumping through all these hoops is required as I don't want to risk breaking the build fora code base that has been stable and mostly working well this week.

@robertosfield robertosfield merged commit 38c9d17 into vsg-dev:master Nov 11, 2022
@robertosfield
Copy link
Copy Markdown
Collaborator

@rhabacker since I merged this PR I have been setting errors reported to the console after I run make clobber, the errors are reported after the successful clobber-vsg section, the problem part looks like:

make[3]: CMakeFiles/clobber.dir/build.make: No such file or directory
make[3]: *** No rule to make target 'CMakeFiles/clobber.dir/build.make'. Stop.
make[2]: *** [CMakeFiles/Makefile2:161: CMakeFiles/clobber.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:169: CMakeFiles/clobber.dir/rule] Error 2
make: *** [Makefile:195: clobber] Error 2

It looks like to implement the add_depedency for clobber target CMake is building script files for us when we first run cmake, but then when it tries to run these scripts they get deleted by the cobber-vsg before it has a chance to complete.

Any ideas how to resolve this? FYI, reverting to the original implementation works fine.

-- full make clobber report:

$ make clobber
Removing CMakeCache.txt
Removing CMakeDoxyfile.in
Removing CMakeDoxygenDefaults.cmake
Removing CMakeFiles/
Removing Doxyfile.docs-vsg
Removing Makefile
Removing cmake/.vsgMacros.cmake.kate-swp
Removing cmake_install.cmake
Removing include/vsg/core/Version.h
Removing lib/
Removing src/vsg/CMakeFiles/
Removing src/vsg/Makefile
Removing src/vsg/cmake_install.cmake
Removing src/vsg/vsgConfig.cmake
Removing src/vsg/vsgConfigVersion.cmake
Built target clobber-vsg
make[3]: CMakeFiles/clobber.dir/build.make: No such file or directory
make[3]: *** No rule to make target 'CMakeFiles/clobber.dir/build.make'. Stop.
make[2]: *** [CMakeFiles/Makefile2:161: CMakeFiles/clobber.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:169: CMakeFiles/clobber.dir/rule] Error 2
make: *** [Makefile:195: clobber] Error 2

@rhabacker
Copy link
Copy Markdown
Contributor Author

I'll take a look today.

@rhabacker
Copy link
Copy Markdown
Contributor Author

Hmmh, I could not reproduce this problem with the current master branch - I ran the following:

$ mkdir ~/src && cd ~/src
$ git clone https://github.com/vsg-dev/VulkanSceneGraph.git
$ cd VulkanSceneGraph
$ cmake -B ../VulkanSceneGraph-build/
$ cmake --build ../VulkanSceneGraph-build/
$ touch test.log 
$ cmake --build ../VulkanSceneGraph-build/ --target clobber
Lösche test.log
Built target clobber-vsg
Built target clobber

@rhabacker
Copy link
Copy Markdown
Contributor Author

make[3]: CMakeFiles/clobber.dir/build.make: No such file or directory

Please open a new bug report, as this problem is independent of this pr and existed before.

@rhabacker rhabacker deleted the fix-cmake-features branch November 14, 2022 08:03
@robertosfield
Copy link
Copy Markdown
Collaborator

robertosfield commented Nov 14, 2022 via email

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.

vsg_add_target_xxx macros are not working anymore in submodule/fetchcontent builds

2 participants