Clean up our CMake scripts using features introduced between 3… (dotnet/coreclr#26980)
authorJeremy Koritzinsky <jekoritz@microsoft.com>
Mon, 7 Oct 2019 19:11:15 +0000 (12:11 -0700)
committerGitHub <noreply@github.com>
Mon, 7 Oct 2019 19:11:15 +0000 (12:11 -0700)
* Try to remove the CLR_CMAKE_COMPILER weirdness.

* Cleanup phase 1.

Fixes CMake's incremental build, but makes MSBuild complain about it's incremental build possibly not working.

* Drive dac and crossgen-specific defines through target properties.

* First pass of consolidation of singularly nested CMakeLists.txt files.

* Convert metadata libraries to not use leaf folders for dac/runtime/crossgen/dbi variations.

* Clean up some of the non-arm assembly file handling.

* Encapsulate arm/arm64 manual preprocessing and compilation of assembly files into a cmake function preprocess_compile_asm.

* Fix typo.

* Convert usages of add_precompiled_header to target_precompile_header everywhere except the jit.

* Clean up/remove some leaf CMake files that are just simple target creation (where most of the work was done in the parent).

* Remove unused CMakeLists file and folder.

* Clean up coreclr/CMakeLists.txt

* Remove conditions based on CMake version (since we're unifying on CMake 3.14)

* Convert final usages of add_precompiled_header to target_precompile_header and remove add_precompiled_header.

* Handle the AsmConstants.inc inclusion in cee_wks by marking it a header file instead of making a custom target.

* Move from deprecated FindPythonInterp module to FindPython module.

* Remove unused jitpch.cpp

* Fix typo.

* Have get_compile_definitions correctly split out generator expressions for multiple-valued generator expressions.

* preprocess_def_file -> preprocess_file and make it work xplat.

* Fix test build.

* Fix typo in flag.

* Fix resource building on non-windows.

* Fix other linker flag typo I missed.

* Add missing eventing_headers dependency.

* Fix multivalued generator expression.

* Use CMake 3.x features to significantly simplify toolchain.cmake.

* Remove references to LLDB from gen-buildsys-* (these aren't needed since SOS moved out of the repo).

* Remove debugging line

* Check check_pie_supported

* Clean up link flags.

* Fix copy-paste typo

* Cleanup. Change some conditions in configurecompiler to check for MSVC specifically, not Windows.

* Restore the llldb include and library path searching.

* Restore asmconstants_inc custom target.

Commit migrated from https://github.com/dotnet/coreclr/commit/59c7b7e84ab3a74d3939abd0c0f973d2bb9e8a70

119 files changed:
src/coreclr/CMakeLists.txt
src/coreclr/build.cmd
src/coreclr/clrdefinitions.cmake
src/coreclr/configure.cmake [deleted file]
src/coreclr/configurecompiler.cmake
src/coreclr/cross/toolchain.cmake
src/coreclr/crossgen.cmake [deleted file]
src/coreclr/dac.cmake [deleted file]
src/coreclr/functions.cmake
src/coreclr/pgosupport.cmake
src/coreclr/src/CMakeLists.txt
src/coreclr/src/ToolBox/SOS/diasdk/CMakeLists.txt [deleted file]
src/coreclr/src/ToolBox/SOS/diasdk/native.rc [deleted file]
src/coreclr/src/ToolBox/superpmi/mcs/CMakeLists.txt
src/coreclr/src/ToolBox/superpmi/superpmi-shared/standardpch.cpp [deleted file]
src/coreclr/src/ToolBox/superpmi/superpmi-shim-collector/CMakeLists.txt
src/coreclr/src/ToolBox/superpmi/superpmi-shim-counter/CMakeLists.txt
src/coreclr/src/ToolBox/superpmi/superpmi-shim-simple/CMakeLists.txt
src/coreclr/src/ToolBox/superpmi/superpmi/CMakeLists.txt
src/coreclr/src/binder/CMakeLists.txt
src/coreclr/src/binder/v3binder/CMakeLists.txt [deleted file]
src/coreclr/src/binder/v3binder_crossgen/CMakeLists.txt [deleted file]
src/coreclr/src/debug/daccess/CMakeLists.txt
src/coreclr/src/debug/daccess/stdafx.cpp [deleted file]
src/coreclr/src/debug/di/CMakeLists.txt
src/coreclr/src/debug/di/stdafx.cpp [deleted file]
src/coreclr/src/debug/ee/dac/CMakeLists.txt
src/coreclr/src/debug/ee/stdafx.cpp [deleted file]
src/coreclr/src/debug/ee/wks/CMakeLists.txt
src/coreclr/src/dlls/dbgshim/CMakeLists.txt
src/coreclr/src/dlls/mscordac/CMakeLists.txt
src/coreclr/src/dlls/mscordbi/CMakeLists.txt
src/coreclr/src/dlls/mscordbi/stdafx.cpp [deleted file]
src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt
src/coreclr/src/gcinfo/CMakeLists.txt
src/coreclr/src/gcinfo/crossgen/CMakeLists.txt [deleted file]
src/coreclr/src/gcinfo/lib/CMakeLists.txt [deleted file]
src/coreclr/src/jit/CMakeLists.txt
src/coreclr/src/jit/armelnonjit/CMakeLists.txt
src/coreclr/src/jit/crossgen/CMakeLists.txt
src/coreclr/src/jit/dll/CMakeLists.txt
src/coreclr/src/jit/jitpch.cpp [deleted file]
src/coreclr/src/jit/linuxnonjit/CMakeLists.txt
src/coreclr/src/jit/protojit/CMakeLists.txt
src/coreclr/src/jit/protononjit/CMakeLists.txt
src/coreclr/src/jit/standalone/CMakeLists.txt
src/coreclr/src/md/CMakeLists.txt
src/coreclr/src/md/ceefilegen/CMakeLists.txt
src/coreclr/src/md/ceefilegen/stdafx.cpp [deleted file]
src/coreclr/src/md/compiler/CMakeLists.txt
src/coreclr/src/md/compiler/crossgen/CMakeLists.txt [deleted file]
src/coreclr/src/md/compiler/dac/CMakeLists.txt [deleted file]
src/coreclr/src/md/compiler/dbi/CMakeLists.txt [deleted file]
src/coreclr/src/md/compiler/stdafx.cpp [deleted file]
src/coreclr/src/md/compiler/wks/CMakeLists.txt [deleted file]
src/coreclr/src/md/datasource/CMakeLists.txt
src/coreclr/src/md/datasource/dbi/CMakeLists.txt [deleted file]
src/coreclr/src/md/datasource/stdafx.cpp [deleted file]
src/coreclr/src/md/enc/CMakeLists.txt
src/coreclr/src/md/enc/crossgen/CMakeLists.txt [deleted file]
src/coreclr/src/md/enc/dac/CMakeLists.txt [deleted file]
src/coreclr/src/md/enc/dbi/CMakeLists.txt [deleted file]
src/coreclr/src/md/enc/stdafx.cpp [deleted file]
src/coreclr/src/md/enc/wks/CMakeLists.txt [deleted file]
src/coreclr/src/md/hotdata/CMakeLists.txt
src/coreclr/src/md/hotdata/crossgen/CMakeLists.txt [deleted file]
src/coreclr/src/md/hotdata/dac/CMakeLists.txt [deleted file]
src/coreclr/src/md/hotdata/external.cpp [deleted file]
src/coreclr/src/md/hotdata/full-staticcrt/CMakeLists.txt [deleted file]
src/coreclr/src/md/hotdata/full/CMakeLists.txt [deleted file]
src/coreclr/src/md/md_dac.cmake [deleted file]
src/coreclr/src/md/md_dbi.cmake [deleted file]
src/coreclr/src/md/md_wks.cmake [deleted file]
src/coreclr/src/md/runtime/CMakeLists.txt
src/coreclr/src/md/runtime/crossgen/CMakeLists.txt [deleted file]
src/coreclr/src/md/runtime/dac/CMakeLists.txt [deleted file]
src/coreclr/src/md/runtime/dbi/CMakeLists.txt [deleted file]
src/coreclr/src/md/runtime/stdafx.cpp [deleted file]
src/coreclr/src/md/runtime/wks/CMakeLists.txt [deleted file]
src/coreclr/src/md/winmd/CMakeLists.txt
src/coreclr/src/md/winmd/crossgen/CMakeLists.txt [deleted file]
src/coreclr/src/md/winmd/dac/CMakeLists.txt [deleted file]
src/coreclr/src/md/winmd/dbi/CMakeLists.txt [deleted file]
src/coreclr/src/md/winmd/wks/CMakeLists.txt [deleted file]
src/coreclr/src/pal/src/CMakeLists.txt
src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt
src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt
src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt
src/coreclr/src/pal/tools/gen-buildsys-clang.sh
src/coreclr/src/pal/tools/gen-buildsys-gcc.sh
src/coreclr/src/strongname/api/CMakeLists.txt
src/coreclr/src/strongname/api/crossgen/CMakeLists.txt [deleted file]
src/coreclr/src/strongname/api/dac/CMakeLists.txt [deleted file]
src/coreclr/src/strongname/api/tool/CMakeLists.txt [deleted file]
src/coreclr/src/strongname/api/wks/CMakeLists.txt [deleted file]
src/coreclr/src/tools/crossgen/CMakeLists.txt
src/coreclr/src/unwinder/CMakeLists.txt
src/coreclr/src/unwinder/dac/CMakeLists.txt [deleted file]
src/coreclr/src/unwinder/dac/hostwinamd64/CMakeLists.txt [deleted file]
src/coreclr/src/unwinder/wks/CMakeLists.txt [deleted file]
src/coreclr/src/utilcode/CMakeLists.txt
src/coreclr/src/utilcode/crossgen/CMakeLists.txt [deleted file]
src/coreclr/src/utilcode/dac/CMakeLists.txt [deleted file]
src/coreclr/src/utilcode/dyncrt/CMakeLists.txt [deleted file]
src/coreclr/src/utilcode/staticnohost/CMakeLists.txt [deleted file]
src/coreclr/src/utilcode/stdafx.cpp [deleted file]
src/coreclr/src/vm/CMakeLists.txt
src/coreclr/src/vm/common.cpp [deleted file]
src/coreclr/src/vm/crossgen/CMakeLists.txt
src/coreclr/src/vm/crossgen_mscorlib/CMakeLists.txt [deleted file]
src/coreclr/src/vm/dac/CMakeLists.txt [deleted file]
src/coreclr/src/vm/eventing/CMakeLists.txt
src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt
src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt
src/coreclr/src/vm/wks/CMakeLists.txt
src/coreclr/src/zap/CMakeLists.txt [new file with mode: 0644]
src/coreclr/src/zap/common.cpp [deleted file]
src/coreclr/src/zap/crossgen/CMakeLists.txt [deleted file]
src/coreclr/tests/CMakeLists.txt

index a4dcf76..3036bf5 100644 (file)
@@ -8,9 +8,6 @@ project(CoreCLR)
 # Include cmake functions
 include(functions.cmake)
 
-# Verify that LTCG/LTO is available
-include(configure.cmake)
-
 if (WIN32)
   message(STATUS "VS_PLATFORM_TOOLSET is ${CMAKE_VS_PLATFORM_TOOLSET}")
   message(STATUS "VS_PLATFORM_NAME is ${CMAKE_VS_PLATFORM_NAME}")
index 29af75d..0b3efab 100644 (file)
@@ -557,8 +557,6 @@ if %__BuildNative% EQU 1 (
 
     echo %__MsgPrefix%Regenerating the Visual Studio solution
 
-    echo Cross Arch Defines !___CrossBuildDefine!
-
     pushd "%__IntermediatesDir%"
     set __ExtraCmakeArgs=!___SDKVersion! !___CrossBuildDefine! "-DCLR_CMAKE_TARGET_OS=%__BuildOS%" "-DCLR_CMAKE_PACKAGES_DIR=%__PackagesDir%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_VERSION=%__PgoOptDataVersion%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%"
     call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs!
index 372b031..d4da74a 100644 (file)
@@ -10,6 +10,12 @@ if (PRERELEASE)
   # add_definitions(-DFEATURE_XXX)
 endif (PRERELEASE)
 
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>:DACCESS_COMPILE>)
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>:CROSSGEN_COMPILE>)
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>:CROSS_COMPILE>)
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>:FEATURE_NATIVE_IMAGE_GENERATION>)
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>:SELF_NO_HOST>)
+
 if (CLR_CMAKE_TARGET_ARCH_AMD64)
   if (CLR_CMAKE_PLATFORM_UNIX)
     add_definitions(-DDBG_TARGET_AMD64_UNIX)
@@ -73,7 +79,8 @@ endif(CLR_CMAKE_PLATFORM_ALPINE_LINUX)
 
 add_definitions(-D_BLD_CLR)
 add_definitions(-DDEBUGGING_SUPPORTED)
-add_definitions(-DPROFILING_SUPPORTED)
+add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>:PROFILING_SUPPORTED>)
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>:PROFILING_SUPPORTED_DATA>)
 
 if(WIN32)
   add_definitions(-DWIN32)
@@ -85,9 +92,9 @@ if(WIN32)
   if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
     # Only enable edit and continue on windows x86 and x64
     # exclude Linux, arm & arm64
-    add_definitions(-DEnC_SUPPORTED)
+    add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:EnC_SUPPORTED>)
   endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
-endif(WIN32)
+  endif(WIN32)
 
 # Features - please keep them alphabetically sorted
 if(WIN32)
@@ -100,7 +107,7 @@ else(WIN32)
   add_definitions(-DFEATURE_ARRAYSTUB_AS_IL)
   add_definitions(-DFEATURE_MULTICASTSTUB_AS_IL)
 endif(WIN32)
-add_definitions(-DFEATURE_CODE_VERSIONING)
+add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_CODE_VERSIONING>)
 add_definitions(-DFEATURE_COLLECTIBLE_TYPES)
 
 if(WIN32)
@@ -121,7 +128,7 @@ if(FEATURE_DBGIPC)
 endif(FEATURE_DBGIPC)
 add_definitions(-DFEATURE_DEFAULT_INTERFACES)
 if(FEATURE_EVENT_TRACE)
-    add_definitions(-DFEATURE_EVENT_TRACE)
+    add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_EVENT_TRACE>)
     add_definitions(-DFEATURE_PERFTRACING)
 endif(FEATURE_EVENT_TRACE)
 if(FEATURE_GDBJIT)
@@ -148,7 +155,7 @@ if (WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386 OR CLR_
     add_definitions(-DFEATURE_INTEROP_DEBUGGING)
 endif (WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_ARM64))
 if(FEATURE_INTERPRETER)
-  add_definitions(-DFEATURE_INTERPRETER)
+  add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_INTERPRETER>)
 endif(FEATURE_INTERPRETER)
 add_definitions(-DFEATURE_ISYM_READER)
 if (CLR_CMAKE_PLATFORM_LINUX OR WIN32)
@@ -159,27 +166,36 @@ add_definitions(-DFEATURE_MANAGED_ETW_CHANNELS)
 if(FEATURE_MERGE_JIT_AND_ENGINE)
   add_definitions(-DFEATURE_MERGE_JIT_AND_ENGINE)
 endif(FEATURE_MERGE_JIT_AND_ENGINE)
-add_definitions(-DFEATURE_MULTICOREJIT)
+add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_MULTICOREJIT>)
 if(CLR_CMAKE_PLATFORM_UNIX)
   add_definitions(-DFEATURE_PAL)
   add_definitions(-DFEATURE_PAL_ANSI)
 endif(CLR_CMAKE_PLATFORM_UNIX)
-if(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD)
+if(CLR_CMAKE_PLATFORM_LINUX)
     add_definitions(-DFEATURE_PERFMAP)
-endif(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD)
+endif(CLR_CMAKE_PLATFORM_LINUX)
+if(CLR_CMAKE_PLATFORM_FREEBSD)
+    add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_PERFMAP>)
+endif(CLR_CMAKE_PLATFORM_FREEBSD)
 if(FEATURE_PREJIT)
   add_definitions(-DFEATURE_PREJIT)
+else()
+  add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>:FEATURE_PREJIT>)
 endif(FEATURE_PREJIT)
 
 if(WIN32 OR CLR_CMAKE_PLATFORM_LINUX)
-    add_definitions(-DFEATURE_PROFAPI_ATTACH_DETACH)
+    add_compile_definitions($<$<AND:$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>,$<NOT:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>>:FEATURE_PROFAPI_ATTACH_DETACH>)
 endif(WIN32 OR CLR_CMAKE_PLATFORM_LINUX)
 
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>:DATA_PROFAPI_ATTACH_DETACH>)
+
 add_definitions(-DFEATURE_READYTORUN)
+
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>:FEATURE_READYTORUN_COMPILER>)
 set(FEATURE_READYTORUN 1)
 
 if (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
-  add_definitions(-DFEATURE_REJIT)
+  add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_REJIT>)
 endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
 
 if (CLR_CMAKE_PLATFORM_UNIX OR CLR_CMAKE_TARGET_ARCH_ARM64)
@@ -193,7 +209,7 @@ if (FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION)
 endif(FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION)
 add_definitions(-DFEATURE_SVR_GC)
 add_definitions(-DFEATURE_SYMDIFF)
-add_definitions(-DFEATURE_TIERED_COMPILATION)
+add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_TIERED_COMPILATION>)
 if (WIN32)
     add_definitions(-DFEATURE_TYPEEQUIVALENCE)
 endif(WIN32)
@@ -216,7 +232,7 @@ if((CLR_CMAKE_PLATFORM_ARCH_AMD64 OR CLR_CMAKE_PLATFORM_ARCH_ARM64) AND NOT WIN3
 endif((CLR_CMAKE_PLATFORM_ARCH_AMD64 OR CLR_CMAKE_PLATFORM_ARCH_ARM64) AND NOT WIN32)
 
 if(WIN32)
-    add_definitions(-DFEATURE_VERSIONING_LOG)
+    add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_VERSIONING_LOG>)
 endif(WIN32)
 if(NOT CLR_CMAKE_PLATFORM_UNIX)
     add_definitions(-DFEATURE_WIN32_REGISTRY)
diff --git a/src/coreclr/configure.cmake b/src/coreclr/configure.cmake
deleted file mode 100644 (file)
index 3af13f3..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-include(CheckCXXSourceCompiles)
-include(CheckCXXCompilerFlag)
-
-# VC++ guarantees support for LTCG (LTO's equivalent)
-if(NOT WIN32)
-  # Function required to give CMAKE_REQUIRED_* local scope
-  function(check_have_lto)
-    set(CMAKE_REQUIRED_FLAGS -flto)
-    set(CMAKE_REQUIRED_LIBRARIES -flto -fuse-ld=gold)
-    check_cxx_source_compiles("int main() { return 0; }" HAVE_LTO)
-  endfunction(check_have_lto)
-  check_have_lto()
-
-  check_cxx_compiler_flag(-faligned-new COMPILER_SUPPORTS_F_ALIGNED_NEW)
-endif(NOT WIN32)
index 525849b..8287698 100644 (file)
@@ -6,13 +6,20 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
 set(CMAKE_CXX_STANDARD 11)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
+cmake_policy(SET CMP0083 NEW)
+
+include(CheckPIESupported)
+include(CheckCXXCompilerFlag)
+
 # All code we build should be compiled as position independent
+check_pie_supported(OUTPUT_VARIABLE PIE_SUPPORT_OUTPUT LANGUAGES CXX)
+if(NOT MSVC AND NOT CMAKE_CXX_LINK_PIE_SUPPORTED)
+  message(WARNING "PIE is not supported at link time: ${PIE_SUPPORT_OUTPUT}.\n"
+                  "PIE link options will not be passed to linker.")
+endif()
 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 
-set(CLR_DEFINES_DEBUG_INIT              DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
-set(CLR_DEFINES_CHECKED_INIT            DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
-set(CLR_DEFINES_RELEASE_INIT            NDEBUG URTBLDENV_FRIENDLY=Retail)
-set(CLR_DEFINES_RELWITHDEBINFO_INIT     NDEBUG URTBLDENV_FRIENDLY=Retail)
+check_cxx_compiler_flag(-faligned-new COMPILER_SUPPORTS_F_ALIGNED_NEW)
 
 #----------------------------------------
 # Detect and set platform variable names
@@ -184,7 +191,7 @@ endif()
 # Initialize Cmake compiler flags and other variables
 #-----------------------------------------------------
 
-if(WIN32)
+if(MSVC)
     add_compile_options(/Zi /FC /Zc:strictStrings)
 elseif (CLR_CMAKE_PLATFORM_UNIX)
     add_compile_options(-g)
@@ -205,68 +212,66 @@ set(CMAKE_CXX_FLAGS_CHECKED "")
 set(CMAKE_EXE_LINKER_FLAGS_CHECKED "")
 set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "")
 
-set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc.
+add_compile_definitions("$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:DEBUG;_DEBUG;_DBG;URTBLDENV_FRIENDLY=Checked;BUILDENV_CHECKED=1>")
+add_compile_definitions("$<$<OR:$<CONFIG:RELEASE>,$<CONFIG:RELWITHDEBINFO>>:NDEBUG;URTBLDENV_FRIENDLY=Retail>")
 
-if (WIN32)
-  # For multi-configuration toolset (as Visual Studio)
-  # set the different configuration defines.
-  foreach (Config DEBUG CHECKED RELEASE RELWITHDEBINFO)
-    foreach (Definition IN LISTS CLR_DEFINES_${Config}_INIT)
-      set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:${Config}>:${Definition}>)
-    endforeach (Definition)
-  endforeach (Config)
+set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc.
 
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /GUARD:CF")
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF")
+if (MSVC)
+  add_link_options(/GUARD:CF)
 
   # Linker flags
   #
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") #Do not create Side-by-Side Assembly Manifest
+  set (WINDOWS_SUBSYSTEM_VERSION 6.01)
 
   if (CLR_CMAKE_PLATFORM_ARCH_ARM)
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.02") #windows subsystem - arm minimum is 6.02
+    set(WINDOWS_SUBSYSTEM_VERSION 6.02) #windows subsystem - arm minimum is 6.02
   elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.03") #windows subsystem - arm64 minimum is 6.03
-  else ()
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.01") #windows subsystem
+    set(WINDOWS_SUBSYSTEM_VERSION 6.03) #windows subsystem - arm64 minimum is 6.03
   endif ()
 
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE") # can handle addresses larger than 2 gigabytes
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NXCOMPAT") #Compatible with Data Execution Prevention
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DYNAMICBASE") #Use address space layout randomization
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /PDBCOMPRESS") #shrink pdb size
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG")
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4197,4013,4254,4070,4221")
+  #Do not create Side-by-Side Assembly Manifest
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/MANIFEST:NO>)
+  # can handle addresses larger than 2 gigabytes
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/LARGEADDRESSAWARE>)
+  #Compatible with Data Execution Prevention
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/NXCOMPAT>)
+  #Use address space layout randomization
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/DYNAMICBASE>)
+  #shrink pdb size
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/PDBCOMPRESS>)
+
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/DEBUG>)
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/IGNORE:4197,4013,4254,4070,4221>)
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:/SUBSYSTEM:WINDOWS,${WINDOWS_SUBSYSTEM_VERSION}>)
 
   set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221")
-
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /PDBCOMPRESS")
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1572864")
+  
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:/DEBUG>)
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:/PDBCOMPRESS>)
+  add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:/STACK:1572864>)
 
   # Debug build specific flags
-  set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/NOVCFEATURE ${NO_INCREMENTAL_LINKER_FLAGS}")
-  set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${NO_INCREMENTAL_LINKER_FLAGS}")
+  add_link_options($<$<AND:$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>>:/NOVCFEATURE>)
 
   # Checked build specific flags
-  set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "${CMAKE_SHARED_LINKER_FLAGS_CHECKED} /OPT:REF /OPT:NOICF /NOVCFEATURE ${NO_INCREMENTAL_LINKER_FLAGS}")
-  set(CMAKE_STATIC_LINKER_FLAGS_CHECKED "${CMAKE_STATIC_LINKER_FLAGS_CHECKED}")
-  set(CMAKE_EXE_LINKER_FLAGS_CHECKED "${CMAKE_EXE_LINKER_FLAGS_CHECKED} /OPT:REF /OPT:NOICF ${NO_INCREMENTAL_LINKER_FLAGS}")
+  add_link_options($<$<CONFIG:CHECKED>:/OPT:REF>)
+  add_link_options($<$<CONFIG:CHECKED>:/OPT:NOICF>)
 
   # Release build specific flags
-  set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
+  add_link_options($<$<CONFIG:RELEASE>:/LTCG>)
+  add_link_options($<$<CONFIG:RELEASE>:/OPT:REF>)
+  add_link_options($<$<CONFIG:RELEASE>:/OPT:ICF>)
   set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
-  set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
 
   # ReleaseWithDebugInfo build specific flags
-  set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
+  add_link_options($<$<CONFIG:RELWITHDEBINFO>:/LTCG>)
+  add_link_options($<$<CONFIG:RELWITHDEBINFO>:/OPT:REF>)
+  add_link_options($<$<CONFIG:RELWITHDEBINFO>:/OPT:ICF>)
   set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
-  set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
 
   # Force uCRT to be dynamically linked for Release build
-  set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
-  set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
-  set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
-  set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
+  add_link_options("$<$<CONFIG:RELEASE>:/NODEFAULTLIB:libucrt.lib;/DEFAULTLIB:ucrt.lib>")
 
 elseif (CLR_CMAKE_PLATFORM_UNIX)
   # Set the values to display when interactively configuring CMAKE_BUILD_TYPE
@@ -275,23 +280,8 @@ elseif (CLR_CMAKE_PLATFORM_UNIX)
   # Use uppercase CMAKE_BUILD_TYPE for the string comparisons below
   string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE)
 
-  # For single-configuration toolset
-  # set the different configuration defines.
-  if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
-    # First DEBUG
-    set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_DEBUG_INIT})
-  elseif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
-    # Then CHECKED
-    set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_CHECKED_INIT})
-  elseif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE)
-    # Then RELEASE
-    set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_RELEASE_INIT})
-  elseif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
-    # And then RELWITHDEBINFO
-    set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_RELWITHDEBINFO_INIT})
-  else ()
-    message(FATAL_ERROR "Unknown build type! Set CMAKE_BUILD_TYPE to DEBUG, CHECKED, RELEASE, or RELWITHDEBINFO!")
-  endif ()
+  set(CLR_SANITIZE_CXX_OPTIONS "")
+  set(CLR_SANITIZE_LINK_OPTIONS "")
 
   # set the CLANG sanitizer flags for debug build
   if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
@@ -299,9 +289,12 @@ elseif (CLR_CMAKE_PLATFORM_UNIX)
     string(FIND "$ENV{DEBUG_SANITIZERS}" "asan" __ASAN_POS)
     string(FIND "$ENV{DEBUG_SANITIZERS}" "ubsan" __UBSAN_POS)
     if ((${__ASAN_POS} GREATER -1) OR (${__UBSAN_POS} GREATER -1))
-      set(CLR_SANITIZE_CXX_FLAGS "${CLR_SANITIZE_CXX_FLAGS} -fsanitize-blacklist=${CMAKE_CURRENT_SOURCE_DIR}/sanitizerblacklist.txt -fsanitize=")
-      set(CLR_SANITIZE_LINK_FLAGS "${CLR_SANITIZE_LINK_FLAGS} -fsanitize=")
+      list(APPEND CLR_SANITIZE_CXX_OPTIONS -fsanitize-blacklist=${CMAKE_CURRENT_SOURCE_DIR}/sanitizerblacklist.txt)
+      set (CLR_CXX_SANITIZERS "")
+      set (CLR_LINK_SANITIZERS "")
       if (${__ASAN_POS} GREATER -1)
+        list(APPEND CLR_CXX_SANITIZERS address)
+        list(APPEND CLR_LINK_SANITIZERS address)
         set(CLR_SANITIZE_CXX_FLAGS "${CLR_SANITIZE_CXX_FLAGS}address,")
         set(CLR_SANITIZE_LINK_FLAGS "${CLR_SANITIZE_LINK_FLAGS}address,")
         add_definitions(-DHAS_ASAN)
@@ -309,30 +302,42 @@ elseif (CLR_CMAKE_PLATFORM_UNIX)
       endif ()
       if (${__UBSAN_POS} GREATER -1)
         # all sanitizier flags are enabled except alignment (due to heavy use of __unaligned modifier)
-        set(CLR_SANITIZE_CXX_FLAGS "${CLR_SANITIZE_CXX_FLAGS}bool,bounds,enum,float-cast-overflow,float-divide-by-zero,function,integer,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,unreachable,vla-bound,vptr")
-        set(CLR_SANITIZE_LINK_FLAGS "${CLR_SANITIZE_LINK_FLAGS}undefined")
+        list(APPEND CLR_CXX_SANITIZERS 
+          "bool"
+          bounds
+          enum
+          float-cast-overflow
+          float-divide-by-zero
+          "function"
+          integer
+          nonnull-attribute
+          null
+          object-size
+          "return"
+          returns-nonnull-attribute
+          shift
+          unreachable
+          vla-bound
+          vptr)
+        list(APPEND CLR_LINK_SANITIZERS
+          undefined)
         message("Undefined Behavior Sanitizer (ubsan) enabled")
       endif ()
+      list(JOIN CLR_CXX_SANITIZERS "," CLR_CXX_SANITIZERS_OPTIONS)
+      list(APPEND CLR_SANITIZE_CXX_OPTIONS "-fsanitize=${CLR_CXX_SANITIZERS_OPTIONS}")
+      list(JOIN CLR_LINK_SANITIZERS "," CLR_LINK_SANITIZERS_OPTIONS)
+      list(APPEND CLR_SANITIZE_LINK_OPTIONS "-fsanitize=${CLR_LINK_SANITIZERS_OPTIONS}")
 
       # -fdata-sections -ffunction-sections: each function has own section instead of one per .o file (needed for --gc-sections)
       # -O1: optimization level used instead of -O0 to avoid compile error "invalid operand for inline asm constraint"
-      set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CLR_SANITIZE_CXX_FLAGS} -fdata-sections -ffunction-sections  -O1")
-      set(CMAKE_CXX_FLAGS_CHECKED "${CMAKE_CXX_FLAGS_CHECKED} ${CLR_SANITIZE_CXX_FLAGS} -fdata-sections -ffunction-sections  -O1")
-
-      set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${CLR_SANITIZE_LINK_FLAGS}")
-      set(CMAKE_EXE_LINKER_FLAGS_CHECKED "${CMAKE_EXE_LINKER_FLAGS_CHECKED} ${CLR_SANITIZE_LINK_FLAGS}")
+      add_compile_definitions("$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>")
+      add_link_options($<$<AND:$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>>:${CLR_SANITIZE_LINK_OPTIONS}>)
 
       # -Wl and --gc-sections: drop unused sections\functions (similar to Windows /Gy function-level-linking)
-      set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${CLR_SANITIZE_LINK_FLAGS} -Wl,--gc-sections")
-      set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "${CMAKE_SHARED_LINKER_FLAGS_CHECKED} ${CLR_SANITIZE_LINK_FLAGS} -Wl,--gc-sections")
+      add_link_options("$<$<AND:$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>,$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>>:${CLR_SANITIZE_LINK_OPTIONS};-Wl,--gc-sections>")
     endif ()
   endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
-
-  # This linker option causes executables we build to be marked as containing position independent code.
-  # It is necessary to make ASLR work for executables.
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie" )
-
-endif(WIN32)
+endif(MSVC)
 
 # CLR_ADDITIONAL_LINKER_FLAGS - used for passing additional arguments to linker
 # CLR_ADDITIONAL_COMPILER_OPTIONS - used for passing additional arguments to compiler
@@ -341,19 +346,16 @@ endif(WIN32)
 #       ./build-native.sh cmakeargs "-DCLR_ADDITIONAL_COMPILER_OPTIONS=<...>" cmakeargs "-DCLR_ADDITIONAL_LINKER_FLAGS=<...>"
 #
 if(CLR_CMAKE_PLATFORM_UNIX)
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CLR_ADDITIONAL_LINKER_FLAGS}")
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CLR_ADDITIONAL_LINKER_FLAGS}" )
+    add_link_options(${CLR_ADDITIONAL_LINKER_FLAGS})
 endif(CLR_CMAKE_PLATFORM_UNIX)
 
 if(CLR_CMAKE_PLATFORM_LINUX)
-  set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1")
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1")
+  add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
+  add_link_options(-Wl,--build-id=sha1)
 endif(CLR_CMAKE_PLATFORM_LINUX)
 if(CLR_CMAKE_PLATFORM_FREEBSD)
-  set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld -Xlinker --build-id=sha1")
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld -Xlinker --build-id=sha1")
+  add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
+  add_link_options(-fuse-ld=lld LINKER:--build-id=sha1)
 endif(CLR_CMAKE_PLATFORM_FREEBSD)
 
 #------------------------------------
@@ -520,10 +522,9 @@ if (CLR_CMAKE_PLATFORM_UNIX)
 
   # Specify the minimum supported version of macOS
   if(CLR_CMAKE_PLATFORM_DARWIN)
-    set(MACOS_VERSION_MIN_FLAGS "-mmacosx-version-min=10.12")
-    add_compile_options("${MACOS_VERSION_MIN_FLAGS}")
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MACOS_VERSION_MIN_FLAGS}")
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MACOS_VERSION_MIN_FLAGS}")
+    set(MACOS_VERSION_MIN_FLAGS -mmacosx-version-min=10.12)
+    add_compile_options(${MACOS_VERSION_MIN_FLAGS})
+    add_link_options(${MACOS_VERSION_MIN_FLAGS})
   endif(CLR_CMAKE_PLATFORM_DARWIN)
 endif(CLR_CMAKE_PLATFORM_UNIX)
 
@@ -543,7 +544,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
   add_compile_options(${CLR_ADDITIONAL_COMPILER_OPTIONS})
 endif(CLR_CMAKE_PLATFORM_UNIX)
 
-if (WIN32)
+if (MSVC)
   # Compile options for targeting windows
 
   # The following options are set by the razzle build
@@ -595,17 +596,18 @@ if (WIN32)
   # For Release builds, we shall dynamically link into uCRT [ucrtbase.dll] (which is pushed down as a Windows Update on downlevel OS) but
   # wont do the same for debug/checked builds since ucrtbased.dll is not redistributable and Debug/Checked builds are not
   # production-time scenarios.
-  add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/MT>)
-  add_compile_options($<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:/MTd>)
 
-  set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /ZH:SHA_256")
+  add_compile_options($<$<OR:$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>,$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>:/MT>)
+  add_compile_options($<$<AND:$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>,$<NOT:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>>:/MTd>)
+
+  add_compile_options($<$<COMPILE_LANGUAGE:ASM_MASM>:/ZH:SHA_256>)
 
   if (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)
     # Contracts work too slow on ARM/ARM64 DEBUG/CHECKED.
     add_definitions(-DDISABLE_CONTRACTS)
   endif (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)
 
-endif (WIN32)
+endif (MSVC)
 
 if(CLR_CMAKE_ENABLE_CODE_COVERAGE)
 
@@ -617,9 +619,7 @@ if(CLR_CMAKE_ENABLE_CODE_COVERAGE)
 
     add_compile_options(-fprofile-arcs)
     add_compile_options(-ftest-coverage)
-    set(CLANG_COVERAGE_LINK_FLAGS  "--coverage")
-    set(CMAKE_SHARED_LINKER_FLAGS  "${CMAKE_SHARED_LINKER_FLAGS} ${CLANG_COVERAGE_LINK_FLAGS}")
-    set(CMAKE_EXE_LINKER_FLAGS     "${CMAKE_EXE_LINKER_FLAGS} ${CLANG_COVERAGE_LINK_FLAGS}")
+    add_link_options(--coverage)
   else()
     message(FATAL_ERROR "Code coverage builds not supported on current platform")
   endif(CLR_CMAKE_PLATFORM_UNIX)
index 75c2e27..0eea7d1 100644 (file)
@@ -35,15 +35,6 @@ if(DEFINED ENV{TOOLCHAIN})
   set(TOOLCHAIN $ENV{TOOLCHAIN})
 endif()
 
-# This gets called with CLR_CMAKE_COMPILER set on the first invocation
-# but the cmake variable is not getting populated into other calls.
-# Use environment variable to keep CLR_CMAKE_COMPILER around.
-if (NOT DEFINED CLR_CMAKE_COMPILER)
-  set(CLR_CMAKE_COMPILER $ENV{CLR_CMAKE_COMPILER})
-else()
-  set(ENV{CLR_CMAKE_COMPILER} ${CLR_CMAKE_COMPILER})
-endif()
-
 # Specify include paths
 if(TARGET_ARCH_NAME STREQUAL "armel")
   if(DEFINED TIZEN_TOOLCHAIN)
@@ -52,51 +43,25 @@ if(TARGET_ARCH_NAME STREQUAL "armel")
   endif()
 endif()
 
