diff options
author | Jeremy Koritzinsky <jekoritz@microsoft.com> | 2019-06-05 14:48:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-05 14:48:55 -0700 |
commit | 90dd13ee1bd497d7724c2b1d0fd833d42f7001ad (patch) | |
tree | ae6167d368f59598c6dd6c71e3280d1af0485f02 /src | |
parent | d7e49efa6b41afb2b7a9ee3adc8f0850b968562a (diff) | |
download | coreclr-90dd13ee1bd497d7724c2b1d0fd833d42f7001ad.tar.gz coreclr-90dd13ee1bd497d7724c2b1d0fd833d42f7001ad.tar.bz2 coreclr-90dd13ee1bd497d7724c2b1d0fd833d42f7001ad.zip |
Use Modern CMake features instead of CMAKE_CXX_FLAGS (#24861)
* Convert C++ standard settings and warning options from CMAKE_<LANG>_FLAGS to Modern CMake isms.
* More $<COMPILE_LANGUAGE> generator expressions instead of CMAKE_CXX_FLAGS.
* Use $<COMPILE_LANGUAGE:CXX> for all -fpermissive usage
* Fix generator expression that generates multiple flags
* Fix invalid use of CMAKE_CXX_FLAGS instead of CMAKE_C_FLAGS.
* Treat AppleClang as though it is Clang (match pre-3.0 behavior).
* Update our build system to understand that AppleClang is distinct from Clang and remove CMP0025 policy setting.
* PR Feedback.
Diffstat (limited to 'src')
-rw-r--r-- | src/ToolBox/SOS/Strike/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/ToolBox/SOS/lldbplugin/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/dlls/mscorpe/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/ilasm/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/inc/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/jit/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/pal/src/libunwind/src/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/pal/tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/pal/tests/palsuite/CMakeLists.txt | 4 |
9 files changed, 13 insertions, 13 deletions
diff --git a/src/ToolBox/SOS/Strike/CMakeLists.txt b/src/ToolBox/SOS/Strike/CMakeLists.txt index 8e0218a341..7047e3291c 100644 --- a/src/ToolBox/SOS/Strike/CMakeLists.txt +++ b/src/ToolBox/SOS/Strike/CMakeLists.txt @@ -106,10 +106,10 @@ if(WIN32) ) else(WIN32) add_definitions(-DPAL_STDCPP_COMPAT=1) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-null-arithmetic) elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion-null") + add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-conversion-null>) add_compile_options(-Wno-pointer-arith) endif() add_compile_options(-Wno-format) diff --git a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt index 0e4d40a706..2b65f52cba 100644 --- a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt +++ b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt @@ -124,7 +124,7 @@ endif() message(STATUS "LLDB_H: ${LLDB_H}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor") +add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-delete-non-virtual-dtor>) include_directories(inc) include_directories("${LLDB_H}") diff --git a/src/dlls/mscorpe/CMakeLists.txt b/src/dlls/mscorpe/CMakeLists.txt index 43deb47ec9..6a8919326b 100644 --- a/src/dlls/mscorpe/CMakeLists.txt +++ b/src/dlls/mscorpe/CMakeLists.txt @@ -10,7 +10,7 @@ set(MSCORPE_SOURCES ) if(NOT WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor") + add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-delete-non-virtual-dtor>) endif() add_library_clr(mscorpe STATIC diff --git a/src/ilasm/CMakeLists.txt b/src/ilasm/CMakeLists.txt index 3d1a74dae6..f780dcae11 100644 --- a/src/ilasm/CMakeLists.txt +++ b/src/ilasm/CMakeLists.txt @@ -51,7 +51,7 @@ if(CLR_CMAKE_PLATFORM_UNIX) # Need generate a right form of asmparse.cpp to avoid the following options. # Clang also produces a bad-codegen on this prebuilt file with optimization. # https://github.com/dotnet/coreclr/issues/2305 - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor -Wno-register") + add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wno-delete-non-virtual-dtor;-Wno-register>") add_compile_options(-Wno-array-bounds) add_compile_options(-Wno-unused-label) set_source_files_properties( prebuilt/asmparse.cpp PROPERTIES COMPILE_FLAGS "-O0" ) diff --git a/src/inc/CMakeLists.txt b/src/inc/CMakeLists.txt index 517ea8e0f4..c38d59587a 100644 --- a/src/inc/CMakeLists.txt +++ b/src/inc/CMakeLists.txt @@ -49,7 +49,7 @@ else() # The prebuilt files contain extra '!_MIDL_USE_GUIDDEF_' after the #endif, but not in the comment. # In order to not to have to modify these prebuilt files, we disable the extra tokens warning. -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-extra-tokens) elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") add_compile_options(-Wno-endif-labels) diff --git a/src/jit/CMakeLists.txt b/src/jit/CMakeLists.txt index 5e7c9c50d2..8a3475605b 100644 --- a/src/jit/CMakeLists.txt +++ b/src/jit/CMakeLists.txt @@ -4,7 +4,7 @@ include_directories("./jitstd") include_directories("../inc") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") + add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fpermissive>) add_compile_options(-Wno-error) endif() diff --git a/src/pal/src/libunwind/src/CMakeLists.txt b/src/pal/src/libunwind/src/CMakeLists.txt index b29e7ee9a2..93b4daf3a6 100644 --- a/src/pal/src/libunwind/src/CMakeLists.txt +++ b/src/pal/src/libunwind/src/CMakeLists.txt @@ -22,7 +22,7 @@ add_definitions("-Ddwarf_search_unwind_table_int=UNW_OBJ(dwarf_search_unwind_tab # Disable warning due to incorrect format specifier in debugging printf via the Debug macro add_compile_options(-Wno-format) -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-header-guard) elseif() add_compile_options(-Wno-unused-value) @@ -33,7 +33,7 @@ if(CLR_CMAKE_PLATFORM_ARCH_ARM) add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)") # Disable warning in asm: use of SP or PC in the list is deprecated add_compile_options(-Wno-inline-asm) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Disable warning due to labs function called on unsigned argument add_compile_options(-Wno-absolute-value) endif() @@ -48,7 +48,7 @@ if(CLR_CMAKE_PLATFORM_ARCH_ARM) # the include/tdep-arm to include directories include_directories(../include/tdep-arm) elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Disable warning due to labs function called on unsigned argument add_compile_options(-Wno-absolute-value) endif() diff --git a/src/pal/tests/CMakeLists.txt b/src/pal/tests/CMakeLists.txt index 5597922f72..0ec630df8c 100644 --- a/src/pal/tests/CMakeLists.txt +++ b/src/pal/tests/CMakeLists.txt @@ -32,7 +32,7 @@ endif() # C++ emits errors and warnings for c-string literal fed into char* parameter # this is just to take care of the warnings -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-writable-strings) elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") add_compile_options(-Wno-write-strings) diff --git a/src/pal/tests/palsuite/CMakeLists.txt b/src/pal/tests/palsuite/CMakeLists.txt index 6726165caf..00a4301784 100644 --- a/src/pal/tests/palsuite/CMakeLists.txt +++ b/src/pal/tests/palsuite/CMakeLists.txt @@ -14,13 +14,13 @@ endif() list(APPEND COMMON_TEST_LIBRARIES coreclrpal) -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers) add_compile_options(-Wno-int-to-void-pointer-cast) elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") add_compile_options(-Wno-sign-compare) add_compile_options(-Wno-narrowing) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive" ) + add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fpermissive>) add_compile_options(-Wno-int-to-pointer-cast) endif() |