diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 0be4937c7f8d46..e24f5765413330 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -54,7 +54,19 @@ add_compile_definitions("$<$:DEBUG;_DEBUG;_DBG;URTBLDENV_FRIENDL add_compile_definitions("$<$,$>:NDEBUG;URTBLDENV_FRIENDLY=Retail>") if (MSVC) - add_linker_flag(/guard:cf) + + define_property(TARGET PROPERTY CLR_CONTROL_FLOW_GUARD INHERITED BRIEF_DOCS "Controls the /guard:cf flag presence" FULL_DOCS "Set this property to ON or OFF to indicate if the /guard:cf compiler and linker flag should be present") + define_property(TARGET PROPERTY CLR_EH_CONTINUATION INHERITED BRIEF_DOCS "Controls the /guard:ehcont flag presence" FULL_DOCS "Set this property to ON or OFF to indicate if the /guard:ehcont compiler flag should be present") + define_property(TARGET PROPERTY CLR_EH_OPTION INHERITED BRIEF_DOCS "Defines the value of the /EH option" FULL_DOCS "Set this property to one of the valid /EHxx options (/EHa, /EHsc, /EHa-, ...)") + + set_property(GLOBAL PROPERTY CLR_CONTROL_FLOW_GUARD ON) + + # Remove the /EHsc from the CXX flags so that the compile options are the only source of truth for that + string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set_property(GLOBAL PROPERTY CLR_EH_OPTION /EHsc) + + add_compile_options($<$:$>) + add_link_options($<$>:/guard:cf>) # Linker flags # @@ -841,7 +853,7 @@ if (MSVC) add_compile_options($<$:/Gz>) endif (CLR_CMAKE_HOST_ARCH_I386) - add_compile_options($<$,$,$>>:/GL>) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION $,$,$>>) if (CLR_CMAKE_HOST_ARCH_AMD64) # The generator expression in the following command means that the /homeparams option is added only for debug builds for C and C++ source files @@ -850,16 +862,15 @@ if (MSVC) # enable control-flow-guard support for native components for non-Arm64 builds # Added using variables instead of add_compile_options to let individual projects override it - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /guard:cf") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf") + add_compile_options($<$,$>>:/guard:cf>) # Enable EH-continuation table and CET-compatibility for native components for amd64 builds except for components of the Mono # runtime. Added some switches using variables instead of add_compile_options to let individual projects override it. if (CLR_CMAKE_HOST_ARCH_AMD64 AND NOT CLR_CMAKE_RUNTIME_MONO) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /guard:ehcont") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:ehcont") - set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /guard:ehcont") - add_linker_flag(/guard:ehcont) + set_property(GLOBAL PROPERTY CLR_EH_CONTINUATION ON) + + add_compile_options($<$,$>>:/guard:ehcont>) + add_link_options($<$>:/guard:ehcont>) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /CETCOMPAT") endif (CLR_CMAKE_HOST_ARCH_AMD64 AND NOT CLR_CMAKE_RUNTIME_MONO) @@ -888,7 +899,9 @@ if (MSVC) endif (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64) # Don't display the output header when building RC files. - add_compile_options($<$:/nologo>) + set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /nologo") + # Don't display the output header when building asm files. + set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /nologo") endif (MSVC) # Configure non-MSVC compiler flags that apply to all platforms (unix-like or otherwise) diff --git a/eng/native/ijw/IJW.cmake b/eng/native/ijw/IJW.cmake index 9ef90525dda8ba..4dd7b0ff2cfa8f 100644 --- a/eng/native/ijw/IJW.cmake +++ b/eng/native/ijw/IJW.cmake @@ -2,19 +2,13 @@ if (CLR_CMAKE_HOST_WIN32) function(remove_ijw_incompatible_options options updatedOptions) # IJW isn't compatible with Ehsc, which CMake enables by default - if(options MATCHES "/EHsc") - string(REPLACE "/EHsc" "" options "${options}") - endif() + set_property(DIRECTORY PROPERTY CLR_EH_OPTION "") # IJW isn't compatible with CFG - if(options MATCHES "/guard:cf") - string(REPLACE "/guard:cf" "" options "${options}") - endif() + set_property(DIRECTORY PROPERTY CLR_CONTROL_FLOW_GUARD OFF) # IJW isn't compatible with EHCONT, which requires CFG - if(options MATCHES "/guard:ehcont") - string(REPLACE "/guard:ehcont" "" options "${options}") - endif() + set_property(DIRECTORY PROPERTY CLR_EH_CONTINUATION OFF) # IJW isn't compatible with GR- if(options MATCHES "/GR-") diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 7946ca99b0df5f..c806c2d3f9aee2 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -73,8 +73,7 @@ endif() # Enable C++ EH with SEH #------------------------- if (MSVC) - string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - add_compile_options($<$:/EHa>) # enable C++ EH (w/ SEH exceptions) + set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHa) # enable C++ EH (w/ SEH exceptions) endif() #------------------------------- diff --git a/src/coreclr/dlls/clretwrc/CMakeLists.txt b/src/coreclr/dlls/clretwrc/CMakeLists.txt index 2b749fd7b3736f..2729a6072269bc 100644 --- a/src/coreclr/dlls/clretwrc/CMakeLists.txt +++ b/src/coreclr/dlls/clretwrc/CMakeLists.txt @@ -8,9 +8,10 @@ if(CLR_CMAKE_HOST_WIN32) string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO}) # remove /guard:cf, /guard:ehcont, and /CETCOMPAT from resource-only libraries - string(REPLACE "/guard:cf" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) + set_property(DIRECTORY PROPERTY CLR_CONTROL_FLOW_GUARD OFF) + if (CLR_CMAKE_HOST_ARCH_AMD64) - string(REPLACE "/guard:ehcont" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) + set_property(DIRECTORY PROPERTY CLR_EH_CONTINUATION OFF) string(REPLACE "/CETCOMPAT" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) endif (CLR_CMAKE_HOST_ARCH_AMD64) diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index 4b1ff24ccdceb9..ea49cb0ad4098a 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -144,7 +144,7 @@ if(CLR_CMAKE_HOST_WIN32) add_custom_command( DEPENDS mscordaccore_def "${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def" mscordacobj daccess OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.exp - COMMAND lib.exe /OUT:"${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.lib" /DEF:"${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def" "$" $<$,$>:/LTCG> ${STATIC_LIBRARY_FLAGS} $ + COMMAND lib.exe /NOLOGO /OUT:"${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.lib" /DEF:"${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def" "$" $<$,$>:/LTCG> ${STATIC_LIBRARY_FLAGS} $ COMMENT "Generating mscordaccore.exp export file" ) diff --git a/src/coreclr/dlls/mscorrc/CMakeLists.txt b/src/coreclr/dlls/mscorrc/CMakeLists.txt index 8011997c1e55fc..30b2bf1eda69da 100644 --- a/src/coreclr/dlls/mscorrc/CMakeLists.txt +++ b/src/coreclr/dlls/mscorrc/CMakeLists.txt @@ -9,9 +9,10 @@ if(CLR_CMAKE_HOST_WIN32) string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}) # remove /guard:cf, /guard:ehcont, and /CETCOMPAT from resource-only libraries - string(REPLACE "/guard:cf" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) + set_property(DIRECTORY PROPERTY CLR_CONTROL_FLOW_GUARD OFF) + if (CLR_CMAKE_HOST_ARCH_AMD64) - string(REPLACE "/guard:ehcont" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) + set_property(DIRECTORY PROPERTY CLR_EH_CONTINUATION OFF) string(REPLACE "/CETCOMPAT" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) endif (CLR_CMAKE_HOST_ARCH_AMD64) diff --git a/src/coreclr/inc/CMakeLists.txt b/src/coreclr/inc/CMakeLists.txt index 0733379b024093..cae1e5c07b7565 100644 --- a/src/coreclr/inc/CMakeLists.txt +++ b/src/coreclr/inc/CMakeLists.txt @@ -27,7 +27,7 @@ if(CLR_CMAKE_HOST_WIN32) set(OUT_NAME ${CMAKE_CURRENT_BINARY_DIR}/idls_out/${IDLNAME}_i.c) list(APPEND CORGUIDS_SOURCES ${OUT_NAME}) add_custom_command(OUTPUT ${OUT_NAME} - COMMAND ${MIDL} ${MIDL_INCLUDE_DIRECTORIES} /no_stamp /h ${CMAKE_CURRENT_BINARY_DIR}/idls_out/${IDLNAME}.h ${MIDL_DEFINITIONS} /out ${CMAKE_CURRENT_BINARY_DIR}/idls_out ${CMAKE_CURRENT_SOURCE_DIR}/${GENERATE_IDL} + COMMAND ${MIDL} ${MIDL_INCLUDE_DIRECTORIES} /nologo /no_stamp /h ${CMAKE_CURRENT_BINARY_DIR}/idls_out/${IDLNAME}.h ${MIDL_DEFINITIONS} /out ${CMAKE_CURRENT_BINARY_DIR}/idls_out ${CMAKE_CURRENT_SOURCE_DIR}/${GENERATE_IDL} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${GENERATE_IDL} COMMENT "Compiling ${GENERATE_IDL}") endforeach(GENERATE_IDL) diff --git a/src/coreclr/nativeaot/Bootstrap/base/CMakeLists.txt b/src/coreclr/nativeaot/Bootstrap/base/CMakeLists.txt index 3ffc81ac648b09..22c194d7fafb74 100644 --- a/src/coreclr/nativeaot/Bootstrap/base/CMakeLists.txt +++ b/src/coreclr/nativeaot/Bootstrap/base/CMakeLists.txt @@ -12,7 +12,7 @@ install_bootstrapper_object(bootstrapper aotsdk) if (CLR_CMAKE_TARGET_WIN32) add_library(bootstrapper.GuardCF OBJECT ${SOURCES}) install_bootstrapper_object(bootstrapper.GuardCF aotsdk) - target_compile_options(bootstrapper.GuardCF PRIVATE $<$,$>:/guard:cf>) + set_target_properties(bootstrapper.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON) else() add_library(stdc++compat STATIC ../stdcppshim.cpp) install_static_library(stdc++compat aotsdk nativeaot) diff --git a/src/coreclr/nativeaot/Bootstrap/dll/CMakeLists.txt b/src/coreclr/nativeaot/Bootstrap/dll/CMakeLists.txt index 14eb3ece8e1e04..263518e4b006f3 100644 --- a/src/coreclr/nativeaot/Bootstrap/dll/CMakeLists.txt +++ b/src/coreclr/nativeaot/Bootstrap/dll/CMakeLists.txt @@ -13,5 +13,5 @@ install_bootstrapper_object(bootstrapperdll aotsdk) if (CLR_CMAKE_TARGET_WIN32) add_library(bootstrapperdll.GuardCF STATIC ${SOURCES}) install_bootstrapper_object(bootstrapperdll.GuardCF aotsdk) - target_compile_options(bootstrapperdll.GuardCF PRIVATE $<$,$>:/guard:cf>) + set_target_properties(bootstrapperdll.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON) endif() diff --git a/src/coreclr/nativeaot/CMakeLists.txt b/src/coreclr/nativeaot/CMakeLists.txt index 74bf4449e24c7c..557a70ed48db97 100644 --- a/src/coreclr/nativeaot/CMakeLists.txt +++ b/src/coreclr/nativeaot/CMakeLists.txt @@ -3,20 +3,11 @@ if(WIN32) endif (WIN32) if(MSVC) - add_compile_options($<$:/EHa->) # Native AOT runtime does not use C++ exception handling - add_compile_options($<$:/EHs->) - - # CFG runtime checks in C++ code are unnecessary overhead unless Native AOT compiler produces CFG compliant code as well - # and CFG is enabled in the linker - if(CMAKE_CXX_FLAGS MATCHES "/guard:cf") - string(REPLACE "/guard:cf" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - endif() - if(CMAKE_C_FLAGS MATCHES "/guard:cf") - string(REPLACE "/guard:cf" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - endif() + set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHa-s-) # Native AOT runtime does not use C++ exception handling + set_property(DIRECTORY PROPERTY CLR_CONTROL_FLOW_GUARD OFF) # The code generated by the Native AOT compiler doesn't work with Link Time Code Generation - add_compile_options($<$:/GL->) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) # Sets the options that create the fastest code in the majority of cases add_compile_options($<$,$>:/O2>) diff --git a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt index 3cbaa6e2f253a6..2d2858dfaedfdc 100644 --- a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt @@ -40,11 +40,11 @@ target_compile_definitions(Runtime.ServerGC PRIVATE -DFEATURE_SVR_GC) if (CLR_CMAKE_TARGET_WIN32) add_library(Runtime.ServerGC.GuardCF STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${RUNTIME_SOURCES_ARCH_ASM} ${SERVER_GC_SOURCES} ${RUNTIME_ARCH_ASM_OBJECTS}) target_compile_definitions(Runtime.ServerGC.GuardCF PRIVATE -DFEATURE_SVR_GC) - target_compile_options(Runtime.ServerGC.GuardCF PRIVATE $<$,$>:/guard:cf>) + set_target_properties(Runtime.ServerGC.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON) if (CLR_CMAKE_TARGET_ARCH_AMD64) add_library(Runtime.VxsortEnabled.GuardCF STATIC ${VXSORT_SOURCES}) - target_compile_options(Runtime.VxsortEnabled.GuardCF PRIVATE $<$,$>:/guard:cf>) + set_target_properties(Runtime.VxsortEnabled.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON) endif (CLR_CMAKE_TARGET_ARCH_AMD64) endif (CLR_CMAKE_TARGET_WIN32) @@ -55,7 +55,7 @@ set(ASM_OFFSETS_CSPP ${RUNTIME_DIR}/../Runtime.Base/src/AsmOffsets.cspp) if(WIN32) set(COMPILER_LANGUAGE "") - set(PREPROCESSOR_FLAGS -EP) + set(PREPROCESSOR_FLAGS -EP -nologo) set(ASM_OFFSETS_CPP ${RUNTIME_DIR}/windows/AsmOffsets.cpp) else() set(COMPILER_LANGUAGE -x c++) diff --git a/src/coreclr/nativeaot/Runtime/Portable/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/Portable/CMakeLists.txt index ea7b5a348eb233..5d19a4eb9eda04 100644 --- a/src/coreclr/nativeaot/Runtime/Portable/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/Portable/CMakeLists.txt @@ -13,7 +13,7 @@ set(ASM_OFFSETS_CSPP ${RUNTIME_DIR}/../Runtime.Base/src/AsmOffsets.cspp) if(WIN32) set(COMPILER_LANGUAGE "") - set(PREPROCESSOR_FLAGS -EP) + set(PREPROCESSOR_FLAGS -EP -nologo) set(ASM_OFFSETS_CPP ${RUNTIME_DIR}/windows/AsmOffsets.cpp) else() set(COMPILER_LANGUAGE -x c++) diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index 27f07197287994..3dd73aaaaf75b7 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -160,8 +160,8 @@ add_library(eventpipe-disabled STATIC ${AOT_EVENTPIPE_DISABLED_SOURCES}) if (CLR_CMAKE_TARGET_WIN32) add_library(eventpipe-enabled.GuardCF STATIC ${EVENTPIPE_SOURCES}) add_library(eventpipe-disabled.GuardCF STATIC ${AOT_EVENTPIPE_DISABLED_SOURCES}) - target_compile_options(eventpipe-enabled.GuardCF PRIVATE $<$,$>:/guard:cf>) - target_compile_options(eventpipe-disabled.GuardCF PRIVATE $<$,$>:/guard:cf>) + set_target_properties(eventpipe-enabled.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON) + set_target_properties(eventpipe-disabled.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON) endif (CLR_CMAKE_TARGET_WIN32) install_static_library(eventpipe-enabled aotsdk nativeaot) diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index 249e4d52cf2647..0f35d2cdb2f667 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -8,7 +8,7 @@ include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake) if (MSVC) # Host components don't try to handle asynchronous exceptions - add_compile_options($<$:/EHsc>) + set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHsc) # Explicitly re-enable warnings about declaration hiding (currently disabled by configurecompiler.cmake) add_compile_options($<$:/we4456>) # declaration of 'identifier' hides previous local declaration diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index e1a02ece410912..0bced59e7f10b9 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -46,7 +46,7 @@ include(../../hostcommon/files.cmake) if(MSVC) # Host components don't try to handle asynchronous exceptions - add_compile_options(/EHsc) + set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHsc) elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU) # Prevents libc from calling pthread_cond_destroy on static objects in # dlopen()'ed library which we dlclose() in pal::unload_library. diff --git a/src/native/corehost/fxr/staticlib/CMakeLists.txt b/src/native/corehost/fxr/staticlib/CMakeLists.txt index 284d751f7c9079..6ff3bc27f74c19 100644 --- a/src/native/corehost/fxr/staticlib/CMakeLists.txt +++ b/src/native/corehost/fxr/staticlib/CMakeLists.txt @@ -32,7 +32,7 @@ if (MSVC) # We ship libhostfxr.lib as a static library for external consumption, so # LTCG must be disabled to ensure that non-MSVC toolchains can work with it. - target_compile_options(libhostfxr PRIVATE /GL-) + set_target_properties(libhostfxr PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF) string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE}) string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO}) diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt index 5ae3f76e8fe4db..818ed9ced7fce6 100644 --- a/src/native/corehost/nethost/CMakeLists.txt +++ b/src/native/corehost/nethost/CMakeLists.txt @@ -42,7 +42,7 @@ if (MSVC) # We ship libnethost.lib as a static library for external consumption, so # LTCG must be disabled to ensure that non-MSVC toolchains can work with it. - target_compile_options(libnethost PRIVATE /GL-) + set_target_properties(libnethost PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF) string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE}) string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO}) diff --git a/src/native/corehost/test/typelibs/CMakeLists.txt b/src/native/corehost/test/typelibs/CMakeLists.txt index 0b21548ef96fd2..ca39ef86f0a800 100644 --- a/src/native/corehost/test/typelibs/CMakeLists.txt +++ b/src/native/corehost/test/typelibs/CMakeLists.txt @@ -17,6 +17,7 @@ function(compile_idl idl_file tlb_out) /h ${CMAKE_CURRENT_BINARY_DIR}/${IDL_NAME}.h ${MIDL_DEFINITIONS} /out ${CMAKE_CURRENT_BINARY_DIR} /tlb ${tlb_out_local} + /nologo ${IDL_SOURCE} DEPENDS ${IDL_SOURCE} COMMENT "Compiling ${IDL_SOURCE}") diff --git a/src/native/external/libunwind_extras/CMakeLists.txt b/src/native/external/libunwind_extras/CMakeLists.txt index 245bd3823169e5..86db33a4fedd09 100644 --- a/src/native/external/libunwind_extras/CMakeLists.txt +++ b/src/native/external/libunwind_extras/CMakeLists.txt @@ -123,7 +123,6 @@ if(CLR_CMAKE_HOST_WIN32) endif () # Assume we are using default MSVC compiler - add_compile_options(/TC) # compile all files as C add_compile_options(/permissive-) # include paths @@ -162,6 +161,10 @@ endif() include(configure.cmake) include(${CLR_SRC_NATIVE_DIR}/external/libunwind.cmake) +if(CLR_CMAKE_HOST_WIN32) + set_source_files_properties(${LIBUNWIND_SOURCES} PROPERTIES COMPILE_FLAGS /TC) # compile all files as C +endif(CLR_CMAKE_HOST_WIN32) + if(CLR_CMAKE_HOST_UNIX) if(CLR_CMAKE_HOST_OSX) add_library(libunwind_dac OBJECT ${LIBUNWIND_SOURCES}) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index d6dfcb65bf3284..aac9b46c61c5dd 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -165,8 +165,8 @@ if(CLR_CMAKE_TARGET_WIN32) STATIC ${NATIVEGLOBALIZATION_SOURCES} ) - target_compile_options(System.Globalization.Native.Aot PRIVATE /guard:cf-) - target_compile_options(System.Globalization.Native.Aot PRIVATE /GL-) + set_target_properties(System.Globalization.Native.Aot PROPERTIES CLR_CONTROL_FLOW_GUARD OFF) + set_target_properties(System.Globalization.Native.Aot PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF) add_library(System.Globalization.Native.Aot.GuardCF STATIC diff --git a/src/native/libs/System.IO.Compression.Native/CMakeLists.txt b/src/native/libs/System.IO.Compression.Native/CMakeLists.txt index b8a726542ce3ad..0b1cdea3a594e2 100644 --- a/src/native/libs/System.IO.Compression.Native/CMakeLists.txt +++ b/src/native/libs/System.IO.Compression.Native/CMakeLists.txt @@ -136,8 +136,8 @@ else () STATIC ${NATIVECOMPRESSION_SOURCES} ) - target_compile_options(System.IO.Compression.Native.Aot PRIVATE /guard:cf-) - target_compile_options(System.IO.Compression.Native.Aot PRIVATE /GL-) + set_target_properties(System.IO.Compression.Native.Aot PROPERTIES CLR_CONTROL_FLOW_GUARD OFF) + set_target_properties(System.IO.Compression.Native.Aot PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF) add_library(System.IO.Compression.Native.Aot.GuardCF STATIC diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 6167f236a25baf..bb18388c940a0a 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -38,8 +38,7 @@ if (CLR_CMAKE_HOST_WIN32) # 5039 - pointer or reference to potentially throwing function passed to extern C function under -EHc. Undefined behavior may occur if this function throws an exception. add_compile_options(-wd4100 -wd4244 -wd4514 -wd4625 -wd4626 -wd4668 -wd4710 -wd4711 -wd4774 -wd4820 -wd5025 -wd5026 -wd5027 -wd5039) - string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - add_compile_options(/EHa) # enable C++ EH (w/ SEH exceptions) + set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHa) # enable C++ EH (w/ SEH exceptions) endif() MACRO(SUBDIRLIST result curdir)