-# add_compile_param - adds only new options without duplicates.
-# arg0 - list with result options, arg1 - list with new options.
-# arg2 - optional argument, quick summary string for optional using CACHE FORCE mode.
-macro(add_compile_param)
-  if(NOT ${ARGC} MATCHES "^(2|3)$")
-    message(FATAL_ERROR "Wrong using add_compile_param! Two or three parameters must be given! See add_compile_param description.")
-  endif()
-  foreach(OPTION ${ARGV1})
-    if(NOT ${ARGV0} MATCHES "${OPTION}($| )")
-      set(${ARGV0} "${${ARGV0}} ${OPTION}")
-      if(${ARGC} EQUAL "3") # CACHE FORCE mode
-        set(${ARGV0} "${${ARGV0}}" CACHE STRING "${ARGV2}" FORCE)
-      endif()
-    endif()
-  endforeach()
-endmacro()
+set(CMAKE_SYSROOT "${CROSS_ROOTFS}")
+set(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr")
+set(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr")
+set(CMAKE_ASM_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr")
 
 # Specify link flags
-add_compile_param(CROSS_LINK_FLAGS "--sysroot=${CROSS_ROOTFS}")
-if (CLR_CMAKE_COMPILER STREQUAL "Clang")
-  add_compile_param(CROSS_LINK_FLAGS "--gcc-toolchain=${CROSS_ROOTFS}/usr")
-  add_compile_param(CROSS_LINK_FLAGS "--target=${TOOLCHAIN}")
-endif()
 
 if(TARGET_ARCH_NAME STREQUAL "armel")
   if(DEFINED TIZEN_TOOLCHAIN) # For Tizen only
-    add_compile_param(CROSS_LINK_FLAGS "-B${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
-    add_compile_param(CROSS_LINK_FLAGS "-L${CROSS_ROOTFS}/lib")
-    add_compile_param(CROSS_LINK_FLAGS "-L${CROSS_ROOTFS}/usr/lib")
-    add_compile_param(CROSS_LINK_FLAGS "-L${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
+    add_link_options("-B${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
+    add_link_options("-L${CROSS_ROOTFS}/lib")
+    add_link_options("-L${CROSS_ROOTFS}/usr/lib")
+    add_link_options("-L${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
   endif()
 elseif(TARGET_ARCH_NAME STREQUAL "x86")
-  add_compile_param(CROSS_LINK_FLAGS "-m32")
+  add_link_options(-m32)
 endif()
 
-add_compile_param(CMAKE_EXE_LINKER_FLAGS "${CROSS_LINK_FLAGS}" "TOOLCHAIN_EXE_LINKER_FLAGS")
-add_compile_param(CMAKE_SHARED_LINKER_FLAGS "${CROSS_LINK_FLAGS}" "TOOLCHAIN_EXE_LINKER_FLAGS")
-add_compile_param(CMAKE_MODULE_LINKER_FLAGS "${CROSS_LINK_FLAGS}" "TOOLCHAIN_EXE_LINKER_FLAGS")
-
 # Specify compile options
-add_compile_options("--sysroot=${CROSS_ROOTFS}")
-if (CLR_CMAKE_COMPILER STREQUAL "Clang")
-  add_compile_options("--target=${TOOLCHAIN}")
-  add_compile_options("--gcc-toolchain=${CROSS_ROOTFS}/usr")
-endif()
 
 if(TARGET_ARCH_NAME MATCHES "^(arm|armel|arm64)$")
   set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN})
@@ -119,7 +84,7 @@ elseif(TARGET_ARCH_NAME STREQUAL "x86")
   add_compile_options(-Wno-error=unused-command-line-argument)
 endif()
 
-# Set LLDB include and library paths
+# Set LLDB include and library paths for builds that need lldb.
 if(TARGET_ARCH_NAME MATCHES "^(arm|armel|x86)$")
   if(TARGET_ARCH_NAME STREQUAL "x86")
     set(LLVM_CROSS_DIR "$ENV{LLVM_CROSS_HOME}")
@@ -147,7 +112,7 @@ if(TARGET_ARCH_NAME MATCHES "^(arm|armel|x86)$")
   endif()
 endif()
 
-set(CMAKE_FIND_ROOT_PATH "${CROSS_ROOTFS}")
+
 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/src/coreclr/crossgen.cmake b/src/coreclr/crossgen.cmake
deleted file mode 100644 (file)
index 6f416bf..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-# Contains the crossgen build specific definitions. Included by the leaf crossgen cmake files.
-
-add_definitions(
-    -DFEATURE_PREJIT
-    -DCROSSGEN_COMPILE
-    -DCROSS_COMPILE
-    -DFEATURE_NATIVE_IMAGE_GENERATION
-    -DSELF_NO_HOST)
-
-remove_definitions(
-    -DFEATURE_CODE_VERSIONING
-    -DEnC_SUPPORTED
-    -DFEATURE_EVENT_TRACE
-    -DFEATURE_INTERPRETER
-    -DFEATURE_MULTICOREJIT
-    -DFEATURE_PERFMAP
-    -DFEATURE_REJIT
-    -DFEATURE_TIERED_COMPILATION
-    -DFEATURE_VERSIONING_LOG
-    -DFEATURE_PROFAPI_ATTACH_DETACH
-)
-
-if(FEATURE_READYTORUN)
-    add_definitions(-DFEATURE_READYTORUN_COMPILER)
-endif(FEATURE_READYTORUN)
-
-if(CLR_CMAKE_PLATFORM_LINUX)
-    add_definitions(-DFEATURE_PERFMAP)
-endif(CLR_CMAKE_PLATFORM_LINUX)
diff --git a/src/coreclr/dac.cmake b/src/coreclr/dac.cmake
deleted file mode 100644 (file)
index 82da3d2..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# Contains the dac build specific definitions. Included by the leaf dac cmake files.
-
-add_definitions(-DDACCESS_COMPILE)
-if(WIN32)    
-    add_definitions(-MT)
-endif(WIN32)
-
-remove_definitions(-DPROFILING_SUPPORTED)
-add_definitions(-DPROFILING_SUPPORTED_DATA)
-
-remove_definitions(-DFEATURE_PROFAPI_ATTACH_DETACH)
-add_definitions(-DDATA_PROFAPI_ATTACH_DETACH)
index d868445..14d376d 100644 (file)
@@ -13,15 +13,38 @@ function(get_compile_definitions DefinitionName)
     # Get the current list of definitions
     get_directory_property(COMPILE_DEFINITIONS_LIST COMPILE_DEFINITIONS)
 
+    # The entries that contain generator expressions must have the -D inside of the
+    # expression. So we transform e.g. $<$<CONFIG:Debug>:_DEBUG> to $<$<CONFIG:Debug>:-D_DEBUG>
+
+    # CMake's support for multiple values within a single generator expression is somewhat ad-hoc.
+    # Since we have a number of complex generator expressions, we use them with multiple values to ensure that
+    # we don't forget to update all of the generator expressions if one needs to be updated.
+    # As a result, we need to expand out the multi-valued generator expression to wrap each individual value here.
+    # Otherwise, CMake will fail to expand it.
+    set(LastGeneratorExpression "")
     foreach(DEFINITION IN LISTS COMPILE_DEFINITIONS_LIST)
-        if (${DEFINITION} MATCHES "^\\$<\\$<CONFIG:([^>]+)>:([^>]+)>$")
-            # The entries that contain generator expressions must have the -D inside of the
-            # expression. So we transform e.g. $<$<CONFIG:Debug>:_DEBUG> to $<$<CONFIG:Debug>:-D_DEBUG>
-            set(DEFINITION "$<$<CONFIG:${CMAKE_MATCH_1}>:-D${CMAKE_MATCH_2}>")
+      # If there is a definition that uses the $<TARGET_PROPERTY:prop> generator expression
+      # we need to remove it since that generator expression is only valid on binary targets.
+      # Assume that the value is 0.
+      string(REGEX REPLACE "\\$<TARGET_PROPERTY:[^,>]+>" "0" DEFINITION "${DEFINITION}")
+
+      if (${DEFINITION} MATCHES "^\\$<(.+):([^>]+)(>?)$")
+        if("${CMAKE_MATCH_3}" STREQUAL "")
+          set(DEFINITION "$<${CMAKE_MATCH_1}:-D${CMAKE_MATCH_2}>")
+          set(LastGeneratorExpression "${CMAKE_MATCH_1}")
         else()
-            set(DEFINITION -D${DEFINITION})
+          set(DEFINITION "$<${CMAKE_MATCH_1}:-D${CMAKE_MATCH_2}>")
         endif()
-        list(APPEND DEFINITIONS ${DEFINITION})
+      elseif(${DEFINITION} MATCHES "([^>]+)>$")
+        # This entry is the last in a list nested within a generator expression.
+        set(DEFINITION "$<${LastGeneratorExpression}:-D${CMAKE_MATCH_1}>")
+        set(LastGeneratorExpression "")
+      elseif(NOT "${LastGeneratorExpression}" STREQUAL "")
+        set(DEFINITION "$<${LastGeneratorExpression}:-D${DEFINITION}>")
+      else()
+        set(DEFINITION -D${DEFINITION})
+      endif()
+      list(APPEND DEFINITIONS ${DEFINITION})
     endforeach()
     set(${DefinitionName} ${DEFINITIONS} PARENT_SCOPE)
 endfunction(get_compile_definitions)
@@ -71,21 +94,74 @@ function(convert_to_absolute_path RetSources)
     set(${RetSources} ${AbsolutePathSources} PARENT_SCOPE)
 endfunction(convert_to_absolute_path)
 
-#Preprocess exports definition file
-function(preprocess_def_file inputFilename outputFilename)
+#Preprocess file
+function(preprocess_file inputFilename outputFilename)
   get_compile_definitions(PREPROCESS_DEFINITIONS)
-  get_include_directories(ASM_INCLUDE_DIRECTORIES)
-  add_custom_command(
-    OUTPUT ${outputFilename}
-    COMMAND ${CMAKE_CXX_COMPILER} ${ASM_INCLUDE_DIRECTORIES} /P /EP /TC ${PREPROCESS_DEFINITIONS}  /Fi${outputFilename}  ${inputFilename}
-    DEPENDS ${inputFilename}
-    COMMENT "Preprocessing ${inputFilename} - ${CMAKE_CXX_COMPILER} ${ASM_INCLUDE_DIRECTORIES} /P /EP /TC ${PREPROCESS_DEFINITIONS}  /Fi${outputFilename}  ${inputFilename}"
-  )
+  get_include_directories(PREPROCESS_INCLUDE_DIRECTORIES)
+  if (MSVC)
+    add_custom_command(
+        OUTPUT ${outputFilename}
+        COMMAND ${CMAKE_CXX_COMPILER} ${PREPROCESS_INCLUDE_DIRECTORIES} /P /EP /TC ${PREPROCESS_DEFINITIONS}  /Fi${outputFilename}  ${inputFilename}
+        DEPENDS ${inputFilename}
+        COMMENT "Preprocessing ${inputFilename}. Outputting to ${outputFilename}"
+    )
+  else()
+    add_custom_command(
+        OUTPUT ${outputFilename}
+        COMMAND ${CMAKE_CXX_COMPILER} -E -P ${PREPROCESS_DEFINITIONS} ${PREPROCESS_INCLUDE_DIRECTORIES} -o ${outputFilename} -x c ${inputFilename}
+        DEPENDS ${inputFilename}
+        COMMENT "Preprocessing ${inputFilename}. Outputting to ${outputFilename}"
+    )
+  endif()
 
   set_source_files_properties(${outputFilename}
                               PROPERTIES GENERATED TRUE)
 endfunction()
 
+# preprocess_compile_asm(ASM_FILES file1 [file2 ...] OUTPUT_OBJECTS [variableName])
+function(preprocess_compile_asm)
+  set(options "")
+  set(oneValueArgs OUTPUT_OBJECTS)
+  set(multiValueArgs ASM_FILES)
+  cmake_parse_arguments(PARSE_ARGV 0 COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}")
+  
+  get_include_directories_asm(ASM_INCLUDE_DIRECTORIES)
+
+  set (ASSEMBLED_OBJECTS "")
+
+  foreach(ASM_FILE ${COMPILE_ASM_ASM_FILES})
+    # Inserts a custom command in CMake build to preprocess each asm source file
+    get_filename_component(name ${ASM_FILE} NAME_WE)
+    file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${name}.asm" ASM_PREPROCESSED_FILE)
+    preprocess_file(${ASM_FILE} ${ASM_PREPROCESSED_FILE})
+
+    # We do not pass any defines since we have already done pre-processing above
+    set (ASM_CMDLINE "-o ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj ${ASM_PREPROCESSED_FILE}")
+
+    # Generate the batch file that will invoke the assembler
+    file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/runasm_${name}.cmd" ASM_SCRIPT_FILE)
+
+    file(GENERATE OUTPUT "${ASM_SCRIPT_FILE}"
+        CONTENT "\"${CMAKE_ASM_MASM_COMPILER}\" -g ${ASM_INCLUDE_DIRECTORIES} ${ASM_CMDLINE}")
+
+    message("Generated  - ${ASM_SCRIPT_FILE}")
+
+    # Need to compile asm file using custom command as include directories are not provided to asm compiler
+    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj
+                        COMMAND ${ASM_SCRIPT_FILE}
+                        DEPENDS ${ASM_PREPROCESSED_FILE}
+                        COMMENT "Assembling ${ASM_PREPROCESSED_FILE} - ${ASM_SCRIPT_FILE}")
+
+    # mark obj as source that does not require compile
+    set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${name}.obj PROPERTIES EXTERNAL_OBJECT TRUE)
+
+    # Add the generated OBJ in the dependency list so that it gets consumed during linkage
+    list(APPEND ASSEMBLED_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj)
+  endforeach()
+
+  set(${COMPILE_ASM_OUTPUT_OBJECTS} ${ASSEMBLED_OBJECTS} PARENT_SCOPE)
+endfunction()
+
 function(generate_exports_file)
   set(INPUT_LIST ${ARGN})
   list(GET INPUT_LIST -1 outputFilename)
@@ -128,33 +204,56 @@ function(generate_exports_file_prefix inputFilename outputFilename prefix)
                               PROPERTIES GENERATED TRUE)
 endfunction()
 
-function(add_precompiled_header header cppFile targetSources)
+# target_precompile_header(TARGET targetName HEADER headerName [ADDITIONAL_INCLUDE_DIRECTORIES includeDirs])
+function(target_precompile_header)
+  set(options "")
+  set(oneValueArgs TARGET HEADER)
+  set(multiValueArgs ADDITIONAL_INCLUDE_DIRECTORIES)
+  cmake_parse_arguments(PARSE_ARGV 0 PRECOMPILE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}")
+
+  if ("${PRECOMPILE_HEADERS_TARGET}" STREQUAL "")
+  message(SEND_ERROR "No target supplied to target_precompile_header.")
+  endif()
+  if ("${PRECOMPILE_HEADERS_HEADER}" STREQUAL "")
+    message(SEND_ERROR "No header supplied to target_precompile_header.")
+  endif()
+
   if(MSVC)
-    set(precompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/stdafx.pch")
-
-    set_source_files_properties(${cppFile}
-                                PROPERTIES COMPILE_FLAGS "/Yc\"${header}\" /Fp\"${precompiledBinary}\""
-                                           OBJECT_OUTPUTS "${precompiledBinary}")
-    set_source_files_properties(${${targetSources}}
-                                PROPERTIES COMPILE_FLAGS "/Yu\"${header}\" /Fp\"${precompiledBinary}\""
-                                           OBJECT_DEPENDS "${precompiledBinary}")
-    # Add cppFile to SourcesVar
-    set(${targetSources} ${${targetSources}} ${cppFile} PARENT_SCOPE)
+    get_filename_component(PCH_NAME ${PRECOMPILE_HEADERS_HEADER} NAME_WE)
+    # We need to use the $<TARGET_PROPERTY:NAME> generator here instead of the ${targetName} variable since
+    # CMake evaluates source file properties once per directory. If we just use ${targetName}, we end up sharing
+    # the same PCH between targets, which doesn't work.
+    set(precompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${PCH_NAME}.$<TARGET_PROPERTY:NAME>.pch")
+    set(pchSourceFile "${CMAKE_CURRENT_BINARY_DIR}/${PCH_NAME}.${PRECOMPILE_HEADERS_TARGET}.cpp")
+
+    file(GENERATE OUTPUT ${pchSourceFile} CONTENT "#include \"${PRECOMPILE_HEADERS_HEADER}\"")
+
+    set(PCH_SOURCE_FILE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} ${PRECOMPILE_HEADERS_ADDITIONAL_INCLUDE_DIRECTORIES})
+
+    set_source_files_properties(${pchSourceFile}
+                                PROPERTIES COMPILE_FLAGS "/Yc\"${PRECOMPILE_HEADERS_HEADER}\" /Fp\"${precompiledBinary}\""
+                                            OBJECT_OUTPUTS "${precompiledBinary}"
+                                            INCLUDE_DIRECTORIES "${PCH_SOURCE_FILE_INCLUDE_DIRECTORIES}")
+    get_target_property(TARGET_SOURCES ${PRECOMPILE_HEADERS_TARGET} SOURCES)
+
+    foreach (SOURCE ${TARGET_SOURCES})
+      get_source_file_property(SOURCE_LANG ${SOURCE} LANGUAGE)
+      if (("${SOURCE_LANG}" STREQUAL "C") OR ("${SOURCE_LANG}" STREQUAL "CXX"))
+        set_source_files_properties(${SOURCE}
+          PROPERTIES COMPILE_FLAGS "/Yu\"${PRECOMPILE_HEADERS_HEADER}\" /Fp\"${precompiledBinary}\""
+                      OBJECT_DEPENDS "${precompiledBinary}")
+      endif()
+    endforeach()
+
+    # Add pchSourceFile to PRECOMPILE_HEADERS_TARGET target
+    target_sources(${PRECOMPILE_HEADERS_TARGET} PRIVATE ${pchSourceFile})
   endif(MSVC)
 endfunction()
 
 function(strip_symbols targetName outputFilename)
   if (CLR_CMAKE_PLATFORM_UNIX)
     if (STRIP_SYMBOLS)
-
-      # On the older version of cmake (2.8.12) used on Ubuntu 14.04 the TARGET_FILE
-      # generator expression doesn't work correctly returning the wrong path and on
-      # the newer cmake versions the LOCATION property isn't supported anymore.
-      if (CMAKE_VERSION VERSION_EQUAL 3.0 OR CMAKE_VERSION VERSION_GREATER 3.0)
-          set(strip_source_file $<TARGET_FILE:${targetName}>)
-      else()
-          get_property(strip_source_file TARGET ${targetName} PROPERTY LOCATION)
-      endif()
+      set(strip_source_file $<TARGET_FILE:${targetName}>)
 
       if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
         set(strip_destination_file ${strip_source_file}.dwarf)
@@ -190,17 +289,13 @@ function(install_clr targetName)
   list(FIND CLR_CROSS_COMPONENTS_LIST ${targetName} INDEX)
   if (NOT DEFINED CLR_CROSS_COMPONENTS_LIST OR NOT ${INDEX} EQUAL -1)
     strip_symbols(${targetName} strip_destination_file)
-    # On the older version of cmake (2.8.12) used on Ubuntu 14.04 the TARGET_FILE
-    # generator expression doesn't work correctly returning the wrong path and on
-    # the newer cmake versions the LOCATION property isn't supported anymore.
-    if(CMAKE_VERSION VERSION_EQUAL 3.0 OR CMAKE_VERSION VERSION_GREATER 3.0)
-       set(install_source_file $<TARGET_FILE:${targetName}>)
-    else()
-        get_property(install_source_file TARGET ${targetName} PROPERTY LOCATION)
-    endif()
 
-    install(PROGRAMS ${install_source_file} DESTINATION .)
+    # We don't need to install the export libraries for our DLLs
+    # since they won't be directly linked against.
+    install(PROGRAMS $<TARGET_FILE:${targetName}> DESTINATION .)
     if(WIN32)
+        # We can't use the $<TARGET_PDB_FILE> generator expression here since
+        # the generator expression isn't supported on resource DLLs.
         install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb DESTINATION PDB)
     else()
         install(FILES ${strip_destination_file} DESTINATION .)
index dec0500..59a0373 100644 (file)
@@ -1,3 +1,6 @@
+include(CheckIPOSupported)
+check_ipo_supported(RESULT HAVE_LTO)
+
 # Adds Profile Guided Optimization (PGO) flags to the current target
 function(add_pgo TargetName)
     if(WIN32)
index 94214cf..d4b491c 100644 (file)
@@ -38,19 +38,17 @@ if(CLR_CMAKE_PLATFORM_UNIX)
   # variable specified by the TARGET_FILE parameter.
   function(build_resources SOURCE TARGET_NAME TARGET_FILE)
 
-    get_compile_definitions(PREPROCESS_DEFINITIONS)
-    get_include_directories(INCLUDE_DIRECTORIES)
-
     set(PREPROCESSED_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.rc.i)
+
+    preprocess_file(${SOURCE} ${PREPROCESSED_SOURCE})
+
     set(RESOURCE_ENTRY_ARRAY_CPP ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.cpp)
 
     add_custom_command(
       OUTPUT ${RESOURCE_ENTRY_ARRAY_CPP}
-      # Preprocess the windows .rc file
-      COMMAND ${CMAKE_CXX_COMPILER} -E -P ${PREPROCESS_DEFINITIONS} ${INCLUDE_DIRECTORIES} -o ${PREPROCESSED_SOURCE} -x c ${SOURCE}
       # Convert the preprocessed .rc file to a C++ file which will be used to make a static lib.
       COMMAND ${AWK} -v name=${TARGET_NAME} -f ${RC_TO_CPP} -f ${PROCESS_RC} ${PREPROCESSED_SOURCE} >${RESOURCE_ENTRY_ARRAY_CPP}
-            DEPENDS ${SOURCE} ${RC_TO_CPP} ${PROCESS_RC}
+            DEPENDS ${PREPROCESSED_SOURCE} ${RC_TO_CPP} ${PROCESS_RC}
     )
 
     include_directories(${RESOURCE_STRING_HEADER_DIR})
diff --git a/src/coreclr/src/ToolBox/SOS/diasdk/CMakeLists.txt b/src/coreclr/src/ToolBox/SOS/diasdk/CMakeLists.txt
deleted file mode 100644 (file)
index 07bbcdc..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# replace backslashes in path with forward slash
-STRING(REGEX REPLACE "\\\\" "/" VSINSTALLDIR $ENV{VSINSTALLDIR} )
-
-# Generate managed type lib from dia2.idl
-add_custom_target(dialib ALL
-    # generate tlb file from idl
-    COMMAND midl.exe /I"${VSINSTALLDIR}DIA SDK/include" /tlb ${CMAKE_CURRENT_BINARY_DIR}/dia2.tlb  /Zp8  "${VSINSTALLDIR}DIA SDK/idl/dia2.idl"
-    # run tlbimp to generate managed type library
-    COMMAND TlbImp.exe /silent /namespace:Dia /unsafe /strictref:nopia ${CMAKE_CURRENT_BINARY_DIR}/dia2.tlb /out:${CMAKE_CURRENT_BINARY_DIR}/dialib.dll
-    COMMENT Generating managed type library from dia2.idl
-)
-
-# In order to use dialib.dll as library target it needs to be imported into cmake
-# Target is used in ToolBox/SOS/dactablegen/cmakelists.txt
-add_library_clr(dialib_dll SHARED IMPORTED GLOBAL)
-set_property(TARGET dialib_dll PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/dialib.dll)
diff --git a/src/coreclr/src/ToolBox/SOS/diasdk/native.rc b/src/coreclr/src/ToolBox/SOS/diasdk/native.rc
deleted file mode 100644 (file)
index 4c1007f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-#define FX_VER_FILEDESCRIPTION_STR "Microsoft\0"
-
-#include <fxver.h>
-#include <fxver.rc>
index 9f1bde4..5a6a0e3 100644 (file)
@@ -43,15 +43,10 @@ set(MCS_SOURCES
     ../superpmi-shared/spmidumphelper.cpp
 )
 
-add_precompiled_header(
-    standardpch.h
-    ../superpmi-shared/standardpch.cpp
-    MCS_SOURCES
-)
-
 _add_executable(mcs
     ${MCS_SOURCES}
 )
+target_precompile_header(TARGET mcs HEADER standardpch.h)
 
 if(CLR_CMAKE_PLATFORM_UNIX)
     target_link_libraries(mcs
diff --git a/src/coreclr/src/ToolBox/superpmi/superpmi-shared/standardpch.cpp b/src/coreclr/src/ToolBox/superpmi/superpmi-shared/standardpch.cpp
deleted file mode 100644 (file)
index b614443..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-// Don't touch this file: it's just here to create a precompiled header...
-#include "standardpch.h"
index d79d3a5..5faf3be 100644 (file)
@@ -35,15 +35,8 @@ set(SUPERPMI_SHIM_COLLECTOR_SOURCES
     ../superpmi-shared/typeutils.cpp
     ../superpmi-shared/spmidumphelper.cpp
 )
-
-add_precompiled_header(
-    standardpch.h
-    ../superpmi-shared/standardpch.cpp
-    SUPERPMI_SHIM_COLLECTOR_SOURCES
-)
-
 if (WIN32)
-    preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/superpmi-shim-collector.def ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-collector.def)
+    preprocess_file(${CMAKE_CURRENT_SOURCE_DIR}/superpmi-shim-collector.def ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-collector.def)
 
     list(APPEND SUPERPMI_SHIM_COLLECTOR_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-collector.def)
 endif (WIN32)
@@ -53,6 +46,8 @@ _add_library(superpmi-shim-collector
     ${SUPERPMI_SHIM_COLLECTOR_SOURCES}
 )
 
+target_precompile_header(TARGET superpmi-shim-collector HEADER standardpch.h)
+
 if(CLR_CMAKE_PLATFORM_UNIX)
     target_link_libraries(superpmi-shim-collector
         utilcodestaticnohost
index 3330c65..2c0a27c 100644 (file)
@@ -37,14 +37,8 @@ set(SUPERPMI_SHIM_COUNTER_SOURCES
     ../superpmi-shared/spmidumphelper.cpp
 )
 
-add_precompiled_header(
-    standardpch.h
-    ../superpmi-shared/standardpch.cpp
-    SUPERPMI_SHIM_COUNTER_SOURCES
-)
-
 if (WIN32)
-    preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/superpmi-shim-counter.def ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-counter.def)
+    preprocess_file(${CMAKE_CURRENT_SOURCE_DIR}/superpmi-shim-counter.def ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-counter.def)
 
     list(APPEND SUPERPMI_SHIM_COUNTER_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-counter.def)
 endif (WIN32)
@@ -54,6 +48,8 @@ _add_library(superpmi-shim-counter
     ${SUPERPMI_SHIM_COUNTER_SOURCES}
 )
 
+target_precompile_header(TARGET superpmi-shim-counter HEADER standardpch.h)
+
 if(CLR_CMAKE_PLATFORM_UNIX)
     target_link_libraries(superpmi-shim-counter
         utilcodestaticnohost
index 1b6e847..f97d57f 100644 (file)
@@ -36,14 +36,8 @@ set(SUPERPMI_SHIM_SIMPLE_SOURCES
     ../superpmi-shared/spmidumphelper.cpp
 )
 
-add_precompiled_header(
-    standardpch.h
-    ../superpmi-shared/standardpch.cpp
-    SUPERPMI_SHIM_SIMPLE_SOURCES
-)
-
 if (WIN32)
-    preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/superpmi-shim-simple.def ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-simple.def)
+    preprocess_file(${CMAKE_CURRENT_SOURCE_DIR}/superpmi-shim-simple.def ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-simple.def)
 
     list(APPEND SUPERPMI_SHIM_SIMPLE_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-simple.def)
 endif (WIN32)
@@ -53,6 +47,8 @@ _add_library(superpmi-shim-simple
     ${SUPERPMI_SHIM_SIMPLE_SOURCES}
 )
 
+target_precompile_header(TARGET superpmi-shim-simple HEADER standardpch.h)
+
 if(CLR_CMAKE_PLATFORM_UNIX)
     target_link_libraries(superpmi-shim-simple
         utilcodestaticnohost
index 3bb3c6f..a6a7011 100644 (file)
@@ -43,16 +43,12 @@ set(SUPERPMI_SOURCES
     ../superpmi-shared/spmidumphelper.cpp
 )
 
-add_precompiled_header(
-    standardpch.h
-    ../superpmi-shared/standardpch.cpp
-    SUPERPMI_SOURCES
-)
-
 _add_executable(superpmi
     ${SUPERPMI_SOURCES}
 )
 
+target_precompile_header(TARGET superpmi HEADER standardpch.h)
+
 if(CLR_CMAKE_PLATFORM_UNIX)
     target_link_libraries(superpmi
         utilcodestaticnohost
index 07f6c15..46f46e3 100644 (file)
@@ -91,5 +91,16 @@ endif(WIN32)
 convert_to_absolute_path(BINDER_SOURCES ${BINDER_SOURCES})
 convert_to_absolute_path(BINDER_CROSSGEN_SOURCES ${BINDER_CROSSGEN_SOURCES})
 
-add_subdirectory(v3binder)
-add_subdirectory(v3binder_crossgen)
+add_library_clr(v3binder
+    STATIC
+    ${BINDER_SOURCES}
+)
+add_dependencies(v3binder eventing_headers)
+
+add_library_clr(v3binder_crossgen
+    STATIC
+    ${BINDER_CROSSGEN_SOURCES}
+)
+add_dependencies(v3binder_crossgen eventing_headers)
+set_target_properties(v3binder_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+
diff --git a/src/coreclr/src/binder/v3binder/CMakeLists.txt b/src/coreclr/src/binder/v3binder/CMakeLists.txt
deleted file mode 100644 (file)
index 70a66eb..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-add_library_clr(v3binder
-    STATIC
-    ${BINDER_SOURCES}
-)
-
-add_dependencies(v3binder eventing_headers)
diff --git a/src/coreclr/src/binder/v3binder_crossgen/CMakeLists.txt b/src/coreclr/src/binder/v3binder_crossgen/CMakeLists.txt
deleted file mode 100644 (file)
index 06dd0d8..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-include(${CLR_DIR}/crossgen.cmake)
-
-add_library_clr(v3binder_crossgen
-    STATIC
-    ${BINDER_CROSSGEN_SOURCES}
-)
-
-add_dependencies(v3binder_crossgen eventing_headers)
index 241a629..bad942e 100644 (file)
@@ -1,6 +1,3 @@
-
-include(${CLR_DIR}/dac.cmake)
-
 add_definitions(-DFEATURE_NO_HOST)
 
 include_directories(BEFORE ${VM_DIR})
@@ -38,9 +35,9 @@ include_directories(${ARCH_SOURCES_DIR})
 
 convert_to_absolute_path(DACCESS_SOURCES ${DACCESS_SOURCES})
 
-add_precompiled_header(stdafx.h stdafx.cpp DACCESS_SOURCES)
-
 add_library_clr(daccess ${DACCESS_SOURCES})
+set_target_properties(daccess PROPERTIES DAC_COMPONENT TRUE)
+target_precompile_header(TARGET daccess HEADER stdafx.h)
 
 add_dependencies(daccess eventing_headers)
 
diff --git a/src/coreclr/src/debug/daccess/stdafx.cpp b/src/coreclr/src/debug/daccess/stdafx.cpp
deleted file mode 100644 (file)
index f508973..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//*****************************************************************************
-// File: stdafx.cpp
-// 
-
-//
-// Host for precompiled headers.
-//
-//*****************************************************************************
-#include "stdafx.h"                                            // Precompiled header key.
index 1c34eac..7f0ca8b 100644 (file)
@@ -59,34 +59,7 @@ if(WIN32)
 
     if ((CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64) AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
         convert_to_absolute_path(CORDBDI_SOURCES_ASM_FILE ${CORDBDI_SOURCES_ASM_FILE})
-
-        # Inserts a custom command in CMake build to preprocess each asm source file
-        get_filename_component(name ${CORDBDI_SOURCES_ASM_FILE} NAME_WE)
-        file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${name}.asm" ASM_PREPROCESSED_FILE)
-        preprocess_def_file(${CORDBDI_SOURCES_ASM_FILE} ${ASM_PREPROCESSED_FILE})
-
-        # We do not pass any defines since we have already done pre-processing above
-        set (ASM_CMDLINE "-o ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj ${ASM_PREPROCESSED_FILE}")
-
-        # Generate the batch file that will invoke the assembler
-        file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/runasm_${name}.cmd" ASM_SCRIPT_FILE)
-
-        file(GENERATE OUTPUT "${ASM_SCRIPT_FILE}"
-            CONTENT "\"${CMAKE_ASM_MASM_COMPILER}\" -g ${ASM_CMDLINE}")
-
-        message("Generated  - ${ASM_SCRIPT_FILE}")
-
-        # Need to compile asm file using custom command as include directories are not provided to asm compiler
-        add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj
-                            COMMAND ${ASM_SCRIPT_FILE}
-                            DEPENDS ${ASM_PREPROCESSED_FILE}
-                            COMMENT "Assembling ${ASM_PREPROCESSED_FILE} - ${ASM_SCRIPT_FILE}")
-
-        # mark obj as source that does not require compile
-        set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${name}.obj PROPERTIES EXTERNAL_OBJECT TRUE)
-
-        # Add the generated OBJ in the dependency list so that it gets consumed during linkage
-        set(CORDBDI_SOURCES_ASM_FILE ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj)
+        preprocess_compile_asm(ASM_FILES ${CORDBDI_SOURCES_ASM_FILE} OUTPUT_OBJECTS CORDBDI_SOURCES_ASM_FILE)
     endif()
 elseif(CLR_CMAKE_PLATFORM_UNIX)
 
@@ -98,8 +71,6 @@ elseif(CLR_CMAKE_PLATFORM_UNIX)
 
 endif(WIN32)
 
-add_precompiled_header(stdafx.h stdafx.cpp CORDBDI_SOURCES)
-
 if (WIN32)
     convert_to_absolute_path(CORDBDI_HEADERS ${CORDBDI_HEADERS})
     list(APPEND CORDBDI_SOURCES ${CORDBDI_HEADERS})
@@ -108,4 +79,5 @@ endif (WIN32)
 list(APPEND CORDBDI_SOURCES ${CORDBDI_SOURCES_ASM_FILE})
 
 add_library_clr(cordbdi STATIC ${CORDBDI_SOURCES})
+target_precompile_header(TARGET cordbdi HEADER stdafx.h)
 add_dependencies(cordbdi eventing_headers)
diff --git a/src/coreclr/src/debug/di/stdafx.cpp b/src/coreclr/src/debug/di/stdafx.cpp
deleted file mode 100644 (file)
index 91eba13..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//*****************************************************************************
-//     stdafx.cpp
-// 
-
-//
-//     Host for precompiled header.
-//
-//*****************************************************************************
-#include "stdafx.h"                                            // Precompiled header key.
index ceae5c9..feb6947 100644 (file)
@@ -1,11 +1,9 @@
 
-include(${CLR_DIR}/dac.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp CORDBEE_SOURCES_DAC)
-
 if (WIN32)
   list(APPEND CORDBEE_SOURCES_DAC ${CORDBEE_HEADERS_DAC})
 endif (WIN32)
 
 add_library_clr(cordbee_dac ${CORDBEE_SOURCES_DAC})
+set_target_properties(cordbee_dac PROPERTIES DAC_COMPONENT TRUE)
+target_precompile_header(TARGET cordbee_dac HEADER stdafx.h)
 add_dependencies(cordbee_dac eventing_headers)
diff --git a/src/coreclr/src/debug/ee/stdafx.cpp b/src/coreclr/src/debug/ee/stdafx.cpp
deleted file mode 100644 (file)
index f508973..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//*****************************************************************************
-// File: stdafx.cpp
-// 
-
-//
-// Host for precompiled headers.
-//
-//*****************************************************************************
-#include "stdafx.h"                                            // Precompiled header key.
index 6a1a47c..aa1bc13 100644 (file)
@@ -1,7 +1,5 @@
 if (WIN32)
 
-  add_precompiled_header(stdafx.h ../stdafx.cpp CORDBEE_SOURCES_WKS)
-
   list(APPEND CORDBEE_SOURCES_WKS ${CORDBEE_HEADERS_WKS})
 
   get_include_directories(ASM_INCLUDE_DIRECTORIES)
@@ -11,28 +9,9 @@ if (WIN32)
 
   if(CLR_CMAKE_PLATFORM_ARCH_ARM OR CLR_CMAKE_PLATFORM_ARCH_ARM64)
 
-    get_filename_component(name ${ASM_FILE} NAME_WE)
-    file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${name}.asm" ASM_PREPROCESSED_FILE)
-    preprocess_def_file(${ASM_FILE} ${ASM_PREPROCESSED_FILE})
-
-    # We do not pass any defines since we have already done pre-processing above
-    set (ASM_CMDLINE "-o ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj ${ASM_PREPROCESSED_FILE}")
-
-    # Generate the batch file that will invoke the assembler
-    file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/runasm_${name}.cmd" ASM_SCRIPT_FILE)
-
-    file(GENERATE OUTPUT "${ASM_SCRIPT_FILE}"
-         CONTENT "\"${CMAKE_ASM_MASM_COMPILER}\" -g ${ASM_CMDLINE}")
+    preprocess_compile_asm(ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS)
 
-    message("Generated  - ${ASM_SCRIPT_FILE}")
-
-    # Need to compile asm file using custom command as include directories are not provided to asm compiler
-    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj
-                       COMMAND ${ASM_SCRIPT_FILE}
-                       DEPENDS ${ASM_PREPROCESSED_FILE}
-                       COMMENT "Assembling ${ASM_PREPROCESSED_FILE} - ${ASM_SCRIPT_FILE}")
-
-    add_library_clr(cordbee_wks ${CORDBEE_SOURCES_WKS} ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj)
+    add_library_clr(cordbee_wks ${CORDBEE_SOURCES_WKS} ${ASM_OBJECTS})
 
   else ()
 
@@ -42,13 +21,9 @@ if (WIN32)
       list (APPEND ASM_OPTIONS /safeseh)
     endif (CLR_CMAKE_PLATFORM_ARCH_I386)
 
-    # Need to compile asm file using custom command as include directories are not provided to asm compiler
-    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dbghelpers.obj
-                       COMMAND ${CMAKE_ASM_MASM_COMPILER} ${ASM_INCLUDE_DIRECTORIES} ${ASM_DEFINITIONS} ${ASM_OPTIONS} /Fo${CMAKE_CURRENT_BINARY_DIR}/dbghelpers.obj /Ta${ASM_FILE}
-                       DEPENDS ${ASM_FILE}
-                       COMMENT "Compiling dbghelpers.asm")
-
-    add_library_clr(cordbee_wks ${CORDBEE_SOURCES_WKS} ${CMAKE_CURRENT_BINARY_DIR}/dbghelpers.obj)
+    set_source_files_properties(${ASM_FILE} PROPERTIES COMPILE_OPTIONS "${ASM_OPTIONS}")
+    
+    add_library_clr(cordbee_wks ${CORDBEE_SOURCES_WKS} ${ASM_FILE})
 
   endif()
 
@@ -62,4 +37,5 @@ else ()
 
 endif (WIN32)
 
+target_precompile_header(TARGET cordbee_wks HEADER stdafx.h)
 add_dependencies(cordbee_wks eventing_headers)
index ca4556b..7a0275b 100644 (file)
@@ -16,7 +16,7 @@ if(WIN32)
         dbgshim.rc
     )
 
-    preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/dbgshim.ntdef ${CMAKE_CURRENT_BINARY_DIR}/dbgshim.def)
+    preprocess_file(${CMAKE_CURRENT_SOURCE_DIR}/dbgshim.ntdef ${CMAKE_CURRENT_BINARY_DIR}/dbgshim.def)
     list(APPEND DBGSHIM_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dbgshim.def)
 else(WIN32)
     set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dbgshim_unixexports.src)
