Skip to content

try_compile(): handle empty CMAKE_TRY_COMPILE_CONFIGURATION

If CMAKE_TRY_COMPILE_CONFIGURATION is not set, the generated CMake project sets CMAKE_<LANG>_FLAGS_DEBUG, but does not set CMAKE_BUILD_TYPE to Debug so those flags will be ignored. I noticed this because poppler's configure checks were failing when cross-compiling for CHERI-RISC-V due to missing -mabi/-march flags. This happens because poppler's build system overrides CMAKE_C_FLAGS and appends the user/toolchain-provided flags to CMAKE_C_FLAGS_<CONFIG>.

See https://gitlab.freedesktop.org/poppler/poppler/-/merge_requests/887

Fixes: #22414 (closed)

Edited by Alexander Richardson

Merge request reports