diff --git a/src/coreclr/functions.cmake b/src/coreclr/functions.cmake index 14d376ddb0fb9..ed2961db0a8a1 100644 --- a/src/coreclr/functions.cmake +++ b/src/coreclr/functions.cmake @@ -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 $ DESTINATION .) - if(WIN32) - # We can't use the $ generator expression here since - # the generator expression isn't supported on resource DLLs. - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$/${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 $ DESTINATION ${INSTALL_CLR_DESTINATION}) if(WIN32) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$/${targetName}.pgd DESTINATION PGD OPTIONAL) + # We can't use the $ generator expression here since + # the generator expression isn't supported on resource DLLs. + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$/${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}/$/${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. diff --git a/src/coreclr/src/ToolBox/SOS/CMakeLists.txt b/src/coreclr/src/ToolBox/SOS/CMakeLists.txt index af190db35182b..e9c1be8c95e86 100644 --- a/src/coreclr/src/ToolBox/SOS/CMakeLists.txt +++ b/src/coreclr/src/ToolBox/SOS/CMakeLists.txt @@ -5,3 +5,4 @@ if(WIN32) endif(WIN32) _install(FILES SOS_README.md DESTINATION .) +_install(FILES SOS_README.md DESTINATION sharedFramework) diff --git a/src/coreclr/src/coreclr/hosts/coreconsole/CMakeLists.txt b/src/coreclr/src/coreclr/hosts/coreconsole/CMakeLists.txt index c51f287699100..092d8e31f2c93 100644 --- a/src/coreclr/src/coreclr/hosts/coreconsole/CMakeLists.txt +++ b/src/coreclr/src/coreclr/hosts/coreconsole/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/src/coreclr/hosts/corerun/CMakeLists.txt index eec4815be896c..e18030219f87c 100644 --- a/src/coreclr/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/src/coreclr/hosts/corerun/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/coreclr/hosts/coreshim/CMakeLists.txt b/src/coreclr/src/coreclr/hosts/coreshim/CMakeLists.txt index 828b91ce5b140..51061e11d1dd3 100644 --- a/src/coreclr/src/coreclr/hosts/coreshim/CMakeLists.txt +++ b/src/coreclr/src/coreclr/hosts/coreshim/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/coreclr/hosts/osxbundlerun/CMakeLists.txt b/src/coreclr/src/coreclr/hosts/osxbundlerun/CMakeLists.txt index 40fab3cdf1c6f..a09c3f330ad90 100644 --- a/src/coreclr/src/coreclr/hosts/osxbundlerun/CMakeLists.txt +++ b/src/coreclr/src/coreclr/hosts/osxbundlerun/CMakeLists.txt @@ -19,4 +19,4 @@ add_dependencies(osxbundlerun coreclr ) -install_clr(osxbundlerun) +install_clr(TARGETS osxbundlerun) diff --git a/src/coreclr/src/coreclr/hosts/unixcoreconsole/CMakeLists.txt b/src/coreclr/src/coreclr/hosts/unixcoreconsole/CMakeLists.txt index fbd7c8e994a7b..23546c606e8b9 100644 --- a/src/coreclr/src/coreclr/hosts/unixcoreconsole/CMakeLists.txt +++ b/src/coreclr/src/coreclr/hosts/unixcoreconsole/CMakeLists.txt @@ -29,4 +29,4 @@ if(NOT CLR_CMAKE_PLATFORM_ANDROID) ) endif() -install_clr(coreconsole) +install_clr(TARGETS coreconsole) diff --git a/src/coreclr/src/coreclr/hosts/unixcorerun/CMakeLists.txt b/src/coreclr/src/coreclr/hosts/unixcorerun/CMakeLists.txt index cb5e7781b533e..eff7a9aa76a3f 100644 --- a/src/coreclr/src/coreclr/hosts/unixcorerun/CMakeLists.txt +++ b/src/coreclr/src/coreclr/hosts/unixcorerun/CMakeLists.txt @@ -30,4 +30,4 @@ if(NOT CLR_CMAKE_PLATFORM_ANDROID) ) endif() -install_clr(corerun) +install_clr(TARGETS corerun) diff --git a/src/coreclr/src/corefx/System.Globalization.Native/CMakeLists.txt b/src/coreclr/src/corefx/System.Globalization.Native/CMakeLists.txt index 86709d71fb023..71e153328d0a9 100644 --- a/src/coreclr/src/corefx/System.Globalization.Native/CMakeLists.txt +++ b/src/coreclr/src/corefx/System.Globalization.Native/CMakeLists.txt @@ -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 .) diff --git a/src/coreclr/src/debug/createdump/CMakeLists.txt b/src/coreclr/src/debug/createdump/CMakeLists.txt index 061051b936bcb..674fe23a0da74 100644 --- a/src/coreclr/src/debug/createdump/CMakeLists.txt +++ b/src/coreclr/src/debug/createdump/CMakeLists.txt @@ -48,4 +48,4 @@ target_link_libraries(createdump add_dependencies(createdump mscordaccore) -install_clr(createdump) +install_clr(TARGETS createdump) diff --git a/src/coreclr/src/dlls/clretwrc/CMakeLists.txt b/src/coreclr/src/dlls/clretwrc/CMakeLists.txt index d59279bd78af1..8598baf1bad7e 100644 --- a/src/coreclr/src/dlls/clretwrc/CMakeLists.txt +++ b/src/coreclr/src/dlls/clretwrc/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/dlls/dbgshim/CMakeLists.txt b/src/coreclr/src/dlls/dbgshim/CMakeLists.txt index b1463b64b3e8f..d355f0152788e 100644 --- a/src/coreclr/src/dlls/dbgshim/CMakeLists.txt +++ b/src/coreclr/src/dlls/dbgshim/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/dlls/mscordac/CMakeLists.txt b/src/coreclr/src/dlls/mscordac/CMakeLists.txt index 02cc30d951b00..91af96db9bc05 100644 --- a/src/coreclr/src/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscordac/CMakeLists.txt @@ -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 $ RENAME mscordaccore_${LONG_NAME_HOST_ARCH}_${LONG_NAME_TARGET_ARCH}_${FILE_VERSION}.dll DESTINATION sharedFramework) +endif() diff --git a/src/coreclr/src/dlls/mscordbi/CMakeLists.txt b/src/coreclr/src/dlls/mscordbi/CMakeLists.txt index 13b8691f2f8ac..b586319624131 100644 --- a/src/coreclr/src/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscordbi/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt index 0b89ee0bc30da..04e48a437ef2b 100644 --- a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/dlls/mscorrc/full/CMakeLists.txt b/src/coreclr/src/dlls/mscorrc/full/CMakeLists.txt index 50fe5165461cb..d3c2ea88288be 100644 --- a/src/coreclr/src/dlls/mscorrc/full/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscorrc/full/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/dlls/mscorrc/small/CMakeLists.txt b/src/coreclr/src/dlls/mscorrc/small/CMakeLists.txt index 7c359e075e395..d8ddc6a2be016 100644 --- a/src/coreclr/src/dlls/mscorrc/small/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscorrc/small/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/gc/CMakeLists.txt b/src/coreclr/src/gc/CMakeLists.txt index 17a774ceb5c25..14bcea0d16e51 100644 --- a/src/coreclr/src/gc/CMakeLists.txt +++ b/src/coreclr/src/gc/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/ilasm/CMakeLists.txt b/src/coreclr/src/ilasm/CMakeLists.txt index c2ad35a0d75f9..bd66fd930d74c 100644 --- a/src/coreclr/src/ilasm/CMakeLists.txt +++ b/src/coreclr/src/ilasm/CMakeLists.txt @@ -133,4 +133,4 @@ else() ) endif(CLR_CMAKE_PLATFORM_UNIX) -install_clr(ilasm) +install_clr(TARGETS ilasm) diff --git a/src/coreclr/src/ildasm/exe/CMakeLists.txt b/src/coreclr/src/ildasm/exe/CMakeLists.txt index 6deb8b9b6f8a0..15dd82b7424ba 100644 --- a/src/coreclr/src/ildasm/exe/CMakeLists.txt +++ b/src/coreclr/src/ildasm/exe/CMakeLists.txt @@ -123,4 +123,4 @@ else() ) endif(CLR_CMAKE_PLATFORM_UNIX) -install_clr(ildasm) +install_clr(TARGETS ildasm) diff --git a/src/coreclr/src/jit/armelnonjit/CMakeLists.txt b/src/coreclr/src/jit/armelnonjit/CMakeLists.txt index 341aff6ef5b35..714800aa7b27b 100644 --- a/src/coreclr/src/jit/armelnonjit/CMakeLists.txt +++ b/src/coreclr/src/jit/armelnonjit/CMakeLists.txt @@ -91,4 +91,4 @@ target_link_libraries(armelnonjit ) # add the install targets -install_clr(armelnonjit) +install_clr(TARGETS armelnonjit) diff --git a/src/coreclr/src/jit/linuxnonjit/CMakeLists.txt b/src/coreclr/src/jit/linuxnonjit/CMakeLists.txt index aeed8137dec1f..a86ac1ffeaeec 100644 --- a/src/coreclr/src/jit/linuxnonjit/CMakeLists.txt +++ b/src/coreclr/src/jit/linuxnonjit/CMakeLists.txt @@ -75,4 +75,4 @@ target_link_libraries(linuxnonjit ) # add the install targets -install_clr(linuxnonjit) +install_clr(TARGETS linuxnonjit) diff --git a/src/coreclr/src/jit/protojit/CMakeLists.txt b/src/coreclr/src/jit/protojit/CMakeLists.txt index 533d541d4e53e..3cfe839ddf4b5 100644 --- a/src/coreclr/src/jit/protojit/CMakeLists.txt +++ b/src/coreclr/src/jit/protojit/CMakeLists.txt @@ -62,4 +62,4 @@ target_link_libraries(protojit ) # add the install targets -install_clr(protojit) +install_clr(TARGETS protojit) diff --git a/src/coreclr/src/jit/protononjit/CMakeLists.txt b/src/coreclr/src/jit/protononjit/CMakeLists.txt index f7466a8549386..bab6994f68908 100644 --- a/src/coreclr/src/jit/protononjit/CMakeLists.txt +++ b/src/coreclr/src/jit/protononjit/CMakeLists.txt @@ -89,4 +89,4 @@ target_link_libraries(protononjit ) # add the install targets -install_clr(protononjit) +install_clr(TARGETS protononjit) diff --git a/src/coreclr/src/jit/standalone/CMakeLists.txt b/src/coreclr/src/jit/standalone/CMakeLists.txt index 572bfc7682d66..0c4e80cc7f091 100644 --- a/src/coreclr/src/jit/standalone/CMakeLists.txt +++ b/src/coreclr/src/jit/standalone/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt b/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt index b9e4f1574b8d6..e3d20ab68770a 100644 --- a/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt +++ b/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/tools/crossgen/CMakeLists.txt b/src/coreclr/src/tools/crossgen/CMakeLists.txt index 0f338572c8632..eb1088235ca66 100644 --- a/src/coreclr/src/tools/crossgen/CMakeLists.txt +++ b/src/coreclr/src/tools/crossgen/CMakeLists.txt @@ -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) diff --git a/src/coreclr/src/tools/crossgen2/jitinterface/CMakeLists.txt b/src/coreclr/src/tools/crossgen2/jitinterface/CMakeLists.txt index 371f08d03bbd5..db31bdaa3e82b 100644 --- a/src/coreclr/src/tools/crossgen2/jitinterface/CMakeLists.txt +++ b/src/coreclr/src/tools/crossgen2/jitinterface/CMakeLists.txt @@ -12,4 +12,4 @@ add_library_clr(jitinterface ${NATIVE_SOURCES} ) -install_clr(jitinterface) +install_clr(TARGETS jitinterface)