index df8d615..715381d 100644 (file)
@@ -1,4 +1,3 @@
-include(${CLR_DIR}/dac.cmake)
 add_definitions(-DFEATURE_NO_HOST)
 
 set(CLR_DAC_SOURCES
@@ -17,7 +16,7 @@ if(WIN32)
     set(CURRENT_BINARY_DIR_FOR_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
 
     # Preprocess exports definition file
-    preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/${DEF_SOURCES} ${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def)
+    preprocess_file(${CMAKE_CURRENT_SOURCE_DIR}/${DEF_SOURCES} ${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def)
 
     # Create target to add file dependency on mscordac.def
     add_custom_target(mscordaccore_def DEPENDS ${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def)
@@ -103,6 +102,8 @@ _add_library(mscordacobj OBJECT mscordac.cpp)
 
 add_library_clr(mscordaccore SHARED ${CLR_DAC_SOURCES} $<TARGET_OBJECTS:mscordacobj>)
 
+set_target_properties(mscordacobj mscordaccore PROPERTIES DAC_COMPONENT TRUE)
+
 if(CLR_CMAKE_PLATFORM_LINUX)
     add_dependencies(mscordaccore lib_redefines_inc)
 endif(CLR_CMAKE_PLATFORM_LINUX)
index 87823a3..78bff40 100644 (file)
@@ -19,9 +19,7 @@ if(CLR_CMAKE_PLATFORM_LINUX)
     list(APPEND MSCORDBI_SOURCES ${PAL_REDEFINES_FILE})
 endif(CLR_CMAKE_PLATFORM_LINUX)
 
-if(WIN32)
-    add_precompiled_header(stdafx.h stdafx.cpp MSCORDBI_SOURCES)
-    
+if(WIN32)    
     add_definitions(-DFX_VER_INTERNALNAME_STR=mscordbi.dll)
 
     list(APPEND MSCORDBI_SOURCES
@@ -34,7 +32,7 @@ if(WIN32)
 
     convert_to_absolute_path(DEF_SOURCES ${DEF_SOURCES})
 
-    preprocess_def_file(${DEF_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.def)
+    preprocess_file(${DEF_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.def)
 
     list(APPEND MSCORDBI_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.def)
 else(WIN32)
@@ -58,6 +56,7 @@ if(CLR_CMAKE_PLATFORM_DARWIN)
 endif(CLR_CMAKE_PLATFORM_DARWIN)
 
 add_library_clr(mscordbi SHARED ${MSCORDBI_SOURCES})
+target_precompile_header(TARGET mscordbi HEADER stdafx.h)
 
 if(CLR_CMAKE_PLATFORM_UNIX)
     add_custom_target(mscordbi_exports DEPENDS ${EXPORTS_FILE})
diff --git a/src/coreclr/src/dlls/mscordbi/stdafx.cpp b/src/coreclr/src/dlls/mscordbi/stdafx.cpp
deleted file mode 100644 (file)
index a23e304..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//*****************************************************************************
-// stdafx.cpp
-//
-// Precompiled headers.
-//
-//*****************************************************************************
-#include "stdafx.h"
index 7c684a0..0b89ee0 100644 (file)
@@ -1,22 +1,22 @@
 if (WIN32)
-    preprocess_def_file(${DEF_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def)
+    preprocess_file(${DEF_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def)
 
     list(APPEND CLR_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def)
 
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /ENTRY:CoreDllMain")
+    add_link_options(/ENTRY:CoreDllMain)
 
     # Incremental linking results in the linker inserting extra padding and routing function calls via thunks that can break the
     # invariants (e.g. size of region between Jit_PatchedCodeLast-Jit_PatchCodeStart needs to fit in a page).
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /INCREMENTAL:NO")
+    add_link_options(/INCREMENTAL:NO)
 
     # Delay load libraries required for WinRT as that is not supported on all platforms
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll")
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll")
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:api-ms-win-core-winrt-roparameterizediid-l1-1-0.dll")
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:api-ms-win-ro-typeresolution-l1-1-0.dll")
+    add_link_options("/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll")
+    add_link_options("/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll")
+    add_link_options("/DELAYLOAD:api-ms-win-core-winrt-roparameterizediid-l1-1-0.dll")
+    add_link_options("/DELAYLOAD:api-ms-win-ro-typeresolution-l1-1-0.dll")
 
     # Delay load version.dll so that we can specify how to search when loading it as it is not part of Windows' known DLLs
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:version.dll")
+    add_link_options("/DELAYLOAD:version.dll")
 
     # No library groups for Win32
     set(START_LIBRARY_GROUP)
@@ -31,7 +31,7 @@ else()
     if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD)
         # This option is necessary to ensure that the overloaded delete operator defined inside
         # of the utilcode will be used instead of the standard library delete operator.
-        set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic -Xlinker -Bsymbolic-functions")
+        add_link_options("LINKER:-Bsymbolic,-Bsymbolic-functions")
 
         # The following linked options can be inserted into the linker libraries list to
         # ensure proper resolving of circular references between a subset of the libraries.
@@ -181,19 +181,15 @@ if(WIN32)
         include(${CMAKE_INSTALL_PREFIX}/${CLR_CMAKE_CROSS_HOST_ARCH}/dactabletools/dactabletools.cmake)
       endif()
 
-      set(DACTABLEGEN_EXE $<TARGET_FILE:dactablegen>)
-      set(INJECT_RESOURCE_EXE $<TARGET_FILE:InjectResource>)
-      set(GEN_CLR_DEBUG_RESOURCE_EXE $<TARGET_FILE:GenClrDebugResource>)
-
       add_custom_command(
           DEPENDS coreclr mscordaccore mscordbi ${CLR_DIR}/src/debug/daccess/daccess.cpp
           OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources.timestamp
           COMMAND ${CMAKE_CXX_COMPILER} /P /EP /TP ${PREPROCESS_DEFINITIONS} ${INC_DIR} /Fi${CMAKE_CURRENT_BINARY_DIR}/daccess.i  ${CLR_DIR}/src/debug/daccess/daccess.cpp
-          COMMAND ${DACTABLEGEN_EXE} /dac:${CMAKE_CURRENT_BINARY_DIR}/daccess.i /pdb:${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/coreclr.pdb /dll:$<TARGET_FILE:coreclr> /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin
-          COMMAND ${INJECT_RESOURCE_EXE} /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin /dll:$<TARGET_FILE:coreclr>
-          COMMAND ${GEN_CLR_DEBUG_RESOURCE_EXE} /dac:$<TARGET_FILE:mscordaccore> /dbi:$<TARGET_FILE:mscordbi> /sku:onecoreclr /out:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin
-          COMMAND ${INJECT_RESOURCE_EXE} /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$<TARGET_FILE:coreclr> /name:CLRDEBUGINFO
-          COMMAND ${INJECT_RESOURCE_EXE} /bin:${CMAKE_CURRENT_SOURCE_DIR}/dump_helper_resource.bin /dll:$<TARGET_FILE:coreclr> /name:MINIDUMP_AUXILIARY_PROVIDER
+          COMMAND dactablegen /dac:${CMAKE_CURRENT_BINARY_DIR}/daccess.i /pdb:${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/coreclr.pdb /dll:$<TARGET_FILE:coreclr> /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin
+          COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin /dll:$<TARGET_FILE:coreclr>
+          COMMAND GenClrDebugResource /dac:$<TARGET_FILE:mscordaccore> /dbi:$<TARGET_FILE:mscordbi> /sku:onecoreclr /out:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin
+          COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$<TARGET_FILE:coreclr> /name:CLRDEBUGINFO
+          COMMAND InjectResource /bin:${CMAKE_CURRENT_SOURCE_DIR}/dump_helper_resource.bin /dll:$<TARGET_FILE:coreclr> /name:MINIDUMP_AUXILIARY_PROVIDER
           COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources.timestamp
           COMMENT Add dactable, debug resources, and dump helper resources to coreclr
       )
index c9c60db..970b1a9 100644 (file)
@@ -16,8 +16,18 @@ endif(CLR_CMAKE_TARGET_ARCH_I386)
 
 convert_to_absolute_path(GCINFO_SOURCES ${GCINFO_SOURCES})
 
-add_subdirectory(lib)
-add_subdirectory(crossgen)
+add_library_clr(gcinfo
+    STATIC
+    ${GCINFO_SOURCES}
+)
+
+add_library_clr(gcinfo_crossgen
+    STATIC
+    ${GCINFO_SOURCES}
+)
+
+set_target_properties(gcinfo_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+
 
 if (CLR_CMAKE_PLATFORM_ARCH_I386)
     # On x86, build RyuJIT/ARM32 cross-compiling altjit.
diff --git a/src/coreclr/src/gcinfo/crossgen/CMakeLists.txt b/src/coreclr/src/gcinfo/crossgen/CMakeLists.txt
deleted file mode 100644 (file)
index 5e16521..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-include(${CLR_DIR}/crossgen.cmake)
-
-add_library_clr(gcinfo_crossgen
-    STATIC
-    ${GCINFO_SOURCES}
-)
diff --git a/src/coreclr/src/gcinfo/lib/CMakeLists.txt b/src/coreclr/src/gcinfo/lib/CMakeLists.txt
deleted file mode 100644 (file)
index ec44c2b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-add_library_clr(gcinfo
-    STATIC
-    ${GCINFO_SOURCES}
-)
index ea122ad..feda3ad 100644 (file)
@@ -296,10 +296,9 @@ convert_to_absolute_path(JIT_ARM64_SOURCES ${JIT_ARM64_SOURCES})
 
 
 if(WIN32)
-  add_precompiled_header(jitpch.h ../jitpch.cpp SOURCES)
   set(CLRJIT_EXPORTS ${CMAKE_CURRENT_LIST_DIR}/ClrJit.exports)
   set(JIT_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/ClrJit.exports.def)
-  preprocess_def_file (${CLRJIT_EXPORTS} ${JIT_EXPORTS_FILE})
+  preprocess_file (${CLRJIT_EXPORTS} ${JIT_EXPORTS_FILE})
 
   set(SHARED_LIB_SOURCES ${SOURCES} ${JIT_EXPORTS_FILE})
 else()
@@ -351,6 +350,8 @@ else()
     )
 endif(CLR_CMAKE_PLATFORM_UNIX)
 
+set(JIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+
 if (FEATURE_MERGE_JIT_AND_ENGINE)
   # Despite the directory being named "dll", it creates a static library "clrjit_static" to link into the VM.
   add_subdirectory(dll)
index dea4374..341aff6 100644 (file)
@@ -50,6 +50,8 @@ add_library_clr(armelnonjit
    ${JIT_ARCH_ALTJIT_SOURCES}
 )
 
+target_precompile_header(TARGET armelnonjit HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR})
+
 add_dependencies(armelnonjit jit_exports)
 
 set_property(TARGET armelnonjit APPEND_STRING PROPERTY LINK_FLAGS ${JIT_EXPORTS_LINKER_OPTION})
index e68bf59..331556f 100644 (file)
@@ -1,6 +1,6 @@
-include(${CLR_DIR}/crossgen.cmake)
-
 add_library_clr(clrjit_crossgen ${SOURCES} ${JIT_ARCH_SOURCES})
 if(FEATURE_MERGE_JIT_AND_ENGINE)
   target_link_libraries(clrjit_crossgen ${RYUJIT_LINK_LIBRARIES})
 endif(FEATURE_MERGE_JIT_AND_ENGINE)
+set_target_properties(clrjit_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+target_precompile_header(TARGET clrjit_crossgen HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR})
index 624e357..2e8a254 100644 (file)
@@ -15,3 +15,4 @@ else()
       ${JIT_ARCH_SOURCES}
     )
 endif(CLR_CMAKE_PLATFORM_UNIX)
+target_precompile_header(TARGET clrjit_static HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR})
diff --git a/src/coreclr/src/jit/jitpch.cpp b/src/coreclr/src/jit/jitpch.cpp
deleted file mode 100644 (file)
index 74300ae..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-/*****************************************************************************/
-
-#include "jitpch.h"
index bcd11cf..aeed813 100644 (file)
@@ -34,6 +34,7 @@ add_library_clr(linuxnonjit
    ${SHARED_LIB_SOURCES}
    ${JIT_ARCH_ALTJIT_SOURCES}
 )
+target_precompile_header(TARGET linuxnonjit HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR})
 
 add_dependencies(linuxnonjit jit_exports)
 
index b5d4e08..533d541 100644 (file)
@@ -21,6 +21,8 @@ add_library_clr(protojit
    ${JIT_ARCH_SOURCES}
 )
 
+target_precompile_header(TARGET protojit HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR})
+
 add_dependencies(protojit jit_exports)
 
 set_property(TARGET protojit APPEND_STRING PROPERTY LINK_FLAGS ${JIT_EXPORTS_LINKER_OPTION})
index 9517333..f7466a8 100644 (file)
@@ -48,6 +48,8 @@ add_library_clr(protononjit
    ${JIT_ARCH_ALTJIT_SOURCES}
 )
 
+target_precompile_header(TARGET protononjit HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR})
+
 add_dependencies(protononjit jit_exports)
 
 set_property(TARGET protononjit APPEND_STRING PROPERTY LINK_FLAGS ${JIT_EXPORTS_LINKER_OPTION})
index f893ddc..572bfc7 100644 (file)
@@ -20,6 +20,8 @@ add_library_clr(clrjit
    ${JIT_ARCH_SOURCES}
 )
 
+target_precompile_header(TARGET clrjit HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR})
+
 add_dependencies(clrjit jit_exports)
 
 set_property(TARGET clrjit APPEND_STRING PROPERTY LINK_FLAGS ${JIT_EXPORTS_LINKER_OPTION})
index a640b09..7899de1 100644 (file)
@@ -1,3 +1,19 @@
+
+add_compile_definitions(FEATURE_METADATA_EMIT)
+add_compile_definitions(FEATURE_METADATA_INTERNAL_APIS)
+add_compile_definitions($<$<OR:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>,$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>>:FEATURE_METADATA_EMIT_IN_DEBUGGER>)
+add_compile_definitions($<$<NOT:$<OR:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>,$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>>>:FEATURE_METADATA_IN_VM>)
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>:FEATURE_METADATA_CUSTOM_DATA_SOURCE>)
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>:FEATURE_METADATA_DEBUGGEE_DATA_SOURCE>)
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>:FEATURE_METADATA_LOAD_TRUSTED_IMAGES>)
+add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>:FEATURE_METADATA_RELEASE_MEMORY_ON_REOPEN>)
+
+if (WIN32)
+    add_compile_options($<$<AND:$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>,$<CONFIG:DEBUG>>:-MTd>)
+    add_compile_options($<$<AND:$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>,$<NOT:$<CONFIG:DEBUG>>>:-MT>)
+    add_compile_definitions($<$<NOT:$<OR:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>,$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>>>:FEATURE_METADATA_VERIFY_LAYOUTS>)
+endif()
+
 add_subdirectory(compiler)
 add_subdirectory(runtime)
 add_subdirectory(enc)
