From c7fa2955e3f860f8070adea115f7277281228a2e Mon Sep 17 00:00:00 2001 From: Johan Lorensson Date: Fri, 26 Feb 2021 15:16:20 +0100 Subject: [PATCH] Fix EventPipe source using COMPILE_OPTIONS on old CMake 3.6.2. (#48809) Older CMake < 3.11 doesn't include COMPILE_OPTIONS source file property. This property is needed by clang or it will issue warning when building files with .c extension under c++ compiler. Fallback to add_compile_options if CMake is older than 3.11. Even if that option has wider scope, this is only applied to files in eventpipe directory or in debug-pal. Keeping the more precise set_source_files_properties on newer CMake and when we can upgrade CMake to 3.11 or newer we could get rid of this. --- src/coreclr/debug/debug-pal/CMakeLists.txt | 6 +++++- src/coreclr/vm/eventing/eventpipe/CMakeLists.txt | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/coreclr/debug/debug-pal/CMakeLists.txt b/src/coreclr/debug/debug-pal/CMakeLists.txt index f7d036af579..da51b34fdf6 100644 --- a/src/coreclr/debug/debug-pal/CMakeLists.txt +++ b/src/coreclr/debug/debug-pal/CMakeLists.txt @@ -38,7 +38,11 @@ if(CLR_CMAKE_HOST_UNIX) set (EVENTPIPE_PAL_SOURCES "${SHARED_EVENTPIPE_DIR}/ds-ipc-posix.c") set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES LANGUAGE CXX) - set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) + if (CMAKE_VERSION VERSION_GREATER 3.11 OR CMAKE_VERSION VERSION_EQUAL 3.11) + set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) + else(CMAKE_VERSION VERSION_GREATER 3.11 OR CMAKE_VERSION VERSION_EQUAL 3.11) + add_compile_options(-xc++) + endif() set(TWO_WAY_PIPE_SOURCES ${EVENTPIPE_PAL_SOURCES} diff --git a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt index 6c2052bb5ea..3b03605aece 100644 --- a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt +++ b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt @@ -65,7 +65,11 @@ set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERT set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES LANGUAGE CXX) if(CLR_CMAKE_HOST_UNIX) - set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) + if (CMAKE_VERSION VERSION_GREATER 3.11 OR CMAKE_VERSION VERSION_EQUAL 3.11) + set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) + else(CMAKE_VERSION VERSION_GREATER 3.11 OR CMAKE_VERSION VERSION_EQUAL 3.11) + add_compile_options(-xc++) + endif() endif(CLR_CMAKE_HOST_UNIX) list(APPEND CORECLR_EVENTPIPE_SHIM_SOURCES -- GitLab