robotology / ycm-cmake-modules

YCM (YCM CMake modules) is a collection of various useful CMake modules.
http://robotology.github.io/ycm-cmake-modules
Other
50 stars 22 forks source link

Create YCMBootstrapFetch to permit projects to bootstrap YCM using FetchContent #403

Closed traversaro closed 2 years ago

traversaro commented 2 years ago

Create YCMBootstrapFetch.cmake script to permit projects to bootstrap YCM by just using FetchContent.

A different file is created as the semantics of this new bootstrap script is a bit different, as it just make YCM available in the project, but it does not also adds it as a subproject in the superbuild sense. Superbuilds that want to switch from YCMBootstrap.cmake to YCMBootstrapFetch.cmake need to create BuildYCM.cmake script, and appropriately call find_or_build_package(YCM), as done for example in the robotology-superbuild in https://github.com/robotology/robotology-superbuild/pull/1078 .

Fix https://github.com/robotology/ycm/issues/138 .

traversaro commented 2 years ago

Windows GitHub Action builds, before this PR the bootstrapping took ~25 seconds and ~22 seconds in subsequent builds:

2022-04-13T13:15:32.8484463Z -- YCM not found. Bootstrapping it.
2022-04-13T13:15:32.8515271Z -- Downloading YCMEPHelper.cmake - Attempt 1 of 3
2022-04-13T13:15:32.9477256Z -- Downloading YCMEPHelper.cmake - SUCCESS
2022-04-13T13:15:32.9506210Z -- Downloading CMakeParseArguments.cmake - Attempt 1 of 3
2022-04-13T13:15:32.9785522Z -- Downloading CMakeParseArguments.cmake - SUCCESS
2022-04-13T13:15:32.9798445Z -- Downloading ExternalProject.cmake - Attempt 1 of 3
2022-04-13T13:15:33.0161645Z -- Downloading ExternalProject.cmake - SUCCESS
2022-04-13T13:15:33.0346004Z CMake Warning (dev) at build/CMakeFiles/YCMEPHelper.cmake:164 (message):
2022-04-13T13:15:33.0346733Z   YCM_BOOTSTRAP HASH mismatch
2022-04-13T13:15:33.0347087Z 
2022-04-13T13:15:33.0347458Z     for file: [D:/a/robotology-superbuild/robotology-superbuild/cmake/IncludeUrl.cmake]
2022-04-13T13:15:33.0347962Z       expected hash: [997de3554f0d03ae22952a64fe26cdad118e8199]
2022-04-13T13:15:33.0348380Z         actual hash: [5ec16edfcc1f76c7e22771b4f632da908232a933]
2022-04-13T13:15:33.0348672Z 
2022-04-13T13:15:33.0348953Z   Perhaps it is outdated or you have local modification.  Please consider
2022-04-13T13:15:33.0349405Z   upgrading it, or contributing your changes to YCM.
2022-04-13T13:15:33.0349683Z 
2022-04-13T13:15:33.0349889Z Call Stack (most recent call first):
2022-04-13T13:15:33.0350293Z   build/CMakeFiles/YCMEPHelper.cmake:1335 (_ycm_hash_check)
2022-04-13T13:15:33.0351012Z   cmake/YCMBootstrap.cmake:102 (ycm_bootstrap)
2022-04-13T13:15:33.0351429Z   CMakeLists.txt:56 (include)
2022-04-13T13:15:33.0351846Z This warning is for project developers.  Use -Wno-dev to suppress it.
2022-04-13T13:15:33.0352153Z 
2022-04-13T13:15:33.0356264Z -- Downloading StyleGITHUB.cmake - Attempt 1 of 3
2022-04-13T13:15:33.0678198Z -- Downloading StyleGITHUB.cmake - SUCCESS
2022-04-13T13:15:33.1785470Z -- Performing download step (git clone) for 'YCM'
2022-04-13T13:15:34.9784192Z -- Performing update step for 'YCM'
2022-04-13T13:15:35.9801574Z -- Performing configure step for 'YCM'
2022-04-13T13:15:38.1790158Z -- Performing uninstall step for 'YCM'
2022-04-13T13:15:39.6938859Z -- Performing build step for 'YCM'
2022-04-13T13:15:50.3215812Z -- Performing install step for 'YCM'
2022-04-13T13:15:56.6708893Z -- Found YCM: D:/a/robotology-superbuild/robotology-superbuild/build/install/share/cmake/YCM (found version "0.13.2")
2022-04-13T13:15:57.1612277Z -- Package YARP not found. Will be downloaded and built.

After, it takes ~5 seconds on first build and ~3 on subsequent builds:

2022-04-13T15:58:29.2048786Z -- YCM not found. Bootstrapping it.
2022-04-13T15:58:29.2089251Z -- Fetching YCM.
2022-04-13T15:58:34.2048020Z -- YCM_SOURCE_DIR: D:/a/robotology-superbuild/robotology-superbuild/build/_deps/ycm-src
2022-04-13T15:58:34.9321770Z -- Package YARP not found. Will be downloaded and built.
traversaro commented 2 years ago

The tests in in https://github.com/robotology/robotology-superbuild/pull/1078 worked fine, the PR is now ready for review.