@@ -6,5 +22,5 @@ add_subdirectory(ceefilegen)
 add_subdirectory(datasource)
 add_subdirectory(staticmd)
 if(WIN32)
-add_subdirectory(winmd)
+    add_subdirectory(winmd)
 endif(WIN32)
index 57d4cb6..75faa16 100644 (file)
@@ -21,8 +21,6 @@ set(CEEFILEGEN_HEADERS
     ../../inc/utilcode.h
 )
 
-add_precompiled_header(stdafx.h stdafx.cpp CEEFILEGEN_SOURCES)
-
 if (WIN32)
     list(APPEND CEEFILEGEN_SOURCES ${CEEFILEGEN_HEADERS})
 endif (WIN32)
@@ -31,3 +29,4 @@ add_library_clr(ceefgen
     STATIC
     ${CEEFILEGEN_SOURCES}
 )
+target_precompile_header(TARGET ceefgen HEADER stdafx.h)
diff --git a/src/coreclr/src/md/ceefilegen/stdafx.cpp b/src/coreclr/src/md/ceefilegen/stdafx.cpp
deleted file mode 100644 (file)
index 91eba13..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//*****************************************************************************
-//     stdafx.cpp
-// 
-
-//
-//     Host for precompiled header.
-//
-//*****************************************************************************
-#include "stdafx.h"                                            // Precompiled header key.
index 260731d..cc9ba34 100644 (file)
@@ -51,7 +51,22 @@ set(MDCOMPILER_HEADERS
 convert_to_absolute_path(MDCOMPILER_SOURCES ${MDCOMPILER_SOURCES})
 convert_to_absolute_path(MDCOMPILER_HEADERS ${MDCOMPILER_HEADERS})
 
-add_subdirectory(dac)
-add_subdirectory(wks)
-add_subdirectory(dbi)
-add_subdirectory(crossgen)
+if (WIN32)
+    list(APPEND MDCOMPILER_SOURCES ${MDCOMPILER_HEADERS})
+endif()
+
+add_library_clr(mdcompiler_dac ${MDCOMPILER_SOURCES})
+set_target_properties(mdcompiler_dac PROPERTIES DAC_COMPONENT TRUE)
+target_precompile_header(TARGET mdcompiler_dac HEADER stdafx.h)
+
+add_library_clr(mdcompiler_wks ${MDCOMPILER_SOURCES})
+target_compile_definitions(mdcompiler_wks PRIVATE FEATURE_METADATA_EMIT_ALL)
+target_precompile_header(TARGET mdcompiler_wks HEADER stdafx.h)
+
+add_library_clr(mdcompiler-dbi ${MDCOMPILER_SOURCES})
+set_target_properties(mdcompiler-dbi PROPERTIES DBI_COMPONENT TRUE)
+target_precompile_header(TARGET mdcompiler-dbi HEADER stdafx.h)
+
+add_library_clr(mdcompiler_crossgen ${MDCOMPILER_SOURCES})
+set_target_properties(mdcompiler_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+target_precompile_header(TARGET mdcompiler_crossgen HEADER stdafx.h)
diff --git a/src/coreclr/src/md/compiler/crossgen/CMakeLists.txt b/src/coreclr/src/md/compiler/crossgen/CMakeLists.txt
deleted file mode 100644 (file)
index e732ef6..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-include(${CLR_DIR}/crossgen.cmake)
-include(../../md_wks.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDCOMPILER_SOURCES)
-
-if (WIN32)
-    list(APPEND MDCOMPILER_SOURCES ${MDCOMPILER_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdcompiler_crossgen ${MDCOMPILER_SOURCES})
diff --git a/src/coreclr/src/md/compiler/dac/CMakeLists.txt b/src/coreclr/src/md/compiler/dac/CMakeLists.txt
deleted file mode 100644 (file)
index 80041f3..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-
-include(${CLR_DIR}/dac.cmake)
-include(../../md_dac.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDCOMPILER_SOURCES)
-
-if (WIN32)
-    list(APPEND MDCOMPILER_SOURCES ${MDCOMPILER_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdcompiler_dac ${MDCOMPILER_SOURCES})
diff --git a/src/coreclr/src/md/compiler/dbi/CMakeLists.txt b/src/coreclr/src/md/compiler/dbi/CMakeLists.txt
deleted file mode 100644 (file)
index ee7a2cb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-include(../../md_dbi.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDCOMPILER_SOURCES)
-
-if (WIN32)
-    list(APPEND MDCOMPILER_SOURCES ${MDCOMPILER_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdcompiler-dbi ${MDCOMPILER_SOURCES})
diff --git a/src/coreclr/src/md/compiler/stdafx.cpp b/src/coreclr/src/md/compiler/stdafx.cpp
deleted file mode 100644 (file)
index ff341e1..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//*****************************************************************************
-// stdafx.cpp
-// 
-
-//
-// Precompiled headers.
-//
-//*****************************************************************************
-#include "stdafx.h"
diff --git a/src/coreclr/src/md/compiler/wks/CMakeLists.txt b/src/coreclr/src/md/compiler/wks/CMakeLists.txt
deleted file mode 100644 (file)
index c4cf62e..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-include(../../md_wks.cmake)
-
-add_definitions(-DFEATURE_METADATA_EMIT_ALL)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDCOMPILER_SOURCES)
-
-if (WIN32)
-    list(APPEND MDCOMPILER_SOURCES ${MDCOMPILER_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdcompiler_wks ${MDCOMPILER_SOURCES})
index 3aaa00a..0a842fc 100644 (file)
@@ -16,4 +16,10 @@ set(MDDATASOURCE_HEADERS
 convert_to_absolute_path(MDDATASOURCE_SOURCES ${MDDATASOURCE_SOURCES})
 convert_to_absolute_path(MDDATASOURCE_HEADERS ${MDDATASOURCE_HEADERS})
 
-add_subdirectory(dbi)
+if (WIN32)
+    list(APPEND MDDATASOURCE_SOURCES ${MDDATASOURCE_HEADERS})
+endif (WIN32)
+
+add_library_clr(mddatasource_dbi STATIC ${MDDATASOURCE_SOURCES})
+set_target_properties(mddatasource_dbi PROPERTIES DBI_COMPONENT TRUE)
+target_precompile_header(TARGET mddatasource_dbi HEADER stdafx.h)
diff --git a/src/coreclr/src/md/datasource/dbi/CMakeLists.txt b/src/coreclr/src/md/datasource/dbi/CMakeLists.txt
deleted file mode 100644 (file)
index f392a20..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-include(../../md_dbi.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDDATASOURCE_SOURCES)
-
-if (WIN32)
-    list(APPEND MDDATASOURCE_SOURCES ${MDDATASOURCE_HEADERS})
-endif (WIN32)
-
-add_library_clr(mddatasource_dbi STATIC ${MDDATASOURCE_SOURCES})
diff --git a/src/coreclr/src/md/datasource/stdafx.cpp b/src/coreclr/src/md/datasource/stdafx.cpp
deleted file mode 100644 (file)
index ff341e1..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//*****************************************************************************
-// stdafx.cpp
-// 
-
-//
-// Precompiled headers.
-//
-//*****************************************************************************
-#include "stdafx.h"
index 2f1398d..e6773e9 100644 (file)
@@ -44,7 +44,18 @@ endif(WIN32)
 convert_to_absolute_path(MDRUNTIMERW_HEADERS ${MDRUNTIMERW_HEADERS})
 convert_to_absolute_path(MDRUNTIMERW_SOURCES ${MDRUNTIMERW_SOURCES})
 
-add_subdirectory(dac)
-add_subdirectory(wks)
-add_subdirectory(dbi)
-add_subdirectory(crossgen)
+add_library_clr(mdruntimerw_dac ${MDRUNTIMERW_SOURCES})
+set_target_properties(mdruntimerw_dac PROPERTIES DAC_COMPONENT TRUE)
+target_precompile_header(TARGET mdruntimerw_dac HEADER stdafx.h)
+
+add_library_clr(mdruntimerw_wks ${MDRUNTIMERW_SOURCES})
+target_compile_definitions(mdruntimerw_wks PRIVATE FEATURE_METADATA_EMIT_ALL)
+target_precompile_header(TARGET mdruntimerw_wks HEADER stdafx.h)
+
+add_library_clr(mdruntimerw-dbi ${MDRUNTIMERW_SOURCES})
+set_target_properties(mdruntimerw-dbi PROPERTIES DBI_COMPONENT TRUE)
+target_precompile_header(TARGET mdruntimerw-dbi HEADER stdafx.h)
+
+add_library_clr(mdruntimerw_crossgen ${MDRUNTIMERW_SOURCES})
+set_target_properties(mdruntimerw_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+target_precompile_header(TARGET mdruntimerw_crossgen HEADER stdafx.h)
diff --git a/src/coreclr/src/md/enc/crossgen/CMakeLists.txt b/src/coreclr/src/md/enc/crossgen/CMakeLists.txt
deleted file mode 100644 (file)
index 86aa432..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-include(${CLR_DIR}/crossgen.cmake)
-include(../../md_wks.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIMERW_SOURCES)
-
-if (WIN32)
-    list(APPEND MDRUNTIMERW_SOURCES ${MDRUNTIMERW_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdruntimerw_crossgen ${MDRUNTIMERW_SOURCES})
diff --git a/src/coreclr/src/md/enc/dac/CMakeLists.txt b/src/coreclr/src/md/enc/dac/CMakeLists.txt
deleted file mode 100644 (file)
index c4ba31d..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-
-include(${CLR_DIR}/dac.cmake)
-include(../../md_dac.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIMERW_SOURCES)
-
-if (WIN32)
-    list(APPEND MDRUNTIMERW_SOURCES ${MDRUNTIMERW_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdruntimerw_dac ${MDRUNTIMERW_SOURCES})
diff --git a/src/coreclr/src/md/enc/dbi/CMakeLists.txt b/src/coreclr/src/md/enc/dbi/CMakeLists.txt
deleted file mode 100644 (file)
index d591937..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-include(../../md_dbi.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIMERW_SOURCES)
-
-if (WIN32)
-    list(APPEND MDRUNTIMERW_SOURCES ${MDRUNTIMERW_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdruntimerw-dbi ${MDRUNTIMERW_SOURCES})
diff --git a/src/coreclr/src/md/enc/stdafx.cpp b/src/coreclr/src/md/enc/stdafx.cpp
deleted file mode 100644 (file)
index ff341e1..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//*****************************************************************************
-// stdafx.cpp
-// 
-
-//
-// Precompiled headers.
-//
-//*****************************************************************************
-#include "stdafx.h"
diff --git a/src/coreclr/src/md/enc/wks/CMakeLists.txt b/src/coreclr/src/md/enc/wks/CMakeLists.txt
deleted file mode 100644 (file)
index ff4ec93..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-include(../../md_wks.cmake)
-
-add_definitions(-DFEATURE_METADATA_EMIT_ALL)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIMERW_SOURCES)
-
-if (WIN32)
-    list(APPEND MDRUNTIMERW_SOURCES ${MDRUNTIMERW_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdruntimerw_wks ${MDRUNTIMERW_SOURCES})
index 92a16cc..37a2545 100644 (file)
@@ -25,9 +25,22 @@ set(MDHOTDATA_HEADERS
 convert_to_absolute_path(MDHOTDATA_HEADERS ${MDHOTDATA_HEADERS})
 convert_to_absolute_path(MDHOTDATA_SOURCES ${MDHOTDATA_SOURCES})
 
-add_subdirectory(dac)
-add_subdirectory(full)
-add_subdirectory(crossgen)
+if (WIN32)
+    list(APPEND MDHOTDATA_SOURCES ${MDHOTDATA_HEADERS})
+endif (WIN32)
+
+add_library_clr(mdhotdata_dac ${MDHOTDATA_SOURCES})
+set_target_properties(mdhotdata_dac PROPERTIES DAC_COMPONENT TRUE)
+target_precompile_header(TARGET mdhotdata_dac HEADER external.h)
+
+add_library_clr(mdhotdata_full ${MDHOTDATA_SOURCES})
+target_precompile_header(TARGET mdhotdata_full HEADER external.h)
+
+add_library_clr(mdhotdata_crossgen ${MDHOTDATA_SOURCES})
+set_target_properties(mdhotdata_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+target_precompile_header(TARGET mdhotdata_crossgen HEADER external.h)
+
 if(WIN32)
-  add_subdirectory(full-staticcrt)
+  add_library_clr(mdhotdata-staticcrt ${MDHOTDATA_SOURCES})
+  target_precompile_header(TARGET mdhotdata-staticcrt HEADER external.h)
 endif(WIN32)
diff --git a/src/coreclr/src/md/hotdata/crossgen/CMakeLists.txt b/src/coreclr/src/md/hotdata/crossgen/CMakeLists.txt
deleted file mode 100644 (file)
index 4403c2f..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-include(${CLR_DIR}/crossgen.cmake)
-include(../../md_wks.cmake)
-
-add_precompiled_header(external.h ../external.cpp MDHOTDATA_SOURCES)
-
-if (WIN32)
-    list(APPEND MDHOTDATA_SOURCES ${MDHOTDATA_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdhotdata_crossgen ${MDHOTDATA_SOURCES})
diff --git a/src/coreclr/src/md/hotdata/dac/CMakeLists.txt b/src/coreclr/src/md/hotdata/dac/CMakeLists.txt
deleted file mode 100644 (file)
index 67b8408..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-
-include(${CLR_DIR}/dac.cmake)
-
-add_precompiled_header(external.h ../external.cpp MDHOTDATA_SOURCES)
-
-if (WIN32)
-    list(APPEND MDHOTDATA_SOURCES ${MDHOTDATA_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdhotdata_dac ${MDHOTDATA_SOURCES})
diff --git a/src/coreclr/src/md/hotdata/external.cpp b/src/coreclr/src/md/hotdata/external.cpp
deleted file mode 100644 (file)
index 26ec26d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// 
-// File: external.cpp
-// 
-
-// 
-// Precompiled headers.
-// 
-// ======================================================================================
-
-#include "external.h"
diff --git a/src/coreclr/src/md/hotdata/full-staticcrt/CMakeLists.txt b/src/coreclr/src/md/hotdata/full-staticcrt/CMakeLists.txt
deleted file mode 100644 (file)
index d702032..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-add_definitions(-D_CRTIMP=) # static link of crt
-
-add_precompiled_header(external.h ../external.cpp MDHOTDATA_SOURCES)
-
-if (WIN32)
-    list(APPEND MDHOTDATA_SOURCES ${MDHOTDATA_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdhotdata-staticcrt ${MDHOTDATA_SOURCES})
diff --git a/src/coreclr/src/md/hotdata/full/CMakeLists.txt b/src/coreclr/src/md/hotdata/full/CMakeLists.txt
deleted file mode 100644 (file)
index 1b97ff3..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-add_precompiled_header(external.h ../external.cpp MDHOTDATA_SOURCES)
-
-if (WIN32)
-    list(APPEND MDHOTDATA_SOURCES ${MDHOTDATA_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdhotdata_full ${MDHOTDATA_SOURCES})
diff --git a/src/coreclr/src/md/md_dac.cmake b/src/coreclr/src/md/md_dac.cmake
deleted file mode 100644 (file)
index 1820a55..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-add_definitions(-DFEATURE_METADATA_EMIT)
-add_definitions(-DFEATURE_METADATA_INTERNAL_APIS)
-add_definitions(-DFEATURE_METADATA_EMIT_IN_DEBUGGER)
\ No newline at end of file
diff --git a/src/coreclr/src/md/md_dbi.cmake b/src/coreclr/src/md/md_dbi.cmake
deleted file mode 100644 (file)
index 7622cf0..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-add_definitions(-DFEATURE_METADATA_EMIT)
-add_definitions(-DFEATURE_METADATA_EMIT_IN_DEBUGGER)
-add_definitions(-DFEATURE_METADATA_INTERNAL_APIS)
-add_definitions(-DFEATURE_METADATA_CUSTOM_DATA_SOURCE)
-add_definitions(-DFEATURE_METADATA_DEBUGGEE_DATA_SOURCE)
-# Enable mscordbi-only (perf) feature -->
-add_definitions(-DFEATURE_METADATA_LOAD_TRUSTED_IMAGES -DFEATURE_METADATA_RELEASE_MEMORY_ON_REOPEN)
-
-
-if(WIN32)
-    # using static crt for dbi
-    if (CMAKE_BUILD_TYPE STREQUAL DEBUG)
-      add_definitions(-MTd) 
-    else()
-      add_definitions(-MT) 
-    endif(CMAKE_BUILD_TYPE STREQUAL DEBUG)
-endif(WIN32)
diff --git a/src/coreclr/src/md/md_wks.cmake b/src/coreclr/src/md/md_wks.cmake
deleted file mode 100644 (file)
index 4d72c55..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-add_definitions(-DFEATURE_METADATA_EMIT)
-add_definitions(-DFEATURE_METADATA_INTERNAL_APIS)
-add_definitions(-DFEATURE_METADATA_IN_VM)
-if(WIN32)
-  add_definitions(-DFEATURE_METADATA_VERIFY_LAYOUTS)
-endif(WIN32)
index fc817b1..c5a78fc 100644 (file)
@@ -41,7 +41,22 @@ set(MDRUNTIME_HEADERS
 convert_to_absolute_path(MDRUNTIME_HEADERS ${MDRUNTIME_HEADERS})
 convert_to_absolute_path(MDRUNTIME_SOURCES ${MDRUNTIME_SOURCES})
 
-add_subdirectory(dac)
-add_subdirectory(wks)
-add_subdirectory(dbi)
-add_subdirectory(crossgen)
+if (WIN32)
+    list(APPEND MDRUNTIME_SOURCES ${MDRUNTIME_HEADERS})
+endif (WIN32)
+
+add_library_clr(mdruntime_dac ${MDRUNTIME_SOURCES})
+set_target_properties(mdruntime_dac PROPERTIES DAC_COMPONENT TRUE)
+target_precompile_header(TARGET mdruntime_dac HEADER stdafx.h)
+
+add_library_clr(mdruntime_wks ${MDRUNTIME_SOURCES})
+target_compile_definitions(mdruntime_wks PRIVATE FEATURE_METADATA_EMIT_ALL)
+target_precompile_header(TARGET mdruntime_wks HEADER stdafx.h)
+
+add_library_clr(mdruntime-dbi ${MDRUNTIME_SOURCES})
+set_target_properties(mdruntime-dbi PROPERTIES DBI_COMPONENT TRUE)
+target_precompile_header(TARGET mdruntime-dbi HEADER stdafx.h)
+
+add_library_clr(mdruntime_crossgen ${MDRUNTIME_SOURCES})
+set_target_properties(mdruntime_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+target_precompile_header(TARGET mdruntime_crossgen HEADER stdafx.h)
diff --git a/src/coreclr/src/md/runtime/crossgen/CMakeLists.txt b/src/coreclr/src/md/runtime/crossgen/CMakeLists.txt
deleted file mode 100644 (file)
index e778a86..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-include(${CLR_DIR}/crossgen.cmake)
-include(../../md_wks.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIME_SOURCES)
-
-if (WIN32)
-    list(APPEND MDRUNTIME_SOURCES ${MDRUNTIME_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdruntime_crossgen ${MDRUNTIME_SOURCES})
diff --git a/src/coreclr/src/md/runtime/dac/CMakeLists.txt b/src/coreclr/src/md/runtime/dac/CMakeLists.txt
deleted file mode 100644 (file)
index ba6d4f0..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-
-include(${CLR_DIR}/dac.cmake)
-include(../../md_dac.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIME_SOURCES)
-
-if (WIN32)
-    list(APPEND MDRUNTIME_SOURCES ${MDRUNTIME_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdruntime_dac ${MDRUNTIME_SOURCES})
\ No newline at end of file
diff --git a/src/coreclr/src/md/runtime/dbi/CMakeLists.txt b/src/coreclr/src/md/runtime/dbi/CMakeLists.txt
deleted file mode 100644 (file)
index 4d2ebe4..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-include(../../md_dbi.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIME_SOURCES)
-
-if (WIN32)
-    list(APPEND MDRUNTIME_SOURCES ${MDRUNTIME_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdruntime-dbi ${MDRUNTIME_SOURCES})
diff --git a/src/coreclr/src/md/runtime/stdafx.cpp b/src/coreclr/src/md/runtime/stdafx.cpp
deleted file mode 100644 (file)
index ff341e1..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//*****************************************************************************
-// stdafx.cpp
-// 
-
-//
-// Precompiled headers.
-//
-//*****************************************************************************
-#include "stdafx.h"
diff --git a/src/coreclr/src/md/runtime/wks/CMakeLists.txt b/src/coreclr/src/md/runtime/wks/CMakeLists.txt
deleted file mode 100644 (file)
index c8c52f5..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-include(../../md_wks.cmake)
-
-add_definitions(-DFEATURE_METADATA_EMIT_ALL)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDRUNTIME_SOURCES)
-
-if (WIN32)
-    list(APPEND MDRUNTIME_SOURCES ${MDRUNTIME_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdruntime_wks ${MDRUNTIME_SOURCES})
index 567a975..6cee65a 100644 (file)
@@ -20,9 +20,25 @@ set(MDWINMD_HEADERS
 convert_to_absolute_path(MDWINMD_HEADERS ${MDWINMD_HEADERS})
 convert_to_absolute_path(MDWINMD_SOURCES ${MDWINMD_SOURCES})
 
-add_subdirectory(dac)
-add_subdirectory(wks)
+if (WIN32)
+  list(APPEND MDWINMD_SOURCES ${MDWINMD_HEADERS})
+endif (WIN32)
+
+
+add_library_clr(mdwinmd_dac ${MDWINMD_SOURCES})
+set_target_properties(mdwinmd_dac PROPERTIES DAC_COMPONENT TRUE)
+target_precompile_header(TARGET mdwinmd_dac HEADER stdafx.h)
+
+add_library_clr(mdwinmd_wks ${MDWINMD_SOURCES})
+target_compile_definitions(mdwinmd_wks PRIVATE FEATURE_METADATA_EMIT_ALL)
+target_precompile_header(TARGET mdwinmd_wks HEADER stdafx.h)
+
 if(WIN32)
-  add_subdirectory(dbi)
-  add_subdirectory(crossgen)
+  add_library_clr(mdwinmd_dbi ${MDWINMD_SOURCES})
+  set_target_properties(mdwinmd_dbi PROPERTIES DBI_COMPONENT TRUE)
+  target_precompile_header(TARGET mdwinmd_dbi HEADER stdafx.h)
+
+  add_library_clr(mdwinmd_crossgen ${MDWINMD_SOURCES})
+  set_target_properties(mdwinmd_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+  target_precompile_header(TARGET mdwinmd_crossgen HEADER stdafx.h)
 endif(WIN32)
diff --git a/src/coreclr/src/md/winmd/crossgen/CMakeLists.txt b/src/coreclr/src/md/winmd/crossgen/CMakeLists.txt
deleted file mode 100644 (file)
index 670514a..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-include(${CLR_DIR}/crossgen.cmake)
-include(../../md_wks.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDWINMD_SOURCES)
-
-if (WIN32)
-    list(APPEND MDWINMD_SOURCES ${MDWINMD_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdwinmd_crossgen ${MDWINMD_SOURCES})
diff --git a/src/coreclr/src/md/winmd/dac/CMakeLists.txt b/src/coreclr/src/md/winmd/dac/CMakeLists.txt
deleted file mode 100644 (file)
index 1ed4aec..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-
-include(${CLR_DIR}/dac.cmake)
-include(../../md_dbi.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDWINMD_SOURCES)
-
-if (WIN32)
-    list(APPEND MDWINMD_SOURCES ${MDWINMD_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdwinmd_dac ${MDWINMD_SOURCES})
diff --git a/src/coreclr/src/md/winmd/dbi/CMakeLists.txt b/src/coreclr/src/md/winmd/dbi/CMakeLists.txt
deleted file mode 100644 (file)
index 669018e..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-include(../../md_dbi.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDWINMD_SOURCES)
-
-if (WIN32)
-    list(APPEND MDWINMD_SOURCES ${MDWINMD_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdwinmd_dbi ${MDWINMD_SOURCES})
diff --git a/src/coreclr/src/md/winmd/wks/CMakeLists.txt b/src/coreclr/src/md/winmd/wks/CMakeLists.txt
deleted file mode 100644 (file)
index 930dbca..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-include(../../md_wks.cmake)
-
-add_definitions(-DFEATURE_METADATA_EMIT_ALL)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp MDWINMD_SOURCES)
-
-if (WIN32)
-    list(APPEND MDWINMD_SOURCES ${MDWINMD_HEADERS})
-endif (WIN32)
-
-add_library_clr(mdwinmd_wks ${MDWINMD_SOURCES})
index 542de8c..f7c2383 100644 (file)
@@ -58,9 +58,7 @@ if(CORECLR_SET_RPATH)
     set(MACOSX_RPATH ON)
 endif(CORECLR_SET_RPATH)
 
-if(CMAKE_VERSION VERSION_EQUAL 3.0 OR CMAKE_VERSION VERSION_GREATER 3.0)
-    cmake_policy(SET CMP0042 NEW)
-endif()
+cmake_policy(SET CMP0042 NEW)
 
 # Include directories
 
index 684aadd..18ada86 100644 (file)
@@ -1,10 +1,10 @@
 cmake_minimum_required(VERSION 2.8.12)
 
-include(FindPythonInterp)
+include(FindPython)
 
 set (GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genDummyProvider.py)
 
-set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR})
+set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR})
 
 execute_process(
   COMMAND ${GENERATE_COMMAND} --dry-run
index 1f49aef..1e6c811 100644 (file)
@@ -1,9 +1,9 @@
 cmake_minimum_required(VERSION 2.8.12)
 
-include(FindPythonInterp)
+include(FindPython)
 set (GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genLttngProvider.py)
 
-set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR})
+set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR})
 
 execute_process(
   COMMAND ${GENERATE_COMMAND} --dry-run
index 8b43aad..ad3205a 100644 (file)
@@ -7,10 +7,10 @@ set(SOURCES
 set(EVENT_MANIFEST ${VM_DIR}/ClrEtwAll.man)
 set(TEST_GENERATOR ${CLR_DIR}/src/scripts/genEventingTests.py)
 
-include(FindPythonInterp)
+include(FindPython)
 
 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clralltestevents.cpp
-  COMMAND ${PYTHON_EXECUTABLE} ${TEST_GENERATOR} --testdir "${CMAKE_CURRENT_BINARY_DIR}" --man "${EVENT_MANIFEST}"
+  COMMAND ${Python_EXECUTABLE} ${TEST_GENERATOR} --testdir "${CMAKE_CURRENT_BINARY_DIR}" --man "${EVENT_MANIFEST}"
   DEPENDS ${EVENT_MANIFEST} ${TEST_GENERATOR}
   COMMENT "Updating clralltestevents.cpp"
 )
index 125a158..ce6bc06 100755 (executable)
@@ -114,12 +114,6 @@ if [ $OS = "Linux" -o $OS = "FreeBSD" -o $OS = "OpenBSD" -o $OS = "NetBSD" -o $O
 fi
 
 cmake_extra_defines=
-if [[ -n "$LLDB_LIB_DIR" ]]; then
-    cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_LIBS=$LLDB_LIB_DIR"
-fi
-if [[ -n "$LLDB_INCLUDE_DIR" ]]; then
-    cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_INCLUDES=$LLDB_INCLUDE_DIR"
-fi
 if [ "$CROSSCOMPILE" == "1" ]; then
     if ! [[ -n "$ROOTFS_DIR" ]]; then
         echo "ROOTFS_DIR not set for crosscompile"
@@ -168,7 +162,6 @@ $cmake_command \
   "-DCMAKE_BUILD_TYPE=$buildtype" \
   "-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \
   "-DCMAKE_INSTALL_PREFIX=$__CMakeBinDir" \
-  "-DCLR_CMAKE_COMPILER=Clang" \
   "-DCMAKE_USER_MAKE_RULES_OVERRIDE=" \
   $cmake_extra_defines \
   $__UnprocessedCMakeArgs \
index 9113244..30a8769 100755 (executable)
@@ -124,12 +124,6 @@ if ! gcc_objcopy="$(locate_gcc_exec objcopy)"; then { echo "Unable to locate gcc
 if ! gcc_ranlib="$(locate_gcc_exec ranlib)"; then { echo "Unable to locate gcc-ranlib"; exit 1; } fi
 
 cmake_extra_defines=
-if [ -n "$LLDB_LIB_DIR" ]; then
-    cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_LIBS=$LLDB_LIB_DIR"
-fi
-if [ -n "$LLDB_INCLUDE_DIR" ]; then
-    cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_INCLUDES=$LLDB_INCLUDE_DIR"
-fi
 if [ "$CROSSCOMPILE" = "1" ]; then
     if [ -z "$ROOTFS_DIR" ]; then
         echo "ROOTFS_DIR not set for crosscompile"
@@ -173,7 +167,6 @@ $cmake_command \
   "-DCMAKE_OBJDUMP=$gcc_objdump" \
   "-DCMAKE_BUILD_TYPE=$buildtype" \
   "-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \
-  "-DCLR_CMAKE_COMPILER=GNU" \
   "-DCMAKE_USER_MAKE_RULES_OVERRIDE=" \
   "-DCMAKE_INSTALL_PREFIX=$__CMakeBinDir" \
   $cmake_extra_defines \
index 1e0ec20..865aacc 100644 (file)
@@ -8,7 +8,7 @@ include_directories(BEFORE ${VM_DIR})
 include_directories(${VM_DIR}/${ARCH_SOURCES_DIR})
 include_directories(${CLR_DIR}/src/md/compiler)
 
-add_definitions(-DSTRONGNAME_IN_VM -DSNAPI_INTERNAL)
+add_definitions(-DSNAPI_INTERNAL)
 
 set(STRONGNAME_SOURCES
   strongname.cpp
@@ -17,7 +17,18 @@ set(STRONGNAME_SOURCES
 
 convert_to_absolute_path(STRONGNAME_SOURCES ${STRONGNAME_SOURCES})
 
-add_subdirectory(dac)
-add_subdirectory(wks)
-add_subdirectory(crossgen)
-add_subdirectory(tool)
+add_library_clr(strongname_tool ${STRONGNAME_SOURCES})
+
+add_library_clr(strongname_dac ${STRONGNAME_SOURCES})
+add_dependencies(strongname_dac eventing_headers)
+set_target_properties(strongname_dac PROPERTIES DAC_COMPONENT TRUE)
+target_compile_definitions(strongname_dac PRIVATE STRONGNAME_IN_VM)
+
+add_library_clr(strongname_wks ${STRONGNAME_SOURCES})
+add_dependencies(strongname_wks eventing_headers)
+target_compile_definitions(strongname_wks PRIVATE STRONGNAME_IN_VM)
+
+add_library_clr(strongname_crossgen ${STRONGNAME_SOURCES})
+add_dependencies(strongname_crossgen eventing_headers)
+set_target_properties(strongname_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+target_compile_definitions(strongname_crossgen PRIVATE STRONGNAME_IN_VM)
diff --git a/src/coreclr/src/strongname/api/crossgen/CMakeLists.txt b/src/coreclr/src/strongname/api/crossgen/CMakeLists.txt
deleted file mode 100644 (file)
index 5632c03..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-include(${CLR_DIR}/crossgen.cmake)
-
-add_library_clr(strongname_crossgen ${STRONGNAME_SOURCES})
-add_dependencies(strongname_crossgen eventing_headers)
diff --git a/src/coreclr/src/strongname/api/dac/CMakeLists.txt b/src/coreclr/src/strongname/api/dac/CMakeLists.txt
deleted file mode 100644 (file)
index ee4fc2f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-
-include(${CLR_DIR}/dac.cmake)
-
-add_library_clr(strongname_dac ${STRONGNAME_SOURCES})
-add_dependencies(strongname_dac eventing_headers)
diff --git a/src/coreclr/src/strongname/api/tool/CMakeLists.txt b/src/coreclr/src/strongname/api/tool/CMakeLists.txt
deleted file mode 100644 (file)
index c04dc92..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-remove_definitions(-DSTRONGNAME_IN_VM)
-add_library_clr(strongname_tool ${STRONGNAME_SOURCES})
\ No newline at end of file
diff --git a/src/coreclr/src/strongname/api/wks/CMakeLists.txt b/src/coreclr/src/strongname/api/wks/CMakeLists.txt
deleted file mode 100644 (file)
index fcd6f8a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-add_library_clr(strongname_wks ${STRONGNAME_SOURCES})
-add_dependencies(strongname_wks eventing_headers)
index ab5b4ed..0f33857 100644 (file)
@@ -1,7 +1,5 @@
 project(crossgen)
 
-include(${CLR_DIR}/crossgen.cmake)
-
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 include_directories(../util)
 include_directories(../../pal/prebuilt/corerror)
@@ -23,6 +21,7 @@ add_executable_clr(crossgen
   ${crossgen_SOURCES}
   ${crossgen_RESOURCES}
 )
+set_target_properties(crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
 
 if(FEATURE_MERGE_JIT_AND_ENGINE)
     set(CLRJIT_CROSSGEN clrjit_crossgen)
@@ -67,9 +66,8 @@ else()
 
 endif(CLR_CMAKE_PLATFORM_UNIX)
 
-add_subdirectory(../../zap/crossgen ../../zap/crossgen)
+add_subdirectory(../../zap ../../zap)
 add_subdirectory(../../vm/crossgen ../../vm/crossgen)
-add_subdirectory(../../vm/crossgen_mscorlib ../../vm/crossgen_mscorlib)
 
 # add the install targets
 install_clr(crossgen)
index 9a5d782..5a26440 100644 (file)
@@ -20,7 +20,17 @@ list(APPEND UNWINDER_SOURCES
 convert_to_absolute_path(UNWINDER_SOURCES ${UNWINDER_SOURCES})
 
 if(CLR_CMAKE_PLATFORM_UNIX)    
-    add_subdirectory(wks)
+    add_library_clr(unwinder_wks ${UNWINDER_SOURCES})
+    add_dependencies(unwinder_wks eventing_headers)
 endif(CLR_CMAKE_PLATFORM_UNIX)
 
-add_subdirectory(dac)
+add_library_clr(unwinder_dac ${UNWINDER_SOURCES})
+add_dependencies(unwinder_dac eventing_headers)
+set_target_properties(unwinder_dac PROPERTIES DAC_COMPONENT TRUE)
+target_compile_definitions(unwinder_dac PRIVATE FEATURE_NO_HOST)
+
+add_library_clr(unwinder_dac_amd64 ${UNWINDER_SOURCES})
+add_dependencies(unwinder_dac_amd64 eventing_headers)
+set_target_properties(unwinder_dac_amd64 PROPERTIES DAC_COMPONENT TRUE)
+target_compile_definitions(unwinder_dac_amd64 PRIVATE FEATURE_NO_HOST)
+
diff --git a/src/coreclr/src/unwinder/dac/CMakeLists.txt b/src/coreclr/src/unwinder/dac/CMakeLists.txt
deleted file mode 100644 (file)
index 7a670e8..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-include(${CLR_DIR}/dac.cmake)
-
-add_definitions(-DFEATURE_NO_HOST)
-
-add_library_clr(unwinder_dac ${UNWINDER_SOURCES})
-add_dependencies(unwinder_dac eventing_headers)
diff --git a/src/coreclr/src/unwinder/dac/hostwinamd64/CMakeLists.txt b/src/coreclr/src/unwinder/dac/hostwinamd64/CMakeLists.txt
deleted file mode 100644 (file)
index 8309c35..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-include(${CLR_DIR}/dac.cmake)
-
-add_library_clr(unwinder_dac_amd64 ${UNWINDER_SOURCES})
diff --git a/src/coreclr/src/unwinder/wks/CMakeLists.txt b/src/coreclr/src/unwinder/wks/CMakeLists.txt
deleted file mode 100644 (file)
index b23cb79..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-add_library_clr(unwinder_wks ${UNWINDER_SOURCES})
-add_dependencies(unwinder_wks eventing_headers)
index deb5dc8..be4bad5 100644 (file)
@@ -109,7 +109,34 @@ convert_to_absolute_path(UTILCODE_DAC_SOURCES ${UTILCODE_DAC_SOURCES})
 convert_to_absolute_path(UTILCODE_CROSSGEN_SOURCES ${UTILCODE_CROSSGEN_SOURCES})
 convert_to_absolute_path(UTILCODE_STATICNOHOST_SOURCES ${UTILCODE_STATICNOHOST_SOURCES})
 
-add_subdirectory(dac)
-add_subdirectory(dyncrt)
-add_subdirectory(staticnohost)
-add_subdirectory(crossgen)
+add_library_clr(utilcode_dac STATIC ${UTILCODE_DAC_SOURCES})
+add_library_clr(utilcode STATIC ${UTILCODE_SOURCES})
+add_library_clr(utilcodestaticnohost STATIC ${UTILCODE_STATICNOHOST_SOURCES})
+add_library_clr(utilcode_crossgen STATIC ${UTILCODE_CROSSGEN_SOURCES})
+
+if(CLR_CMAKE_PLATFORM_UNIX)
+  target_link_libraries(utilcodestaticnohost  nativeresourcestring)
+  target_link_libraries(utilcode_crossgen  nativeresourcestring)
+  target_link_libraries(utilcode_dac nativeresourcestring)
+  target_link_libraries(utilcode nativeresourcestring)
+  add_dependencies(utilcode_dac coreclrpal)
+  add_dependencies(utilcode coreclrpal)
+endif(CLR_CMAKE_PLATFORM_UNIX)
+
+
+if(WIN32)
+    target_compile_definitions(utilcodestaticnohost PRIVATE _CRTIMP=) # use static version of crt
+endif(WIN32)
+
+set_target_properties(utilcode_dac PROPERTIES DAC_COMPONENT TRUE)
+set_target_properties(utilcode_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+target_compile_definitions(utilcode_dac PRIVATE SELF_NO_HOST)
+target_compile_definitions(utilcodestaticnohost PRIVATE SELF_NO_HOST)
+add_dependencies(utilcode_dac ${UTILCODE_DEPENDENCIES})
+add_dependencies(utilcode ${UTILCODE_DEPENDENCIES})
+add_dependencies(utilcode_crossgen ${UTILCODE_DEPENDENCIES})
+add_dependencies(utilcodestaticnohost ${UTILCODE_DEPENDENCIES})
+target_precompile_header(TARGET utilcode_dac HEADER stdafx.h)
+target_precompile_header(TARGET utilcode HEADER stdafx.h)
+target_precompile_header(TARGET utilcode_crossgen HEADER stdafx.h)
+target_precompile_header(TARGET utilcodestaticnohost HEADER stdafx.h)
diff --git a/src/coreclr/src/utilcode/crossgen/CMakeLists.txt b/src/coreclr/src/utilcode/crossgen/CMakeLists.txt
deleted file mode 100644 (file)
index 41dd6d2..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-include(${CLR_DIR}/crossgen.cmake)
-
-add_precompiled_header(stdafx.h ../stdafx.cpp UTILCODE_CROSSGEN_SOURCES)
-add_library_clr(utilcode_crossgen STATIC ${UTILCODE_CROSSGEN_SOURCES})
-if(CLR_CMAKE_PLATFORM_UNIX)
-  target_link_libraries(utilcode_crossgen  nativeresourcestring)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
-add_dependencies(utilcode_crossgen ${UTILCODE_DEPENDENCIES})
diff --git a/src/coreclr/src/utilcode/dac/CMakeLists.txt b/src/coreclr/src/utilcode/dac/CMakeLists.txt
deleted file mode 100644 (file)
index 07d3e1b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-include(${CLR_DIR}/dac.cmake)
-
-add_definitions(-DSELF_NO_HOST)
-
-if(CLR_CMAKE_PLATFORM_UNIX)
-    add_library_clr(utilcode_dac STATIC ${UTILCODE_DAC_SOURCES})
-    target_link_libraries(utilcode_dac nativeresourcestring)
-    add_dependencies(utilcode_dac coreclrpal)
-else()
-    add_precompiled_header(stdafx.h ../stdafx.cpp UTILCODE_DAC_SOURCES)
-    add_library_clr(utilcode_dac STATIC ${UTILCODE_DAC_SOURCES})
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
-add_dependencies(utilcode_dac ${UTILCODE_DEPENDENCIES})
diff --git a/src/coreclr/src/utilcode/dyncrt/CMakeLists.txt b/src/coreclr/src/utilcode/dyncrt/CMakeLists.txt
deleted file mode 100644 (file)
index 752e32b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-
-if(CLR_CMAKE_PLATFORM_UNIX)
-    add_library_clr(utilcode STATIC ${UTILCODE_SOURCES})
-    target_link_libraries(utilcode nativeresourcestring)
-    add_dependencies(utilcode coreclrpal)
-else()
-    add_precompiled_header(stdafx.h ../stdafx.cpp UTILCODE_SOURCES)
-    add_library_clr(utilcode STATIC ${UTILCODE_SOURCES})
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
-add_dependencies(utilcode ${UTILCODE_DEPENDENCIES})
diff --git a/src/coreclr/src/utilcode/staticnohost/CMakeLists.txt b/src/coreclr/src/utilcode/staticnohost/CMakeLists.txt
deleted file mode 100644 (file)
index 5947718..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-add_definitions(-DSELF_NO_HOST)
-
-if(WIN32)
-     add_definitions(-D_CRTIMP=) # use static version of crt
-     add_precompiled_header(stdafx.h ../stdafx.cpp UTILCODE_STATICNOHOST_SOURCES)
-endif(WIN32)
-
-add_library_clr(utilcodestaticnohost STATIC ${UTILCODE_STATICNOHOST_SOURCES})
-
-if(CLR_CMAKE_PLATFORM_UNIX)
-  target_link_libraries(utilcodestaticnohost  nativeresourcestring)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
-add_dependencies(utilcodestaticnohost ${UTILCODE_DEPENDENCIES})
diff --git a/src/coreclr/src/utilcode/stdafx.cpp b/src/coreclr/src/utilcode/stdafx.cpp
deleted file mode 100644 (file)
index f31fef9..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//*****************************************************************************
-//     stdafx.cpp
-//
-
-//
-//     Host for precompiled header.
-//
-//*****************************************************************************
-#include "stdafx.h"                                            // Precompiled header key.
index b036efb..ed72c94 100644 (file)
@@ -920,7 +920,11 @@ convert_to_absolute_path(VM_SOURCES_WKS ${VM_SOURCES_WKS})
 convert_to_absolute_path(VM_SOURCES_WKS_ARCH_ASM ${VM_SOURCES_WKS_ARCH_ASM})
 convert_to_absolute_path(VM_SOURCES_DAC ${VM_SOURCES_DAC})
 
-add_subdirectory(dac)
+add_library_clr(cee_dac ${VM_SOURCES_DAC})
+add_dependencies(cee_dac eventing_headers)
+set_target_properties(cee_dac PROPERTIES DAC_COMPONENT TRUE)
+target_precompile_header(TARGET cee_dac HEADER common.h)
+
 add_subdirectory(wks)
 
 if(FEATURE_PERFTRACING)
diff --git a/src/coreclr/src/vm/common.cpp b/src/coreclr/src/vm/common.cpp
deleted file mode 100644 (file)
index 55a63b3..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
-#include "common.h"
-
index 9b52d77..949e96e 100644 (file)
@@ -1,5 +1,3 @@
-include(${CLR_DIR}/crossgen.cmake)
-
 set(VM_CROSSGEN_SOURCES
   ../appdomain.cpp
   ../array.cpp
@@ -251,9 +249,6 @@ if (WIN32)
     ../winrttypenameconverter.h
   )
 
-  add_precompiled_header(common.h ../common.cpp VM_CROSSGEN_SOURCES)
-  # mscorlib.cpp does not compile with precompiled header file
-  set_source_files_properties(../mscorlib.cpp PROPERTIES COMPILE_FLAGS "/Y-")
   list(APPEND VM_CROSSGEN_SOURCES ${VM_CROSSGEN_HEADERS})
 endif (WIN32)
 
@@ -266,3 +261,22 @@ endif (CLR_CMAKE_PLATFORM_LINUX)
 
 add_library_clr(cee_crossgen ${VM_CROSSGEN_SOURCES})
 add_dependencies(cee_crossgen eventing_headers)
+set_target_properties(cee_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+target_precompile_header(TARGET cee_crossgen HEADER common.h)
+if (MSVC)
+  # mscorlib.cpp does not compile with precompiled header file
+  set_source_files_properties(../mscorlib.cpp PROPERTIES COMPILE_FLAGS "/Y-")
+endif()
+
+add_library_clr(mscorlib_crossgen ../mscorlib.cpp)
+add_dependencies(mscorlib_crossgen eventing_headers)
+target_compile_definitions(mscorlib_crossgen
+    PRIVATE
+        EnC_SUPPORTED
+        FEATURE_EVENT_TRACE
+        FEATURE_MULTICOREJIT
+        FEATURE_VERSIONING_LOG
+        CROSSGEN_MSCORLIB)
+
+set_target_properties(mscorlib_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+
diff --git a/src/coreclr/src/vm/crossgen_mscorlib/CMakeLists.txt b/src/coreclr/src/vm/crossgen_mscorlib/CMakeLists.txt
deleted file mode 100644 (file)
index b79a08f..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-include(${CLR_DIR}/crossgen.cmake)
-
-# Add back some of the macro removed by crossgen.cmake.
-add_definitions(
-    -DEnC_SUPPORTED
-    -DFEATURE_EVENT_TRACE
-    -DFEATURE_MULTICOREJIT
-    -DFEATURE_VERSIONING_LOG
-)
-
-add_definitions(-DCROSSGEN_MSCORLIB)
-
-add_library_clr(mscorlib_crossgen ../mscorlib.cpp)
-add_dependencies(cee_crossgen eventing_headers)
diff --git a/src/coreclr/src/vm/dac/CMakeLists.txt b/src/coreclr/src/vm/dac/CMakeLists.txt
deleted file mode 100644 (file)
index f001f2e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-
-include(${CLR_DIR}/dac.cmake)
-
-add_precompiled_header(common.h ../common.cpp VM_SOURCES_DAC)
-add_library_clr(cee_dac ${VM_SOURCES_DAC})
-add_dependencies(cee_dac eventing_headers)
index 9d3c988..380a282 100644 (file)
@@ -10,7 +10,7 @@ else()
   set(NEED_XPLAT_HEADER ON)
 endif()
 
-include(FindPythonInterp)
+include(FindPython)
 
 set (EventingHeaders
   ${GENERATED_INCLUDE_DIR}/etmdummy.h
@@ -26,7 +26,7 @@ endif()
 set(GENEVENTING_SCRIPT ${CLR_DIR}/src/scripts/genEventing.py)
 
 add_custom_target(eventing_headers
-  ${PYTHON_EXECUTABLE} ${GENEVENTING_SCRIPT} --man ${EVENT_MANIFEST} --inc ${GENERATED_INCLUDE_DIR} --dummy ${GENERATED_INCLUDE_DIR}/etmdummy.h ${NONEXTERN_ARG} ${NOXPLATHEADER_ARG}
+  ${Python_EXECUTABLE} ${GENEVENTING_SCRIPT} --man ${EVENT_MANIFEST} --inc ${GENERATED_INCLUDE_DIR} --dummy ${GENERATED_INCLUDE_DIR}/etmdummy.h ${NONEXTERN_ARG} ${NOXPLATHEADER_ARG}
   DEPENDS ${EVENT_MANIFEST} ${GENEVENTING_SCRIPT}
   VERBATIM
 )
index fe78082..8289309 100644 (file)
@@ -1,6 +1,6 @@
 cmake_minimum_required(VERSION 2.8.12)
 
-include(FindPythonInterp)
+include(FindPython)
 
 set(ETW_PROVIDER_SCRIPT ${CLR_DIR}/src/scripts/genEtwProvider.py)
 
@@ -16,5 +16,5 @@ set (ETW_PROVIDER_OUTPUTS
 set_source_files_properties(${ETW_PROVIDER_OUTPUTS} PROPERTIES GENERATED TRUE)
 
 add_custom_target(eventprovider
-  ${PYTHON_EXECUTABLE} ${ETW_PROVIDER_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${GENERATED_INCLUDE_DIR}
+  ${Python_EXECUTABLE} ${ETW_PROVIDER_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${GENERATED_INCLUDE_DIR}
   DEPENDS ${EVENT_MANIFEST} ${EVENT_EXCLUSIONS} ${ETW_PROVIDER_SCRIPT})
index 065906e..3ce1362 100644 (file)
@@ -1,11 +1,11 @@
 cmake_minimum_required(VERSION 2.8.12.2)
 
-include(FindPythonInterp)
+include(FindPython)
 
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 set(GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genEventPipe.py)
-set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${CMAKE_CURRENT_BINARY_DIR} ${NONEXTERN_ARG})
+set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${CMAKE_CURRENT_BINARY_DIR} ${NONEXTERN_ARG})
 
 execute_process(
   COMMAND ${GENERATE_COMMAND} --dry-run
index db33f4b..2a2593f 100644 (file)
@@ -1,81 +1,23 @@
 
 if (WIN32)
-  add_precompiled_header(common.h ../common.cpp VM_SOURCES_WKS)
-  # mscorlib.cpp does not compile with precompiled header file
-  set_source_files_properties(../mscorlib.cpp PROPERTIES COMPILE_FLAGS "/Y-") 
-
-  # asm files require preprocessing using cl.exe on arm32 and arm64
   if(CLR_CMAKE_PLATFORM_ARCH_ARM OR CLR_CMAKE_PLATFORM_ARCH_ARM64)
-
-      get_include_directories_asm(ASM_INCLUDE_DIRECTORIES)
-
-      foreach(ASM_FILE ${VM_SOURCES_WKS_ARCH_ASM})
-
-          # Inserts a custom command in CMake build to preprocess each asm source file
-          get_filename_component(name ${ASM_FILE} NAME_WE)
-          file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${name}.asm" ASM_PREPROCESSED_FILE)
-          preprocess_def_file(${ASM_FILE} ${ASM_PREPROCESSED_FILE})
-
-          # We do not pass any defines since we have already done pre-processing above
-          set (ASM_CMDLINE "-o ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj ${ASM_PREPROCESSED_FILE}")
-
-          # Generate the batch file that will invoke the assembler
-          file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/runasm_${name}.cmd" ASM_SCRIPT_FILE)
-
-          file(GENERATE OUTPUT "${ASM_SCRIPT_FILE}"
-               CONTENT "\"${CMAKE_ASM_MASM_COMPILER}\" -g ${ASM_INCLUDE_DIRECTORIES} ${ASM_CMDLINE}")
-
-          message("Generated  - ${ASM_SCRIPT_FILE}")
-
-          # Need to compile asm file using custom command as include directories are not provided to asm compiler
-          add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj
-                             COMMAND ${ASM_SCRIPT_FILE}
-                             DEPENDS ${ASM_PREPROCESSED_FILE}
-                             COMMENT "Assembling ${ASM_PREPROCESSED_FILE} - ${ASM_SCRIPT_FILE}")
-
-          # mark obj as source that does not require compile
-          set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${name}.obj PROPERTIES EXTERNAL_OBJECT TRUE)
-
-          # Add the generated OBJ in the dependency list so that it gets consumed during linkage
-          set(VM_SOURCES_WKS_ARCH_ASM ${VM_SOURCES_WKS_ARCH_ASM} ${CMAKE_CURRENT_BINARY_DIR}/${name}.obj)
-
-      endforeach()
-
+    preprocess_compile_asm(ASM_FILES ${VM_SOURCES_WKS_ARCH_ASM} OUTPUT_OBJECTS VM_WKS_ARCH_ASM_OBJECTS)
+    list(APPEND VM_SOURCES_WKS_ARCH_ASM ${VM_WKS_ARCH_ASM_OBJECTS})
   endif()
 
 endif (WIN32)
 
 add_library_clr(cee_wks ${VM_SOURCES_WKS} ${VM_SOURCES_WKS_ARCH_ASM})
+target_precompile_header(TARGET cee_wks HEADER common.h)
+if (MSVC)
+    # mscorlib.cpp does not compile with precompiled header file
+    set_source_files_properties(../mscorlib.cpp PROPERTIES COMPILE_FLAGS "/Y-")
+endif()
 add_dependencies(cee_wks eventing_headers)
 
 if (WIN32)
 
   if(NOT CLR_CMAKE_PLATFORM_ARCH_ARM AND NOT CLR_CMAKE_PLATFORM_ARCH_ARM64)
-    # Get the current list of definitions
-    get_compile_definitions(DEFINITIONS)
-
-    get_directory_property(COMPILE_DEFINITIONS_LIST COMPILE_DEFINITIONS)
-
-    # Extract the definitions for the ASM code. Since there is a bug in the cmake that prevents us from
-    # using the generator expressions, we split the definitions into lists based on the configuration.
-    foreach(DEFINITION IN LISTS COMPILE_DEFINITIONS_LIST)
-        if (${DEFINITION} MATCHES "^\\$<\\$<CONFIG:([^>]+)>:([^>]+)>$")
-            # The entry contains generator expression, so insert the definition into a definitions list
-            # corresponding to the config
-            string(TOUPPER ${CMAKE_MATCH_1} CONFIG)
-            set(ASM_DEFINITIONS_${CONFIG} ${ASM_DEFINITIONS_${CONFIG}} ${CMAKE_MATCH_2}) 
-        else()
-            list(APPEND ASM_DEFINITIONS ${DEFINITION})        
-        endif()
-    endforeach()
-
-    # Add defines for the ASM. Unfortunately setting it on the target is ignored for asm by the cmake, so we have
-    # to set it on the sources.
-    set_property(SOURCE ${VM_SOURCES_WKS_ARCH_ASM} PROPERTY COMPILE_DEFINITIONS ${ASM_DEFINITIONS})
-    foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES)
-        string(TOUPPER ${CONFIG} CONFIG)
-        set_property(SOURCE ${VM_SOURCES_WKS_ARCH_ASM} PROPERTY COMPILE_DEFINITIONS_${CONFIG} ${ASM_DEFINITIONS_${CONFIG}})
-    endforeach()
 
     if (CLR_CMAKE_PLATFORM_ARCH_I386)
         set_source_files_properties(${VM_SOURCES_WKS_ARCH_ASM} PROPERTIES COMPILE_FLAGS "/Zm /safeseh")
@@ -87,6 +29,8 @@ if (WIN32)
         message(FATAL_ERROR "POWERSHELL not found")
     endif()
 
+    # Get the current list of definitions
+    get_compile_definitions(DEFINITIONS)
     add_custom_command(
         OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.inc"
         DEPENDS ${VM_DIR}/${ARCH_SOURCES_DIR}/asmconstants.h
@@ -97,8 +41,8 @@ if (WIN32)
     set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.inc PROPERTIES GENERATED TRUE)
 
     add_custom_target(
-        asmconstants_inc
-        DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.inc
+      asmconstants_inc
+      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.inc
     )
 
     add_dependencies(cee_wks asmconstants_inc)
diff --git a/src/coreclr/src/zap/CMakeLists.txt b/src/coreclr/src/zap/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1c23048
--- /dev/null
@@ -0,0 +1,56 @@
+set(ZAP_SOURCES
+    svcworker.cpp
+    zapper.cpp
+    zaprelocs.cpp
+    zapcode.cpp
+    zapheaders.cpp
+    zapimage.cpp
+    zapinfo.cpp
+    zapimport.cpp
+    zapinnerptr.cpp
+    zapmetadata.cpp
+    zapwriter.cpp
+    zapwrapper.cpp
+    zapperstats.cpp
+    nativeformatwriter.cpp
+)
+
+set(ZAP_HEADERS
+    zaprelocs.h
+    zapcode.h
+    zapheaders.h
+    zapimage.h
+    zapinfo.h
+    zapimport.h
+    zapinnerptr.h
+    zaplog.h
+    zapmetadata.h
+    zapnodetype.h
+    zapwriter.h
+    zapwrapper.h
+    zapperstats.h
+    nativeformatwriter.h
+)
+
+if (FEATURE_READYTORUN)
+    list(APPEND ZAP_SOURCES
+        zapreadytorun.cpp
+        nativeformatwriter.cpp
+    )
+    list(APPEND ZAP_HEADERS
+        zapreadytorun.h
+        nativeformatwriter.h
+    )
+endif (FEATURE_READYTORUN)
+
+if (WIN32)
+    list(APPEND ZAP_SOURCES ${ZAP_HEADERS})
+endif(WIN32)
+
+add_library_clr(corzap_crossgen STATIC ${ZAP_SOURCES})
+set_target_properties(corzap_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
+target_precompile_header(TARGET corzap_crossgen HEADER common.h)
+
+if(FEATURE_MERGE_JIT_AND_ENGINE)
+  target_link_libraries(corzap_crossgen clrjit_crossgen)
+endif(FEATURE_MERGE_JIT_AND_ENGINE)
diff --git a/src/coreclr/src/zap/common.cpp b/src/coreclr/src/zap/common.cpp
deleted file mode 100644 (file)
index edecbd3..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//*****************************************************************************
-// common.cpp
-//
-
-//
-// Precompiled headers.
-//
-//*****************************************************************************
-#include "common.h"
diff --git a/src/coreclr/src/zap/crossgen/CMakeLists.txt b/src/coreclr/src/zap/crossgen/CMakeLists.txt
deleted file mode 100644 (file)
index 0d45cd1..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-include(${CLR_DIR}/crossgen.cmake)
-
-set(ZAP_SOURCES
-    ../svcworker.cpp
-    ../zapper.cpp
-    ../zaprelocs.cpp
-    ../zapcode.cpp
-    ../zapheaders.cpp
-    ../zapimage.cpp
-    ../zapinfo.cpp
-    ../zapimport.cpp
-    ../zapinnerptr.cpp
-    ../zapmetadata.cpp
-    ../zapwriter.cpp
-    ../zapwrapper.cpp
-    ../zapperstats.cpp
-    ../nativeformatwriter.cpp
-)
-
-set(ZAP_HEADERS
-    ../zaprelocs.h
-    ../zapcode.h
-    ../zapheaders.h
-    ../zapimage.h
-    ../zapinfo.h
-    ../zapimport.h
-    ../zapinnerptr.h
-    ../zaplog.h
-    ../zapmetadata.h
-    ../zapnodetype.h
-    ../zapwriter.h
-    ../zapwrapper.h
-    ../zapperstats.h
-    ../nativeformatwriter.h
-)
-
-if (FEATURE_READYTORUN)
-    list(APPEND ZAP_SOURCES
-        ../zapreadytorun.cpp
-        ../nativeformatwriter.cpp
-    )
-    list(APPEND ZAP_HEADERS
-        ../zapreadytorun.h
-        ../nativeformatwriter.h
-    )
-endif (FEATURE_READYTORUN)
-
-add_precompiled_header(common.h ../common.cpp ZAP_SOURCES)
-
-if (WIN32)
-    list(APPEND ZAP_SOURCES ${ZAP_HEADERS})
-endif(WIN32)
-
-add_library_clr(corzap_crossgen STATIC ${ZAP_SOURCES})
-
-if(FEATURE_MERGE_JIT_AND_ENGINE)
-  target_link_libraries(corzap_crossgen clrjit_crossgen)
-endif(FEATURE_MERGE_JIT_AND_ENGINE)
index 0b453ce..1a4665b 100644 (file)
@@ -7,8 +7,6 @@ if (WIN32)
     add_definitions(-DWINDOWS)
 endif()
 
-# Verify that LTCG/LTO is available
-include(${CMAKE_CURRENT_SOURCE_DIR}/../configure.cmake)
 # Include global configure settings
 include(${CMAKE_CURRENT_SOURCE_DIR}/../configurecompiler.cmake)
 # Compile options