Update cmake files from CoreCLR
authorIgor Kulaychuk <i.kulaychuk@allan.local>
Mon, 4 Jun 2018 17:01:43 +0000 (20:01 +0300)
committerIgor Kulaychuk <i.kulaychuk@allan.local>
Mon, 4 Jun 2018 17:01:43 +0000 (20:01 +0300)
CMakeLists.txt
clrdefinitions.cmake
clrfeatures.cmake [new file with mode: 0644]
compileoptions.cmake
detectplatform.cmake [new file with mode: 0644]
platformdefinitions.cmake [new file with mode: 0644]
src/debug/netcoredbg/CMakeLists.txt

index ee0e76e..6127c28 100644 (file)
@@ -7,8 +7,15 @@ set(BUILD_MANAGED ON CACHE BOOL "Build managed part")
 set(DBGSHIM_INSTALL ON CACHE BOOL "Install libdbgshim")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-null-conversion")
 
+function(clr_unknown_arch)
+    message(FATAL_ERROR "Only AMD64, ARM64, ARM, ARMEL, I386 and WASM are supported")
+endfunction()
+
+# Follow order as in root CoreCLR CMakeLists.txt
+include(detectplatform.cmake) # from root
+include(platformdefinitions.cmake) # from root
+include(compileoptions.cmake) # disabled setting arm compiler flags in Tizen build
 include(clrdefinitions.cmake)
-include(compileoptions.cmake)
 
 if (NOT IS_DIRECTORY "${CLR_DIR}")
     message(FATAL_ERROR "Unable to find CoreCLR directory")
@@ -20,6 +27,9 @@ if ("${CLR_BIN_DIR}" STREQUAL "")
     elseif (CMAKE_SYSTEM_NAME STREQUAL Linux)
         set(TARGET_OS_NAME "Linux")
     endif()
+
+    set(CMAKE_CONFIGURATION_TYPES "Debug;Checked;Release;RelWithDebInfo")
+
     # TODO: Search for CMAKE_BUILD_TYPE configuration first
     # TODO: CLR_CMAKE_TARGET_ARCH may be armel
     set(CLR_BIN_DIR ${CLR_DIR}/bin/Product/${TARGET_OS_NAME}.${CLR_CMAKE_TARGET_ARCH}.Debug)
index 823c365..c50cf63 100644 (file)
-function(clr_unknown_arch)
-  if (WIN32)
-    message(FATAL_ERROR "Only AMD64, ARM64, ARM and I386 are supported")
-  elseif(CLR_CROSS_COMPONENTS_BUILD)
-    message(FATAL_ERROR "Only AMD64, I386 host are supported for linux cross-architecture component")
-  else()
-    message(FATAL_ERROR "Only AMD64, ARM64 and ARM are supported")
-  endif()
-endfunction()
-
-#----------------------------------------
-# Detect and set platform variable names
-#     - for non-windows build platform & architecture is detected using inbuilt CMAKE variables and cross target component configure
-#     - for windows we use the passed in parameter to CMAKE to determine build arch
-#----------------------------------------
-if(CMAKE_SYSTEM_NAME STREQUAL Linux)
-    set(CLR_CMAKE_PLATFORM_UNIX 1)
-    if(CLR_CROSS_COMPONENTS_BUILD)
-        # CMAKE_HOST_SYSTEM_PROCESSOR returns the value of `uname -p` on host.
-        if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
-            if(CLR_CMAKE_TARGET_ARCH STREQUAL "arm")
-                set(CLR_CMAKE_PLATFORM_UNIX_X86 1)
-            else()
-                set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
-            endif()
-        elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL i686)
-            set(CLR_CMAKE_PLATFORM_UNIX_X86 1)
-        else()
-            clr_unknown_arch()
-        endif()
-    else()
-        # CMAKE_SYSTEM_PROCESSOR returns the value of `uname -p` on target.
-        # For the AMD/Intel 64bit architecture two different strings are common.
-        # Linux and Darwin identify it as "x86_64" while FreeBSD and netbsd uses the
-        # "amd64" string. Accept either of the two here.
-        if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
-            set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
-        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
-            set(CLR_CMAKE_PLATFORM_UNIX_ARM 1)
-        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
-            set(CLR_CMAKE_PLATFORM_UNIX_ARM 1)
-        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
-            set(CLR_CMAKE_PLATFORM_UNIX_ARM64 1)
-        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
-            set(CLR_CMAKE_PLATFORM_UNIX_X86 1)
-        else()
-            clr_unknown_arch()
-        endif()
-    endif()
-    set(CLR_CMAKE_PLATFORM_LINUX 1)
-
-    # Detect Linux ID
-    if(DEFINED CLR_CMAKE_LINUX_ID)
-        if(CLR_CMAKE_LINUX_ID STREQUAL ubuntu)
-            set(CLR_CMAKE_TARGET_UBUNTU_LINUX 1)
-        elseif(CLR_CMAKE_LINUX_ID STREQUAL tizen)
-            set(CLR_CMAKE_TARGET_TIZEN_LINUX 1)
-        elseif(CLR_CMAKE_LINUX_ID STREQUAL alpine)
-            set(CLR_CMAKE_PLATFORM_ALPINE_LINUX 1)
-        endif()
-        if(CLR_CMAKE_LINUX_ID STREQUAL ubuntu)
-            set(CLR_CMAKE_PLATFORM_UBUNTU_LINUX 1)
-        endif()
-    endif(DEFINED CLR_CMAKE_LINUX_ID)
-#else()
-#    message(FATAL_ERROR "Currently only Linux is supported but you can try")
-endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
-
-# Set HOST architecture variables
-if(CLR_CMAKE_PLATFORM_UNIX_ARM)
-    set(CLR_CMAKE_PLATFORM_ARCH_ARM 1)
-    set(CLR_CMAKE_HOST_ARCH "arm")
-elseif(CLR_CMAKE_PLATFORM_UNIX_ARM64)
-    set(CLR_CMAKE_PLATFORM_ARCH_ARM64 1)
-    set(CLR_CMAKE_HOST_ARCH "arm64")
-elseif(CLR_CMAKE_PLATFORM_UNIX_AMD64)
-    set(CLR_CMAKE_PLATFORM_ARCH_AMD64 1)
-    set(CLR_CMAKE_HOST_ARCH "x64")
-elseif(CLR_CMAKE_PLATFORM_UNIX_X86)
-    set(CLR_CMAKE_PLATFORM_ARCH_I386 1)
-    set(CLR_CMAKE_HOST_ARCH "x86")
-elseif(WIN32)
-    # CLR_CMAKE_HOST_ARCH is passed in as param to cmake
-    if (CLR_CMAKE_HOST_ARCH STREQUAL x64)
-        set(CLR_CMAKE_PLATFORM_ARCH_AMD64 1)
-    elseif(CLR_CMAKE_HOST_ARCH STREQUAL x86)
-        set(CLR_CMAKE_PLATFORM_ARCH_I386 1)
-    elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm)
-        set(CLR_CMAKE_PLATFORM_ARCH_ARM 1)
-    elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm64)
-        set(CLR_CMAKE_PLATFORM_ARCH_ARM64 1)
-    else()
-        clr_unknown_arch()
-    endif()
-endif()
-
-# Set TARGET architecture variables
-if(NOT DEFINED CLR_CMAKE_TARGET_ARCH OR CLR_CMAKE_TARGET_ARCH STREQUAL "" )
-  set(CLR_CMAKE_TARGET_ARCH ${CLR_CMAKE_HOST_ARCH})
-endif()
+include(clrfeatures.cmake)
 
-# Set target architecture variables
-if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
-    set(CLR_CMAKE_TARGET_ARCH_AMD64 1)
-  elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
-    set(CLR_CMAKE_TARGET_ARCH_I386 1)
-  elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64)
-    set(CLR_CMAKE_TARGET_ARCH_ARM64 1)
-  elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm)
-    set(CLR_CMAKE_TARGET_ARCH_ARM 1)
-  else()
-    clr_unknown_arch()
-endif()
+# If set, indicates that this is not an officially supported release
+# Keep in sync with IsPrerelease in dir.props
+set(PRERELEASE 1)
 
-# Definitions (for platform)
-if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
-  add_definitions(-D_AMD64_)
-  add_definitions(-D_WIN64)
-  add_definitions(-DAMD64)
-  add_definitions(-DBIT64=1)
-elseif (CLR_CMAKE_PLATFORM_ARCH_I386)
-  add_definitions(-D_X86_)
-elseif (CLR_CMAKE_PLATFORM_ARCH_ARM)
-  add_definitions(-D_ARM_)
-  add_definitions(-DARM)
-elseif (CLR_CMAKE_PLATFORM_ARCH_ARM64)
-  add_definitions(-D_ARM64_)
-  add_definitions(-DARM64)
-  add_definitions(-D_WIN64)
-  add_definitions(-DBIT64=1)
-else ()
-  clr_unknown_arch()
-endif ()
+# Features we're currently flighting, but don't intend to ship in officially supported releases
+if (PRERELEASE)
+  add_definitions(-DFEATURE_DEFAULT_INTERFACES=1)  
+endif (PRERELEASE)
 
-# Definitions (for target)
 if (CLR_CMAKE_TARGET_ARCH_AMD64)
   if (CLR_CMAKE_PLATFORM_UNIX)
     add_definitions(-DDBG_TARGET_AMD64_UNIX)
   endif()
   add_definitions(-D_TARGET_AMD64_=1)
+  add_definitions(-D_TARGET_64BIT_=1)
   add_definitions(-DDBG_TARGET_64BIT=1)
   add_definitions(-DDBG_TARGET_AMD64=1)
   add_definitions(-DDBG_TARGET_WIN64=1)
@@ -146,6 +23,7 @@ elseif (CLR_CMAKE_TARGET_ARCH_ARM64)
     add_definitions(-DDBG_TARGET_ARM64_UNIX)
   endif()
   add_definitions(-D_TARGET_ARM64_=1)
+  add_definitions(-D_TARGET_64BIT_=1)
   add_definitions(-DDBG_TARGET_64BIT=1)
   add_definitions(-DDBG_TARGET_ARM64=1)
   add_definitions(-DDBG_TARGET_WIN64=1)
@@ -168,3 +46,185 @@ elseif (CLR_CMAKE_TARGET_ARCH_I386)
 else ()
   clr_unknown_arch()
 endif (CLR_CMAKE_TARGET_ARCH_AMD64)
+
+if (CLR_CMAKE_PLATFORM_UNIX)
+
+  if(CLR_CMAKE_PLATFORM_DARWIN)
+    add_definitions(-D_XOPEN_SOURCE)
+    add_definitions(-DFEATURE_DATATARGET4)
+  endif(CLR_CMAKE_PLATFORM_DARWIN)
+
+  if (CLR_CMAKE_TARGET_ARCH_AMD64)
+    add_definitions(-DUNIX_AMD64_ABI)
+  elseif (CLR_CMAKE_TARGET_ARCH_ARM)
+    add_definitions(-DUNIX_ARM_ABI)
+    add_definitions(-DFEATURE_DATATARGET4)
+  elseif (CLR_CMAKE_TARGET_ARCH_I386)
+    add_definitions(-DUNIX_X86_ABI)
+  endif()
+
+endif(CLR_CMAKE_PLATFORM_UNIX)
+
+if(CLR_CMAKE_PLATFORM_ALPINE_LINUX)
+  # Alpine Linux doesn't have fixed stack limit, this define disables some stack pointer
+  # sanity checks in debug / checked build that rely on a fixed stack limit
+  add_definitions(-DNO_FIXED_STACK_LIMIT)
+endif(CLR_CMAKE_PLATFORM_ALPINE_LINUX)
+
+add_definitions(-D_BLD_CLR)
+add_definitions(-DDEBUGGING_SUPPORTED)
+add_definitions(-DPROFILING_SUPPORTED)
+
+if(WIN32)
+  add_definitions(-DWIN32)
+  add_definitions(-D_WIN32)
+  add_definitions(-DWINVER=0x0602)
+  add_definitions(-D_WIN32_WINNT=0x0602)
+  add_definitions(-DWIN32_LEAN_AND_MEAN=1)
+  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+  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)
+  endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
+endif(WIN32)
+
+# Features - please keep them alphabetically sorted
+if (FEATURE_APPDOMAIN_RESOURCE_MONITORING)
+  add_definitions(-DFEATURE_APPDOMAIN_RESOURCE_MONITORING)
+endif(FEATURE_APPDOMAIN_RESOURCE_MONITORING)
+
+if(WIN32)
+  add_definitions(-DFEATURE_APPX)
+  if(NOT CLR_CMAKE_TARGET_ARCH_I386)
+    add_definitions(-DFEATURE_ARRAYSTUB_AS_IL)
+    add_definitions(-DFEATURE_MULTICASTSTUB_AS_IL)
+  endif()
+else(WIN32)
+  add_definitions(-DFEATURE_ARRAYSTUB_AS_IL)
+  add_definitions(-DFEATURE_MULTICASTSTUB_AS_IL)
+endif(WIN32)
+add_definitions(-DFEATURE_CODE_VERSIONING)
+add_definitions(-DFEATURE_COLLECTIBLE_TYPES)
+
+if(WIN32)
+    add_definitions(-DFEATURE_CLASSIC_COMINTEROP)
+    add_definitions(-DFEATURE_COMINTEROP)
+    add_definitions(-DFEATURE_COMINTEROP_APARTMENT_SUPPORT)
+    add_definitions(-DFEATURE_COMINTEROP_UNMANAGED_ACTIVATION)
+    add_definitions(-DFEATURE_COMINTEROP_WINRT_MANAGED_ACTIVATION)
+endif(WIN32)
+
+add_definitions(-DFEATURE_CORECLR)
+if (CLR_CMAKE_PLATFORM_UNIX)
+  add_definitions(-DFEATURE_COREFX_GLOBALIZATION)
+endif(CLR_CMAKE_PLATFORM_UNIX)
+add_definitions(-DFEATURE_CORESYSTEM)
+add_definitions(-DFEATURE_CORRUPTING_EXCEPTIONS)
+if(FEATURE_DBGIPC)
+  add_definitions(-DFEATURE_DBGIPC_TRANSPORT_DI)
+  add_definitions(-DFEATURE_DBGIPC_TRANSPORT_VM)
+endif(FEATURE_DBGIPC)
+if(FEATURE_EVENT_TRACE)
+    add_definitions(-DFEATURE_EVENT_TRACE=1)
+    add_definitions(-DFEATURE_PERFTRACING=1)
+endif(FEATURE_EVENT_TRACE)
+if(FEATURE_GDBJIT)
+    add_definitions(-DFEATURE_GDBJIT)
+endif()
+if(FEATURE_GDBJIT_FRAME)
+    add_definitions(-DFEATURE_GDBJIT_FRAME)
+endif(FEATURE_GDBJIT_FRAME)
+if(FEATURE_GDBJIT_LANGID_CS)
+    add_definitions(-DFEATURE_GDBJIT_LANGID_CS)
+endif(FEATURE_GDBJIT_LANGID_CS)
+if(FEATURE_GDBJIT_SYMTAB)
+    add_definitions(-DFEATURE_GDBJIT_SYMTAB)
+endif(FEATURE_GDBJIT_SYMTAB)
+if(CLR_CMAKE_PLATFORM_UNIX)
+    add_definitions(-DFEATURE_EVENTSOURCE_XPLAT=1)
+endif(CLR_CMAKE_PLATFORM_UNIX)
+# NetBSD doesn't implement this feature
+if(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
+    add_definitions(-DFEATURE_HIJACK)
+endif(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
+add_definitions(-DFEATURE_ICASTABLE)
+if (WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_ARM64))
+    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)
+endif(FEATURE_INTERPRETER)
+add_definitions(-DFEATURE_ISYM_READER)
+if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
+    add_definitions(-DFEATURE_JUMPSTAMP)
+  endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
+add_definitions(-DFEATURE_LOADER_OPTIMIZATION)
+if (CLR_CMAKE_PLATFORM_LINUX OR WIN32)
+    add_definitions(-DFEATURE_MANAGED_ETW)
+endif(CLR_CMAKE_PLATFORM_LINUX OR WIN32)
+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)
+if (FEATURE_NI_BIND_FALLBACK)
+  add_definitions(-DFEATURE_NI_BIND_FALLBACK)
+endif(FEATURE_NI_BIND_FALLBACK)
+if(CLR_CMAKE_PLATFORM_UNIX)
+  add_definitions(-DFEATURE_PAL)
+  add_definitions(-DFEATURE_PAL_SXS)
+  add_definitions(-DFEATURE_PAL_ANSI)
+endif(CLR_CMAKE_PLATFORM_UNIX)
+if(CLR_CMAKE_PLATFORM_LINUX)
+    add_definitions(-DFEATURE_PERFMAP)
+endif(CLR_CMAKE_PLATFORM_LINUX)
+add_definitions(-DFEATURE_PREJIT)
+
+add_definitions(-DFEATURE_READYTORUN)
+set(FEATURE_READYTORUN 1)
+
+if (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
+  add_definitions(-DFEATURE_REJIT)
+endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
+
+add_definitions(-DFEATURE_STANDALONE_SN)
+add_definitions(-DFEATURE_STRONGNAME_DELAY_SIGNING_ALLOWED)
+add_definitions(-DFEATURE_STRONGNAME_MIGRATION)
+if (CLR_CMAKE_PLATFORM_UNIX OR CLR_CMAKE_TARGET_ARCH_ARM64)
+    add_definitions(-DFEATURE_STUBS_AS_IL)
+endif ()
+add_definitions(-DFEATURE_SVR_GC)
+add_definitions(-DFEATURE_SYMDIFF)
+add_definitions(-DFEATURE_TIERED_COMPILATION)
+if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
+  # Enable the AMD64 Unix struct passing JIT-EE interface for all AMD64 platforms, to enable altjit.
+  add_definitions(-DUNIX_AMD64_ABI_ITF)
+endif (CLR_CMAKE_PLATFORM_ARCH_AMD64)
+if(CLR_CMAKE_PLATFORM_UNIX_AMD64)
+  add_definitions(-DFEATURE_MULTIREG_RETURN)
+endif (CLR_CMAKE_PLATFORM_UNIX_AMD64)
+if(CLR_CMAKE_PLATFORM_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64)
+  add_definitions(-DUNIX_AMD64_ABI)
+endif(CLR_CMAKE_PLATFORM_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64)
+add_definitions(-DFEATURE_USE_ASM_GC_WRITE_BARRIERS)
+if(CLR_CMAKE_PLATFORM_ARCH_AMD64 OR (CLR_CMAKE_PLATFORM_ARCH_ARM64 AND NOT WIN32))
+  add_definitions(-DFEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP)
+endif(CLR_CMAKE_PLATFORM_ARCH_AMD64 OR (CLR_CMAKE_PLATFORM_ARCH_ARM64 AND NOT WIN32))
+if((CLR_CMAKE_PLATFORM_ARCH_AMD64 OR CLR_CMAKE_PLATFORM_ARCH_ARM64) AND NOT WIN32)
+  add_definitions(-DFEATURE_MANUALLY_MANAGED_CARD_BUNDLES)
+endif((CLR_CMAKE_PLATFORM_ARCH_AMD64 OR CLR_CMAKE_PLATFORM_ARCH_ARM64) AND NOT WIN32)
+
+if(WIN32)
+    add_definitions(-DFEATURE_VERSIONING_LOG)
+endif(WIN32)
+if(NOT CLR_CMAKE_PLATFORM_UNIX)
+    add_definitions(-DFEATURE_WIN32_REGISTRY)
+endif(NOT CLR_CMAKE_PLATFORM_UNIX)
+add_definitions(-DFEATURE_LEGACYNETCF_DBG_HOST_CONTROL)
+add_definitions(-DFEATURE_WINDOWSPHONE)
+add_definitions(-DFEATURE_WINMD_RESILIENT)
+add_definitions(-D_SECURE_SCL=0)
+add_definitions(-DUNICODE)
+add_definitions(-D_UNICODE)
diff --git a/clrfeatures.cmake b/clrfeatures.cmake
new file mode 100644 (file)
index 0000000..88b9cdd
--- /dev/null
@@ -0,0 +1,29 @@
+if(CLR_CMAKE_TARGET_TIZEN_LINUX)
+  set(FEATURE_GDBJIT_LANGID_CS 1)
+endif()
+
+if(NOT DEFINED FEATURE_EVENT_TRACE)
+  set(FEATURE_EVENT_TRACE 1)
+endif(NOT DEFINED FEATURE_EVENT_TRACE)
+
+if(NOT DEFINED FEATURE_PERFTRACING AND FEATURE_EVENT_TRACE)
+  set(FEATURE_PERFTRACING 1)
+endif(NOT DEFINED FEATURE_PERFTRACING AND FEATURE_EVENT_TRACE)
+
+if(NOT DEFINED FEATURE_DBGIPC)
+  if(CLR_CMAKE_PLATFORM_UNIX AND (NOT CLR_CMAKE_PLATFORM_ANDROID))
+    set(FEATURE_DBGIPC 1)
+  endif()
+endif(NOT DEFINED FEATURE_DBGIPC)
+
+if(NOT DEFINED FEATURE_INTERPRETER)
+  set(FEATURE_INTERPRETER 0)
+endif(NOT DEFINED FEATURE_INTERPRETER)
+
+if(NOT DEFINED FEATURE_APPDOMAIN_RESOURCE_MONITORING)
+  set(FEATURE_APPDOMAIN_RESOURCE_MONITORING 1)
+endif(NOT DEFINED FEATURE_APPDOMAIN_RESOURCE_MONITORING)
+
+if(NOT DEFINED FEATURE_STANDALONE_GC)
+  set(FEATURE_STANDALONE_GC 1)
+endif(NOT DEFINED FEATURE_STANDALONE_GC)
index 0d221d8..7329fdd 100644 (file)
-# Disable frame pointer optimizations so profilers can get better call stacks
-add_compile_options(-fno-omit-frame-pointer)
-
-# The -fms-extensions enable the stuff like __if_exists, __declspec(uuid()), etc.
-add_compile_options(-fms-extensions )
-#-fms-compatibility      Enable full Microsoft Visual C++ compatibility
-#-fms-extensions         Accept some non-standard constructs supported by the Microsoft compiler
-
-# Make signed arithmetic overflow of addition, subtraction, and multiplication wrap around
-# using twos-complement representation (this is normally undefined according to the C++ spec).
-add_compile_options(-fwrapv)
-
-add_definitions(-DDISABLE_CONTRACTS)
-# The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop
-# after hitting just about 20 errors.
-add_compile_options(-ferror-limit=4096)
-
-# All warnings that are not explicitly disabled are reported as errors
-add_compile_options(-Werror)
-
-# Disabled warnings
-add_compile_options(-Wno-unused-private-field)
-add_compile_options(-Wno-unused-variable)
-# Explicit constructor calls are not supported by clang (this->ClassName::ClassName())
-add_compile_options(-Wno-microsoft)
-# This warning is caused by comparing 'this' to NULL
-add_compile_options(-Wno-tautological-compare)
-# There are constants of type BOOL used in a condition. But BOOL is defined as int
-# and so the compiler thinks that there is a mistake.
-add_compile_options(-Wno-constant-logical-operand)
-
-add_compile_options(-Wno-unknown-warning-option)
-
-#These seem to indicate real issues
-add_compile_options(-Wno-invalid-offsetof)
-# The following warning indicates that an attribute __attribute__((__ms_struct__)) was applied
-# to a struct or a class that has virtual members or a base class. In that case, clang
-# may not generate the same object layout as MSVC.
-add_compile_options(-Wno-incompatible-ms-struct)
-
-# Some architectures (e.g., ARM) assume char type is unsigned while CoreCLR assumes char is signed
-# as x64 does. It has been causing issues in ARM (https://github.com/dotnet/coreclr/issues/4746)
-add_compile_options(-fsigned-char)
+if (CLR_CMAKE_PLATFORM_UNIX)
+  # Disable frame pointer optimizations so profilers can get better call stacks
+  add_compile_options(-fno-omit-frame-pointer)
+
+  # The -fms-extensions enable the stuff like __if_exists, __declspec(uuid()), etc.
+  add_compile_options(-fms-extensions )
+  #-fms-compatibility      Enable full Microsoft Visual C++ compatibility
+  #-fms-extensions         Accept some non-standard constructs supported by the Microsoft compiler
+
+  # Make signed arithmetic overflow of addition, subtraction, and multiplication wrap around
+  # using twos-complement representation (this is normally undefined according to the C++ spec).
+  add_compile_options(-fwrapv)
+
+  if(CLR_CMAKE_PLATFORM_DARWIN)
+    # We cannot enable "stack-protector-strong" on OS X due to a bug in clang compiler (current version 7.0.2)
+    add_compile_options(-fstack-protector)
+  else()
+    add_compile_options(-fstack-protector-strong)
+  endif(CLR_CMAKE_PLATFORM_DARWIN)
+
+  add_definitions(-DDISABLE_CONTRACTS)
+  # The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop
+  # after hitting just about 20 errors.
+  add_compile_options(-ferror-limit=4096)
+
+  if (CLR_CMAKE_WARNINGS_ARE_ERRORS)
+    # All warnings that are not explicitly disabled are reported as errors
+    add_compile_options(-Werror)
+  endif(CLR_CMAKE_WARNINGS_ARE_ERRORS)
+
+  # Disabled warnings
+  add_compile_options(-Wno-unused-private-field)
+  add_compile_options(-Wno-unused-variable)
+  # Explicit constructor calls are not supported by clang (this->ClassName::ClassName())
+  add_compile_options(-Wno-microsoft)
+  # This warning is caused by comparing 'this' to NULL
+  add_compile_options(-Wno-tautological-compare)
+  # There are constants of type BOOL used in a condition. But BOOL is defined as int
+  # and so the compiler thinks that there is a mistake.
+  add_compile_options(-Wno-constant-logical-operand)
+  # We use pshpack1/2/4/8.h and poppack.h headers to set and restore packing. However
+  # clang 6.0 complains when the packing change lifetime is not contained within 
+  # a header file.
+  add_compile_options(-Wno-pragma-pack)
+
+  add_compile_options(-Wno-unknown-warning-option)
+
+  #These seem to indicate real issues
+  add_compile_options(-Wno-invalid-offsetof)
+  # The following warning indicates that an attribute __attribute__((__ms_struct__)) was applied
+  # to a struct or a class that has virtual members or a base class. In that case, clang
+  # may not generate the same object layout as MSVC.
+  add_compile_options(-Wno-incompatible-ms-struct)
+
+  # Some architectures (e.g., ARM) assume char type is unsigned while CoreCLR assumes char is signed
+  # as x64 does. It has been causing issues in ARM (https://github.com/dotnet/coreclr/issues/4746)
+  add_compile_options(-fsigned-char)
+endif(CLR_CMAKE_PLATFORM_UNIX)
 
 if(CLR_CMAKE_PLATFORM_UNIX_ARM AND NOT DEFINED CLR_CMAKE_TARGET_TIZEN_LINUX)
    # Because we don't use CMAKE_C_COMPILER/CMAKE_CXX_COMPILER to use clang
    # we have to set the triple by adding a compiler argument
    add_compile_options(-mthumb)
    add_compile_options(-mfpu=vfpv3)
+   add_compile_options(-march=armv7-a)
    if(ARM_SOFTFP)
      add_definitions(-DARM_SOFTFP)
      add_compile_options(-mfloat-abi=softfp)
-     add_compile_options(-target armv7-linux-gnueabi)
-   else()
-     add_compile_options(-target armv7-linux-gnueabihf)
    endif(ARM_SOFTFP)
 endif()
+
+if (WIN32)
+  # Compile options for targeting windows
+
+  # The following options are set by the razzle build
+  add_compile_options(/TP) # compile all files as C++
+  add_compile_options(/d2Zi+) # make optimized builds debugging easier
+  add_compile_options(/nologo) # Suppress Startup Banner
+  add_compile_options(/W3) # set warning level to 3
+  add_compile_options(/WX) # treat warnings as errors
+  add_compile_options(/Oi) # enable intrinsics
+  add_compile_options(/Oy-) # disable suppressing of the creation of frame pointers on the call stack for quicker function calls
+  add_compile_options(/U_MT) # undefine the predefined _MT macro
+  add_compile_options(/GF) # enable read-only string pooling
+  add_compile_options(/Gm-) # disable minimal rebuild
+  add_compile_options(/EHa) # enable C++ EH (w/ SEH exceptions)
+  add_compile_options(/Zp8) # pack structs on 8-byte boundary
+  add_compile_options(/Gy) # separate functions for linker
+  add_compile_options(/Zc:wchar_t-) # C++ language conformance: wchar_t is NOT the native type, but a typedef
+  add_compile_options(/Zc:forScope) # C++ language conformance: enforce Standard C++ for scoping rules
+  add_compile_options(/GR-) # disable C++ RTTI
+  add_compile_options(/FC) # use full pathnames in diagnostics
+  add_compile_options(/MP) # Build with Multiple Processes (number of processes equal to the number of processors)
+  add_compile_options(/GS) # Buffer Security Check
+  add_compile_options(/Zm200) # Specify Precompiled Header Memory Allocation Limit of 150MB
+  add_compile_options(/wd4960 /wd4961 /wd4603 /wd4627 /wd4838 /wd4456 /wd4457 /wd4458 /wd4459 /wd4091 /we4640)
+  add_compile_options(/Zi) # enable debugging information
+  add_compile_options(/ZH:SHA_256) # use SHA256 for generating hashes of compiler processed source files.
+  add_compile_options(/source-charset:utf-8) # Force MSVC to compile source as UTF-8.
+
+  if (CLR_CMAKE_PLATFORM_ARCH_I386)
+    add_compile_options(/Gz)
+  endif (CLR_CMAKE_PLATFORM_ARCH_I386)
+
+  add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/GL>)
+  add_compile_options($<$<OR:$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>,$<CONFIG:Checked>>:/O1>)
+
+  if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
+  # The generator expression in the following command means that the /homeparams option is added only for debug builds
+  add_compile_options($<$<CONFIG:Debug>:/homeparams>) # Force parameters passed in registers to be written to the stack
+  endif (CLR_CMAKE_PLATFORM_ARCH_AMD64)
+
+  # enable control-flow-guard support for native components for non-Arm64 builds
+  add_compile_options(/guard:cf) 
+
+  # Statically linked CRT (libcmt[d].lib, libvcruntime[d].lib and libucrt[d].lib) by default. This is done to avoid  
+  # linking in VCRUNTIME140.DLL for a simplified xcopy experience by reducing the dependency on VC REDIST.  
+  #  
+  # 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")
+  
+endif (WIN32)
+
+if(CLR_CMAKE_ENABLE_CODE_COVERAGE)
+
+  if(CLR_CMAKE_PLATFORM_UNIX)
+    string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE)
+    if(NOT UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
+      message( WARNING "Code coverage results with an optimised (non-Debug) build may be misleading" )
+    endif(NOT UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
+
+    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}")
+  else()
+    message(FATAL_ERROR "Code coverage builds not supported on current platform")
+  endif(CLR_CMAKE_PLATFORM_UNIX)
+
+endif(CLR_CMAKE_ENABLE_CODE_COVERAGE)
diff --git a/detectplatform.cmake b/detectplatform.cmake
new file mode 100644 (file)
index 0000000..7b93bbf
--- /dev/null
@@ -0,0 +1,164 @@
+#----------------------------------------
+# Detect and set platform variable names
+#     - for non-windows build platform & architecture is detected using inbuilt CMAKE variables and cross target component configure
+#     - for windows we use the passed in parameter to CMAKE to determine build arch
+#----------------------------------------
+if(CMAKE_SYSTEM_NAME STREQUAL Linux)
+    set(CLR_CMAKE_PLATFORM_UNIX 1)
+    if(CLR_CROSS_COMPONENTS_BUILD)
+        # CMAKE_HOST_SYSTEM_PROCESSOR returns the value of `uname -p` on host.
+        if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
+            if(CLR_CMAKE_TARGET_ARCH STREQUAL "arm")
+                set(CLR_CMAKE_PLATFORM_UNIX_X86 1)
+            else()
+                set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
+            endif()
+        elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL i686)
+            set(CLR_CMAKE_PLATFORM_UNIX_X86 1)
+        else()
+            clr_unknown_arch()
+        endif()
+    else()
+        # CMAKE_SYSTEM_PROCESSOR returns the value of `uname -p` on target.
+        # For the AMD/Intel 64bit architecture two different strings are common.
+        # Linux and Darwin identify it as "x86_64" while FreeBSD and netbsd uses the
+        # "amd64" string. Accept either of the two here.
+        if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
+            set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
+        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
+            set(CLR_CMAKE_PLATFORM_UNIX_ARM 1)
+        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
+            set(CLR_CMAKE_PLATFORM_UNIX_ARM 1)
+        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
+            set(CLR_CMAKE_PLATFORM_UNIX_ARM64 1)
+        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
+            set(CLR_CMAKE_PLATFORM_UNIX_X86 1)
+        else()
+            clr_unknown_arch()
+        endif()
+    endif()
+    set(CLR_CMAKE_PLATFORM_LINUX 1)
+
+    # Detect Linux ID
+    if(DEFINED CLR_CMAKE_LINUX_ID)
+        if(CLR_CMAKE_LINUX_ID STREQUAL ubuntu)
+            set(CLR_CMAKE_TARGET_UBUNTU_LINUX 1)
+        elseif(CLR_CMAKE_LINUX_ID STREQUAL tizen)
+            set(CLR_CMAKE_TARGET_TIZEN_LINUX 1)
+        elseif(CLR_CMAKE_LINUX_ID STREQUAL alpine)
+            set(CLR_CMAKE_PLATFORM_ALPINE_LINUX 1)
+        endif()
+        if(CLR_CMAKE_LINUX_ID STREQUAL ubuntu)
+            set(CLR_CMAKE_PLATFORM_UBUNTU_LINUX 1)
+        endif()
+    endif(DEFINED CLR_CMAKE_LINUX_ID)
+endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
+
+if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+  set(CLR_CMAKE_PLATFORM_UNIX 1)
+  set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
+  set(CLR_CMAKE_PLATFORM_DARWIN 1)
+  if(CMAKE_VERSION VERSION_LESS "3.4.0")
+    set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> -o <OBJECT> -c <SOURCE>")
+  else()
+    set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
+  endif(CMAKE_VERSION VERSION_LESS "3.4.0")
+endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+
+if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
+  set(CLR_CMAKE_PLATFORM_UNIX 1)
+  set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
+  set(CLR_CMAKE_PLATFORM_FREEBSD 1)
+endif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
+
+if(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
+  set(CLR_CMAKE_PLATFORM_UNIX 1)
+  set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
+  set(CLR_CMAKE_PLATFORM_OPENBSD 1)
+endif(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
+
+if(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
+  set(CLR_CMAKE_PLATFORM_UNIX 1)
+  set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
+  set(CLR_CMAKE_PLATFORM_NETBSD 1)
+endif(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
+
+if(CMAKE_SYSTEM_NAME STREQUAL SunOS)
+  set(CLR_CMAKE_PLATFORM_UNIX 1)
+  EXECUTE_PROCESS(
+    COMMAND isainfo -n
+    OUTPUT_VARIABLE SUNOS_NATIVE_INSTRUCTION_SET
+    )
+  if(SUNOS_NATIVE_INSTRUCTION_SET MATCHES "amd64")
+    set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
+    set(CMAKE_SYSTEM_PROCESSOR "amd64")
+  else()
+    clr_unknown_arch()
+  endif()
+  set(CLR_CMAKE_PLATFORM_SUNOS 1)
+endif(CMAKE_SYSTEM_NAME STREQUAL SunOS)
+
+#--------------------------------------------
+# This repo builds two set of binaries
+# 1. binaries which execute on target arch machine
+#        - for such binaries host architecture & target architecture are same
+#        - eg. coreclr.dll
+# 2. binaries which execute on host machine but target another architecture
+#        - host architecture is different from target architecture
+#        - eg. crossgen.exe - runs on x64 machine and generates nis targeting arm64
+#        - for complete list of such binaries refer to file crosscomponents.cmake
+#-------------------------------------------------------------
+# Set HOST architecture variables
+if(CLR_CMAKE_PLATFORM_UNIX_ARM)
+    set(CLR_CMAKE_PLATFORM_ARCH_ARM 1)
+    set(CLR_CMAKE_HOST_ARCH "arm")
+elseif(CLR_CMAKE_PLATFORM_UNIX_ARM64)
+    set(CLR_CMAKE_PLATFORM_ARCH_ARM64 1)
+    set(CLR_CMAKE_HOST_ARCH "arm64")
+elseif(CLR_CMAKE_PLATFORM_UNIX_AMD64)
+    set(CLR_CMAKE_PLATFORM_ARCH_AMD64 1)
+    set(CLR_CMAKE_HOST_ARCH "x64")
+elseif(CLR_CMAKE_PLATFORM_UNIX_X86)
+    set(CLR_CMAKE_PLATFORM_ARCH_I386 1)
+    set(CLR_CMAKE_HOST_ARCH "x86")
+elseif(WIN32)
+    # CLR_CMAKE_HOST_ARCH is passed in as param to cmake
+    if (CLR_CMAKE_HOST_ARCH STREQUAL x64)
+        set(CLR_CMAKE_PLATFORM_ARCH_AMD64 1)
+    elseif(CLR_CMAKE_HOST_ARCH STREQUAL x86)
+        set(CLR_CMAKE_PLATFORM_ARCH_I386 1)
+    elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm)
+        set(CLR_CMAKE_PLATFORM_ARCH_ARM 1)
+    elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm64)
+        set(CLR_CMAKE_PLATFORM_ARCH_ARM64 1)
+    else()
+        clr_unknown_arch()
+    endif()
+endif()
+
+# Set TARGET architecture variables
+# Target arch will be a cmake param (optional) for both windows as well as non-windows build
+# if target arch is not specified then host & target are same
+if(NOT DEFINED CLR_CMAKE_TARGET_ARCH OR CLR_CMAKE_TARGET_ARCH STREQUAL "" )
+  set(CLR_CMAKE_TARGET_ARCH ${CLR_CMAKE_HOST_ARCH})
+endif()
+
+# Set target architecture variables
+if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
+    set(CLR_CMAKE_TARGET_ARCH_AMD64 1)
+  elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
+    set(CLR_CMAKE_TARGET_ARCH_I386 1)
+  elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64)
+    set(CLR_CMAKE_TARGET_ARCH_ARM64 1)
+  elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm)
+    set(CLR_CMAKE_TARGET_ARCH_ARM 1)
+  else()
+    clr_unknown_arch()
+endif()
+
+# check if host & target arch combination are valid
+if(NOT(CLR_CMAKE_TARGET_ARCH STREQUAL CLR_CMAKE_HOST_ARCH))
+    if(NOT((CLR_CMAKE_PLATFORM_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM64) OR (CLR_CMAKE_PLATFORM_ARCH_I386 AND CLR_CMAKE_TARGET_ARCH_ARM)))
+        message(FATAL_ERROR "Invalid host and target arch combination")
+    endif()
+endif()
diff --git a/platformdefinitions.cmake b/platformdefinitions.cmake
new file mode 100644 (file)
index 0000000..d5a4996
--- /dev/null
@@ -0,0 +1,77 @@
+#------------------------------------
+# Definitions (for platform)
+#-----------------------------------
+if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
+  add_definitions(-D_AMD64_)
+  add_definitions(-D_WIN64)
+  add_definitions(-DAMD64)
+  add_definitions(-DBIT64=1)
+elseif (CLR_CMAKE_PLATFORM_ARCH_I386)
+  add_definitions(-D_X86_)
+elseif (CLR_CMAKE_PLATFORM_ARCH_ARM)
+  add_definitions(-D_ARM_)
+  add_definitions(-DARM)
+elseif (CLR_CMAKE_PLATFORM_ARCH_ARM64)
+  add_definitions(-D_ARM64_)
+  add_definitions(-DARM64)
+  add_definitions(-D_WIN64)
+  add_definitions(-DBIT64=1)
+else ()
+  clr_unknown_arch()
+endif ()
+
+if (CLR_CMAKE_PLATFORM_UNIX)
+  if(CLR_CMAKE_PLATFORM_LINUX)
+    if(CLR_CMAKE_PLATFORM_UNIX_AMD64)
+      message("Detected Linux x86_64")
+      add_definitions(-DLINUX64)
+    elseif(CLR_CMAKE_PLATFORM_UNIX_ARM)
+      message("Detected Linux ARM")
+      add_definitions(-DLINUX32)
+    elseif(CLR_CMAKE_PLATFORM_UNIX_ARM64)
+      message("Detected Linux ARM64")
+      add_definitions(-DLINUX64)
+    elseif(CLR_CMAKE_PLATFORM_UNIX_X86)
+      message("Detected Linux i686")
+      add_definitions(-DLINUX32)
+    else()
+      clr_unknown_arch()
+    endif()
+  endif(CLR_CMAKE_PLATFORM_LINUX)
+endif(CLR_CMAKE_PLATFORM_UNIX)
+
+if (CLR_CMAKE_PLATFORM_UNIX)
+  add_definitions(-DPLATFORM_UNIX=1)
+
+  if(CLR_CMAKE_PLATFORM_DARWIN)
+    message("Detected OSX x86_64")
+  endif(CLR_CMAKE_PLATFORM_DARWIN)
+
+  if(CLR_CMAKE_PLATFORM_FREEBSD)
+    message("Detected FreeBSD amd64")
+  endif(CLR_CMAKE_PLATFORM_FREEBSD)
+
+  if(CLR_CMAKE_PLATFORM_NETBSD)
+    message("Detected NetBSD amd64")
+  endif(CLR_CMAKE_PLATFORM_NETBSD)
+endif(CLR_CMAKE_PLATFORM_UNIX)
+
+if (WIN32)
+  # Define the CRT lib references that link into Desktop imports
+  set(STATIC_MT_CRT_LIB  "libcmt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
+  set(STATIC_MT_VCRT_LIB  "libvcruntime$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
+  set(STATIC_MT_CPP_LIB  "libcpmt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
+endif(WIN32)
+
+# Architecture specific files folder name
+if (CLR_CMAKE_TARGET_ARCH_AMD64)
+    set(ARCH_SOURCES_DIR amd64)
+elseif (CLR_CMAKE_TARGET_ARCH_ARM64)
+    set(ARCH_SOURCES_DIR arm64)
+elseif (CLR_CMAKE_TARGET_ARCH_ARM)
+    set(ARCH_SOURCES_DIR arm)
+elseif (CLR_CMAKE_TARGET_ARCH_I386)
+    set(ARCH_SOURCES_DIR i386)
+else ()
+    clr_unknown_arch()
+endif ()
index b515022..3e3ccd9 100644 (file)
@@ -3,10 +3,10 @@
 set(CORECLR_PRODUCT ${CLR_DIR}/bin/Product/${CORECLR_PLATFORM})
 
 add_library(dbgshim SHARED IMPORTED)
-set_target_properties(dbgshim PROPERTIES IMPORTED_LOCATION ${CLR_BIN_DIR}/libdbgshim.so)
+set_target_properties(dbgshim PROPERTIES IMPORTED_LOCATION ${CLR_BIN_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}dbgshim${CMAKE_SHARED_LIBRARY_SUFFIX})
 
 add_library(corguids STATIC IMPORTED)
-set_target_properties(corguids PROPERTIES IMPORTED_LOCATION ${CLR_BIN_DIR}/lib/libcorguids.a)
+set_target_properties(corguids PROPERTIES IMPORTED_LOCATION ${CLR_BIN_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}corguids${CMAKE_STATIC_LIBRARY_SUFFIX})
 
 include_directories(${CLR_DIR}/src/inc)
 include_directories(${CLR_DIR}/src/pal/inc)