[libc-commits] [libc] [libc] Add libc_set_definition and libc_add_definition to properly pass definitions to MSVC. (PR #189664)
Petr Hosek via libc-commits
libc-commits at lists.llvm.org
Tue Mar 31 23:07:11 PDT 2026
================
@@ -10,6 +10,31 @@ if(NOT DEFINED LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE)
endif()
endif()
+function(libc_add_definition output_var def)
+ if(MSVC)
+ list(APPEND ${output_var} "/D${def}")
+ else()
+ list(APPEND ${output_var} "-D${def}")
+ endif()
+
+ set(${output_var} ${${output_var}} PARENT_SCOPE)
+endfunction()
----------------
petrhosek wrote:
In general it'd be preferable to shift towards using the CMake builtin functions where possible to reduce the amount of logic we have to maintain on our side. The previous implementation didn't use `target_compile_definitions` either so I don't have a strong opinion on which version we should keep for now.
https://github.com/llvm/llvm-project/pull/189664
More information about the libc-commits
mailing list