Skip to content

Commit bb3ddac

Browse files
rothmichaelsclaude
andcommitted
fix: resolve CMake compiler test failure in freestanding CI builds
The freestanding CI builds were failing during CMake's initial compiler test because the -ffreestanding flag was causing linker issues. The linker expected a main() function but freestanding environments may not have one. This fix sets CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY when freestanding mode is enabled, which instructs CMake to skip the linking step during compiler tests and only compile to static libraries. This resolves the undefined reference to main error in CI while maintaining proper freestanding compilation semantics. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a6a5b61 commit bb3ddac

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

conanfile.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ def generate(self):
272272
# TODO remove the below when Conan will learn to handle C++ modules
273273
if opt.freestanding:
274274
tc.cache_variables["MP_UNITS_API_FREESTANDING"] = True
275+
# Fix for freestanding builds: CMake compiler tests fail when linking with -ffreestanding
276+
# Set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY to avoid linking during compiler tests
277+
tc.cache_variables["CMAKE_TRY_COMPILE_TARGET_TYPE"] = "STATIC_LIBRARY"
275278
else:
276279
tc.cache_variables["MP_UNITS_API_STD_FORMAT"] = opt.std_format
277280
tc.cache_variables["MP_UNITS_API_NO_CRTP"] = opt.no_crtp

0 commit comments

Comments
 (0)