Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake generating twice breaks on ImGui patches. #895

Closed
mcourteaux opened this issue Sep 30, 2024 · 4 comments
Closed

CMake generating twice breaks on ImGui patches. #895

mcourteaux opened this issue Sep 30, 2024 · 4 comments

Comments

@mcourteaux
Copy link
Contributor

When I have all the dependencies ready, and I run cmake the first time, it works, but then running it again breaks, because the patches are attempted to be applied again. I debugged this a little, but couldn't figure it all out. CPM and FetchContent are somewhere the blame. I found that:

  • The patches are successfully applied, and the file _deps/imgui-subbuild/imgui-populate-prefix/src/imgui-populate-stamp/imgui-populate-patch is successfully touched.
  • Running again runs the patching command again (no idea why)
  • The patch command does not use -N to allow for skipping already-applied patches.
  • Attempting to add -N doesn't work because patch still exits with code 1, which CMake considers a failure.
  • The imgui-populate-patch file that is created to mark the successful patching of files is seemingly not used to skip the patching next time.

CMake output:

-- CPM: Adding package [email protected] (5.0.3)
Enabling CAPSTONE_ARM_SUPPORT
Enabling CAPSTONE_ARM64_SUPPORT
Enabling CAPSTONE_M68K_SUPPORT
Enabling CAPSTONE_MIPS_SUPPORT
Enabling CAPSTONE_PPC_SUPPORT
Enabling CAPSTONE_SPARC_SUPPORT
Enabling CAPSTONE_SYSZ_SUPPORT
Enabling CAPSTONE_XCORE_SUPPORT
Enabling CAPSTONE_X86_SUPPORT
Enabling CAPSTONE_TMS320C64X_SUPPORT
Enabling CAPSTONE_M680X_SUPPORT
Enabling CAPSTONE_EVM_SUPPORT
Enabling CAPSTONE_MOS65XX_SUPPORT
Enabling CAPSTONE_WASM_SUPPORT
Enabling CAPSTONE_BPF_SUPPORT
Enabling CAPSTONE_RISCV_SUPPORT
Enabling CAPSTONE_SH_SUPPORT
Enabling CAPSTONE_TRICORE_SUPPORT
-- CPM: Adding package ImGui@10 (10fe2b67)
-- Populating imgui
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /home/martijn/zec/3rd/tracy/profiler/build/_deps/imgui-subbuild
[0/7] Performing update step for 'imgui-populate'
[1/7] Performing patch step for 'imgui-populate'
patching file imconfig.h
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file imconfig.h.rej
FAILED: imgui-populate-prefix/src/imgui-populate-stamp/imgui-populate-patch /home/martijn/zec/3rd/tracy/profiler/build/_deps/imgui-subbuild/imgui-populate-prefix/src/imgui-populate-stamp/imgui-populate-patch 
cd /home/martijn/zec/3rd/tracy/profiler/build/_deps/imgui-src && /usr/bin/patch -p1 < /home/martijn/zec/3rd/tracy/cmake/imgui-emscripten.patch && /usr/bin/patch -p1 < /home/martijn/zec/3rd/tracy/cmake/imgui-loader.patch && /usr/bin/cmake -E touch /home/martijn/zec/3rd/tracy/profiler/build/_deps/imgui-subbuild/imgui-populate-prefix/src/imgui-populate-stamp/imgui-populate-patch
ninja: build stopped: subcommand failed.
CMake Error at /usr/share/cmake/Modules/FetchContent.cmake:1679 (message):
  Build step for imgui failed: 1
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FetchContent.cmake:1703 (__FetchContent_directPopulate)
  /home/martijn/zec/3rd/tracy/cmake/CPM.cmake:1106 (FetchContent_Populate)
  /home/martijn/zec/3rd/tracy/cmake/CPM.cmake:895 (cpm_fetch_package)
  /home/martijn/zec/3rd/tracy/cmake/vendor.cmake:146 (CPMAddPackage)
  CMakeLists.txt:26 (include)


-- Configuring incomplete, errors occurred!

With -N added in CPM:

~/zec/3rd/tracy/profiler/build master* ⇡ 17s
❯ cmake -DCMAKE_BUILD_TYPE=Release -DGTK_FILESELECTOR=OFF -G Ninja ..
Parsing public/common/TracyVersion.hpp file
VERSION 0.11.2
-- CPM: Adding package [email protected] (5.0.3)
Enabling CAPSTONE_ARM_SUPPORT
Enabling CAPSTONE_ARM64_SUPPORT
Enabling CAPSTONE_M68K_SUPPORT
Enabling CAPSTONE_MIPS_SUPPORT
Enabling CAPSTONE_PPC_SUPPORT
Enabling CAPSTONE_SPARC_SUPPORT
Enabling CAPSTONE_SYSZ_SUPPORT
Enabling CAPSTONE_XCORE_SUPPORT
Enabling CAPSTONE_X86_SUPPORT
Enabling CAPSTONE_TMS320C64X_SUPPORT
Enabling CAPSTONE_M680X_SUPPORT
Enabling CAPSTONE_EVM_SUPPORT
Enabling CAPSTONE_MOS65XX_SUPPORT
Enabling CAPSTONE_WASM_SUPPORT
Enabling CAPSTONE_BPF_SUPPORT
Enabling CAPSTONE_RISCV_SUPPORT
Enabling CAPSTONE_SH_SUPPORT
Enabling CAPSTONE_TRICORE_SUPPORT
-- CPM: Adding package ImGui@10 (10fe2b67)
-- Populating imgui
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /home/martijn/zec/3rd/tracy/profiler/build/_deps/imgui-subbuild
[0/7] Performing update step for 'imgui-populate'
[1/7] Performing patch step for 'imgui-populate'
patching file imconfig.h
Reversed (or previously applied) patch detected!  Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file imconfig.h.rej
FAILED: imgui-populate-prefix/src/imgui-populate-stamp/imgui-populate-patch /home/martijn/zec/3rd/tracy/profiler/build/_deps/imgui-subbuild/imgui-populate-prefix/src/imgui-populate-stamp/imgui-populate-patch 
cd /home/martijn/zec/3rd/tracy/profiler/build/_deps/imgui-src && /usr/bin/patch -N -p1 -i /home/martijn/zec/3rd/tracy/cmake/imgui-emscripten.patch && /usr/bin/patch -N -p1 -i /home/martijn/zec/3rd/tracy/cmake/imgui-loader.patch && /usr/bin/cmake -E touch /home/martijn/zec/3rd/tracy/profiler/build/_deps/imgui-subbuild/imgui-populate-prefix/src/imgui-populate-stamp/imgui-populate-patch
ninja: build stopped: subcommand failed.
CMake Error at /usr/share/cmake/Modules/FetchContent.cmake:1679 (message):
  Build step for imgui failed: 1
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FetchContent.cmake:1703 (__FetchContent_directPopulate)
  /home/martijn/zec/3rd/tracy/cmake/CPM.cmake:1106 (FetchContent_Populate)
  /home/martijn/zec/3rd/tracy/cmake/CPM.cmake:895 (cpm_fetch_package)
  /home/martijn/zec/3rd/tracy/cmake/vendor.cmake:146 (CPMAddPackage)
  CMakeLists.txt:26 (include)


-- Configuring incomplete, errors occurred!

~/zec/3rd/tracy/profiler/build master* ⇡
@wolfpld
Copy link
Owner

wolfpld commented Sep 30, 2024

Set CPM_SOURCE_CACHE.

cpm-cmake/CPM.cmake#577

@lemire
Copy link

lemire commented Sep 30, 2024

@mcourteaux It is a CPM bug and I have a PR that would at least document the issue...

cpm-cmake/CPM.cmake#580

If you'd like, you could chime in to raise awareness for the issue.

@wolfpld
Copy link
Owner

wolfpld commented Oct 3, 2024

Added workaround in b46d8db.

@lemire The behaviour I propose is functionally no different than the current upstream version (package checkout is done in each build directory), but is superior in that it always uses the same, correct code path (wrt to patches) instead of what appears to be one of two different implementations. Am I missing something here?

@wolfpld wolfpld closed this as completed Oct 3, 2024
@lemire
Copy link

lemire commented Oct 4, 2024

@wolfpld

Am I missing something here?

I suspect not but I am only inviting people to raise up awareness of this issue in CPM.

Your fix might very well be correct.

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

No branches or pull requests

3 participants