From 5d67ce4a790818d2316787209160d9528db795f9 Mon Sep 17 00:00:00 2001 From: Alexandre Ganea Date: Wed, 31 Jan 2024 13:22:19 -0500 Subject: [PATCH 1/3] [openmp] On Windows, fix standalone cmake build This fixes: https://github.com/llvm/llvm-project/issues/80117 --- openmp/cmake/HandleOpenMPOptions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmp/cmake/HandleOpenMPOptions.cmake b/openmp/cmake/HandleOpenMPOptions.cmake index 201aeabbd3df9..79dfa334d749e 100644 --- a/openmp/cmake/HandleOpenMPOptions.cmake +++ b/openmp/cmake/HandleOpenMPOptions.cmake @@ -44,9 +44,9 @@ append_if(OPENMP_HAVE_DATA_SECTIONS "-fdata-sections" CMAKE_C_FLAGS CMAKE_CXX_FL if (MSVC) # Disable "warning C4201: nonstandard extension used: nameless struct/union" - append("-wd4201" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append_if(TRUE "-wd4201" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) # Disable "warning C4190: '__kmpc_atomic_cmplx8_rd' has C-linkage specified, but returns # UDT '__kmp_cmplx64_t' which is incompatible with C" - append("-wd4190" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append_if(TRUE "-wd4190" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif() From 196f1332753f53aa62d0ff6cbd01012f53df008f Mon Sep 17 00:00:00 2001 From: Alexandre Ganea Date: Wed, 31 Jan 2024 16:10:21 -0500 Subject: [PATCH 2/3] [openmp][cmake] Add 'append' cmake command if it's not already there --- openmp/cmake/HandleOpenMPOptions.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/openmp/cmake/HandleOpenMPOptions.cmake b/openmp/cmake/HandleOpenMPOptions.cmake index 79dfa334d749e..72fea70e5ea21 100644 --- a/openmp/cmake/HandleOpenMPOptions.cmake +++ b/openmp/cmake/HandleOpenMPOptions.cmake @@ -9,6 +9,14 @@ if (NOT COMMAND append_if) endfunction() endif() +if (NOT COMMAND append) + function(append value) + foreach(variable ${ARGN}) + set(${variable} "${${variable}} ${value}" PARENT_SCOPE) + endforeach(variable) + endfunction() +endif() + # MSVC and clang-cl in compatibility mode map -Wall to -Weverything. # TODO: LLVM adds /W4 instead, check if that works for the OpenMP runtimes. if (NOT MSVC) @@ -44,9 +52,9 @@ append_if(OPENMP_HAVE_DATA_SECTIONS "-fdata-sections" CMAKE_C_FLAGS CMAKE_CXX_FL if (MSVC) # Disable "warning C4201: nonstandard extension used: nameless struct/union" - append_if(TRUE "-wd4201" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-wd4201" CMAKE_C_FLAGS CMAKE_CXX_FLAGS ) # Disable "warning C4190: '__kmpc_atomic_cmplx8_rd' has C-linkage specified, but returns # UDT '__kmp_cmplx64_t' which is incompatible with C" - append_if(TRUE "-wd4190" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-wd4190" CMAKE_C_FLAGS CMAKE_CXX_FLAGS ) endif() From 4654c3d180a878fb1e5c0b7943cb1741b7bd4f25 Mon Sep 17 00:00:00 2001 From: Alexandre Ganea Date: Wed, 31 Jan 2024 16:11:11 -0500 Subject: [PATCH 3/3] Remove extra spaces --- openmp/cmake/HandleOpenMPOptions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmp/cmake/HandleOpenMPOptions.cmake b/openmp/cmake/HandleOpenMPOptions.cmake index 72fea70e5ea21..71346201129b6 100644 --- a/openmp/cmake/HandleOpenMPOptions.cmake +++ b/openmp/cmake/HandleOpenMPOptions.cmake @@ -52,9 +52,9 @@ append_if(OPENMP_HAVE_DATA_SECTIONS "-fdata-sections" CMAKE_C_FLAGS CMAKE_CXX_FL if (MSVC) # Disable "warning C4201: nonstandard extension used: nameless struct/union" - append("-wd4201" CMAKE_C_FLAGS CMAKE_CXX_FLAGS ) + append("-wd4201" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) # Disable "warning C4190: '__kmpc_atomic_cmplx8_rd' has C-linkage specified, but returns # UDT '__kmp_cmplx64_t' which is incompatible with C" - append("-wd4190" CMAKE_C_FLAGS CMAKE_CXX_FLAGS ) + append("-wd4190" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif()