Skip to content

Fix cmake cmp0175 warnings on cmake 3.31 and higher#1273

Merged
salkinium merged 1 commit intomodm-io:developfrom
Tecnologic:fix_cmake_cmp0175
Jul 15, 2025
Merged

Fix cmake cmp0175 warnings on cmake 3.31 and higher#1273
salkinium merged 1 commit intomodm-io:developfrom
Tecnologic:fix_cmake_cmp0175

Conversation

@Tecnologic
Copy link
Contributor

I use cmake 4.0 and gcc 14.2 on my project. the hole cmake build is based on the cmake example project.

What does thid fix?:

  1. CMake starting from 3.31 have the cmp0175 policy which deprecateds the USE_TERMINAL flag for custom output commands. To fix that i changed the Comands generated in ModmConfiguration.cmake to the approach cmake suggests. currently it works for the build but i have done very little testing on the commands if everything works as expected.
  2. My CMake root and the modm root are differnent folders. To make that possible i needed to change how project_source_dir is filled and that it is used for the linker script as well. Also the python path needed to change to the "CMAKE_CURRENT_SOURCE_DIR" because thats inside the generated modm folder.

@Tecnologic
Copy link
Contributor Author

as expected most of the problems arise from folder structure.
my linker script location is "{project_source_dir}/link/linkerscript.ld" as opposed to "modm/link/linkerscript.ld". The variable {project_source_dir} seems unappropriate here.

@Tecnologic
Copy link
Contributor Author

To get away with the linkerscript on cortex m platforms i use link/linkerscript.ld That fixes my compile issue in my project while keeping the examples working.

@Tecnologic
Copy link
Contributor Author

I'll skip the directory independance for this pull request and stick to the override option for the linkerskript.

@salkinium
Copy link
Member

So Point 1 makes sense to me, thanks for updating our CMake to the latest standard!

Point 2 is a bit unclear to me. Could you provide the folder structure, maybe using an simplified tree command? Why is the linkerscript location so special? Shouldn't other paths also break when moving files around? There's also a modm:platform:cortex-m:linkerscript.override option in case you want to modify the existing linkerscript.

lbuild/modm has the option to relocate the output path using the <outpath>...</outpath> xml option:

<outpath>../generated/blink</outpath>

It's a fairly niche feature that was introduced in this PR. That was before the CMake generator existed, so not sure if that is properly supported.

@Tecnologic Tecnologic force-pushed the fix_cmake_cmp0175 branch 2 times, most recently from 254ac8e to bafa06a Compare July 7, 2025 22:26
@Tecnologic
Copy link
Contributor Author

I switched to using modm:platform:cortex-m:linkerscript.override option option in my project so this contains no path releated stuff anymore accept from the cmake specific stuff.

as recomended in the other pr i squashed the commits and rebased on the current release.

I hope this is fine for u.

Copy link
Member

@salkinium salkinium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reproduce this behaviour with cmake v4.0.3 and your commit fixes it!

Thank you!

@salkinium
Copy link
Member

Could you fix your commit message to [cmake] Fix CMP0175 warnings for CMake ≥v3.31. The current squashed one is very non-descriptive. I unfortunately cannot push to your branch.

@Tecnologic
Copy link
Contributor Author

I struggled a bit, but i think this i gona work

@salkinium salkinium merged commit 3fbe3a1 into modm-io:develop Jul 15, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants