Install binaries that are part of shared framework into separa… (dotnet/coreclr#27841)
authorJeremy Koritzinsky <jekoritz@microsoft.com>
Wed, 13 Nov 2019 00:18:18 +0000 (16:18 -0800)
committerGitHub <noreply@github.com>
Wed, 13 Nov 2019 00:18:18 +0000 (16:18 -0800)
* Change the install_clr command to use cmake_parse_arguments to make it easier to extend and easier to read.

Add additional install_clr commands to install the files that go into the shared framework into the sharedFramework folder.

* Install SOS README.

* Collapse conditions. Output message explaining that we're reading the native version out of the native version header so in the case that the header doesn't exist we get something actionable.

Commit migrated from https://github.com/dotnet/coreclr/commit/03b7b318ab6641c20baeb37f963c4599a97d9276

28 files changed:
src/coreclr/functions.cmake
src/coreclr/src/ToolBox/SOS/CMakeLists.txt
src/coreclr/src/coreclr/hosts/coreconsole/CMakeLists.txt
src/coreclr/src/coreclr/hosts/corerun/CMakeLists.txt
src/coreclr/src/coreclr/hosts/coreshim/CMakeLists.txt
src/coreclr/src/coreclr/hosts/osxbundlerun/CMakeLists.txt
src/coreclr/src/coreclr/hosts/unixcoreconsole/CMakeLists.txt
src/coreclr/src/coreclr/hosts/unixcorerun/CMakeLists.txt
src/coreclr/src/corefx/System.Globalization.Native/CMakeLists.txt
src/coreclr/src/debug/createdump/CMakeLists.txt
src/coreclr/src/dlls/clretwrc/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/mscoree/coreclr/CMakeLists.txt
src/coreclr/src/dlls/mscorrc/full/CMakeLists.txt
src/coreclr/src/dlls/mscorrc/small/CMakeLists.txt
src/coreclr/src/gc/CMakeLists.txt
src/coreclr/src/ilasm/CMakeLists.txt
src/coreclr/src/ildasm/exe/CMakeLists.txt
src/coreclr/src/jit/armelnonjit/CMakeLists.txt
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/pal/src/eventprovider/lttngprovider/CMakeLists.txt
src/coreclr/src/tools/crossgen/CMakeLists.txt
src/coreclr/src/tools/crossgen2/jitinterface/CMakeLists.txt

index 14d376d..ed2961d 100644 (file)
@@ -285,27 +285,43 @@ function(strip_symbols targetName outputFilename)
   endif(CLR_CMAKE_PLATFORM_UNIX)
 endfunction()
 
-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)
-
-    # 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 .)
-    endif()
-    if(CLR_CMAKE_PGO_INSTRUMENT)
+# install_clr(TARGETS TARGETS targetName [targetName2 ...] [DESTINATION destination])
+function(install_clr)
+  set(options "")
+  set(oneValueArgs DESTINATION)
+  set(multiValueArgs TARGETS)
+  cmake_parse_arguments(PARSE_ARGV 0 INSTALL_CLR "${options}" "${oneValueArgs}" "${multiValueArgs}")
+
+  if ("${INSTALL_CLR_TARGETS}" STREQUAL "")
+    message(FATAL_ERROR "At least one target must be passed to install_clr(TARGETS )")
+  endif()
+
+  if ("${INSTALL_CLR_DESTINATION}" STREQUAL "")
+    set(INSTALL_CLR_DESTINATION ".")
+  endif()
+
+  foreach(targetName ${INSTALL_CLR_TARGETS})
+    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)
+
+        # 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 ${INSTALL_CLR_DESTINATION})
         if(WIN32)
-            install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pgd DESTINATION PGD OPTIONAL)
+            # 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 ${INSTALL_CLR_DESTINATION}/PDB)
+        else()
+            install(FILES ${strip_destination_file} DESTINATION ${INSTALL_CLR_DESTINATION})
+        endif()
+        if(CLR_CMAKE_PGO_INSTRUMENT)
+            if(WIN32)
+                install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pgd DESTINATION ${INSTALL_CLR_DESTINATION}/PGD OPTIONAL)
+            endif()
         endif()
     endif()
-  endif()
+  endforeach()
 endfunction()
 
 # Disable PAX mprotect that would prevent JIT and other codegen in coreclr from working.
index af190db..e9c1be8 100644 (file)
@@ -5,3 +5,4 @@ if(WIN32)
 endif(WIN32)
 
 _install(FILES SOS_README.md DESTINATION .)
+_install(FILES SOS_README.md DESTINATION sharedFramework)
index c51f287..092d8e3 100644 (file)
@@ -28,6 +28,6 @@ else()
     )
 
     # Can't compile on linux yet so only add for windows
-    install_clr(CoreConsole)
+    install_clr(TARGETS CoreConsole)
 
-endif(CLR_CMAKE_PLATFORM_UNIX)
\ No newline at end of file
+endif(CLR_CMAKE_PLATFORM_UNIX)
index eec4815..e180302 100644 (file)
@@ -33,6 +33,6 @@ else()
     )
 
     # Can't compile on linux yet so only add for windows
-    install_clr(CoreRun)
+    install_clr(TARGETS CoreRun)
 
-endif(CLR_CMAKE_PLATFORM_UNIX)
\ No newline at end of file
+endif(CLR_CMAKE_PLATFORM_UNIX)
index 828b91c..51061e1 100644 (file)
@@ -22,4 +22,4 @@ target_link_libraries(CoreShim
     ${STATIC_MT_VCRT_LIB}
 )
 
-install_clr(CoreShim)
\ No newline at end of file
+install_clr(TARGETS CoreShim)
index 40fab3c..a09c3f3 100644 (file)
@@ -19,4 +19,4 @@ add_dependencies(osxbundlerun
     coreclr
 )
 
-install_clr(osxbundlerun)
+install_clr(TARGETS osxbundlerun)
index cb5e778..eff7a9a 100644 (file)
@@ -30,4 +30,4 @@ if(NOT CLR_CMAKE_PLATFORM_ANDROID)
   )
 endif()
 
-install_clr(corerun)
+install_clr(TARGETS corerun)
index 86709d7..71e1533 100644 (file)
@@ -92,5 +92,6 @@ verify_dependencies(
 )
 
 # add the install targets
-install_clr(System.Globalization.Native)
+install_clr(TARGETS System.Globalization.Native)
+install_clr(TARGETS System.Globalization.Native DESTINATION sharedFramework)
 install(TARGETS System.Globalization.Native_Static DESTINATION .)
index 061051b..674fe23 100644 (file)
@@ -48,4 +48,4 @@ target_link_libraries(createdump
 
 add_dependencies(createdump mscordaccore)
 
-install_clr(createdump)
+install_clr(TARGETS createdump)
index d59279b..8598baf 100644 (file)
@@ -20,6 +20,7 @@ add_library_clr(clretwrc SHARED
 )
 
 # add the install targets
-install_clr(clretwrc)
+install_clr(TARGETS clretwrc)
+install_clr(TARGETS clretwrc DESTINATION sharedFramework)
 
 add_dependencies(clretwrc eventing_headers)
index b1463b6..d355f01 100644 (file)
@@ -81,4 +81,5 @@ endif(WIN32)
 target_link_libraries(dbgshim ${DBGSHIM_LIBRARIES})
 
 # add the install targets
-install_clr(dbgshim)
+install_clr(TARGETS dbgshim)
+install_clr(TARGETS dbgshim DESTINATION sharedFramework)
index 02cc30d..91af96d 100644 (file)
@@ -184,4 +184,20 @@ endif(WIN32)
 target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES})
 
 # add the install targets
-install_clr(mscordaccore)
+install_clr(TARGETS mscordaccore)
+install_clr(TARGETS mscordaccore DESTINATION sharedFramework)
+if(WIN32)
+    set(LONG_NAME_HOST_ARCH ${CLR_CMAKE_HOST_ARCH})
+    set(LONG_NAME_TARGET_ARCH ${CLR_CMAKE_TARGET_ARCH})
+    if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
+        set(LONG_NAME_HOST_ARCH "amd64")
+        set(LONG_NAME_TARGET_ARCH "amd64")
+    endif()
+    set(NATIVE_VERSION_HEADER_FILE "${CLR_DIR}/bin/obj/_version.h")
+    message ("Read file version from native version header at '${NATIVE_VERSION_HEADER_FILE}'.")
+    file(READ "${NATIVE_VERSION_HEADER_FILE}" NATIVE_VERSION_HEADER)
+    string(REGEX MATCH "#define VER_FILEVERSION[ \t]+[0-9]+(,[0-9]+)+" FILE_VERSION_LINE "${NATIVE_VERSION_HEADER}")
+    string(REGEX MATCHALL "[0-9]+" FILE_VERSION_COMPONENTS "${FILE_VERSION_LINE}")
+    list(JOIN FILE_VERSION_COMPONENTS "." FILE_VERSION)
+    install(FILES $<TARGET_FILE:mscordaccore> RENAME mscordaccore_${LONG_NAME_HOST_ARCH}_${LONG_NAME_TARGET_ARCH}_${FILE_VERSION}.dll DESTINATION sharedFramework)
+endif()
index 13b8691..b586319 100644 (file)
@@ -118,4 +118,5 @@ elseif(CLR_CMAKE_PLATFORM_UNIX)
 endif(WIN32)
 
 # add the install targets
-install_clr(mscordbi)
+install_clr(TARGETS mscordbi)
+install_clr(TARGETS mscordbi DESTINATION sharedFramework)
index 0b89ee0..04e48a4 100644 (file)
@@ -202,7 +202,8 @@ if(WIN32)
 endif(WIN32)
 
 # add the install targets
-install_clr(coreclr)
+install_clr(TARGETS coreclr)
+install_clr(TARGETS coreclr DESTINATION sharedFramework)
 
 # Enable profile guided optimization
 add_pgo(coreclr)
index 50fe516..d3c2ea8 100644 (file)
@@ -6,7 +6,8 @@ if(WIN32)
     ../include.rc
   )
 
-  install_clr (mscorrc.debug)
+  install_clr(TARGETS mscorrc.debug)
+  install_clr(TARGETS mscorrc.debug DESTINATION sharedFramework)
 
 else()
   build_resources(${CMAKE_CURRENT_SOURCE_DIR}/../include.rc mscorrc_debug TARGET_CPP_FILE)
index 7c359e0..d8ddc6a 100644 (file)
@@ -4,5 +4,5 @@ add_library_clr(mscorrc SHARED
   ../mscorrc.small.rc
 )
 
-# add the install targets
-install_clr (mscorrc)
\ No newline at end of file
+install_clr(TARGETS mscorrc)
+install_clr(TARGETS mscorrc DESTINATION sharedFramework)
index 17a774c..14bcea0 100644 (file)
@@ -94,7 +94,7 @@ convert_to_absolute_path(GC_SOURCES ${GC_SOURCES})
 add_library_clr(clrgc SHARED ${GC_SOURCES})
 add_dependencies(clrgc eventing_headers)
 target_link_libraries(clrgc ${GC_LINK_LIBRARIES})
-install_clr(clrgc)
+install_clr(TARGETS clrgc)
 
 if(CLR_CMAKE_PLATFORM_UNIX)
   # dprintf causes many warnings (https://github.com/dotnet/coreclr/issues/13367)
index c2ad35a..bd66fd9 100644 (file)
@@ -133,4 +133,4 @@ else()
   )
 endif(CLR_CMAKE_PLATFORM_UNIX)
 
-install_clr(ilasm)
+install_clr(TARGETS ilasm)
index 6deb8b9..15dd82b 100644 (file)
@@ -123,4 +123,4 @@ else()
     )
 endif(CLR_CMAKE_PLATFORM_UNIX)
 
-install_clr(ildasm)
+install_clr(TARGETS ildasm)
index 341aff6..714800a 100644 (file)
@@ -91,4 +91,4 @@ target_link_libraries(armelnonjit
 )
 
 # add the install targets
-install_clr(armelnonjit)
+install_clr(TARGETS armelnonjit)
index aeed813..a86ac1f 100644 (file)
@@ -75,4 +75,4 @@ target_link_libraries(linuxnonjit
 )
 
 # add the install targets
-install_clr(linuxnonjit)
+install_clr(TARGETS linuxnonjit)
index 533d541..3cfe839 100644 (file)
@@ -62,4 +62,4 @@ target_link_libraries(protojit
 )
 
 # add the install targets
-install_clr(protojit)
+install_clr(TARGETS protojit)
index f7466a8..bab6994 100644 (file)
@@ -89,4 +89,4 @@ target_link_libraries(protononjit
 )
 
 # add the install targets
-install_clr(protononjit)
+install_clr(TARGETS protononjit)
index 572bfc7..0c4e80c 100644 (file)
@@ -32,7 +32,8 @@ target_link_libraries(clrjit
 )
 
 # add the install targets
-install_clr(clrjit)
+install_clr(TARGETS clrjit)
+install_clr(TARGETS clrjit DESTINATION sharedFramework)
 
 # Enable profile guided optimization
 add_pgo(clrjit)
index b9e4f15..e3d20ab 100644 (file)
@@ -73,4 +73,4 @@ set_target_properties(coreclrtraceptprovider PROPERTIES LINKER_LANGUAGE CXX)
 # Install the static eventprovider library
 _install(TARGETS eventprovider DESTINATION lib)
 # Install the static coreclrtraceptprovider library
-install_clr(coreclrtraceptprovider)
+install_clr(TARGETS coreclrtraceptprovider)
index 0f33857..eb10882 100644 (file)
@@ -70,4 +70,5 @@ add_subdirectory(../../zap ../../zap)
 add_subdirectory(../../vm/crossgen ../../vm/crossgen)
 
 # add the install targets
-install_clr(crossgen)
+install_clr(TARGETS crossgen)
+install_clr(TARGETS crossgen DESTINATION sharedFramework)
index 371f08d..db31bda 100644 (file)
@@ -12,4 +12,4 @@ add_library_clr(jitinterface
     ${NATIVE_SOURCES}
 )
 
-install_clr(jitinterface)
+install_clr(TARGETS jitinterface)