Skip to content

Commit

Permalink
Install binaries that are part of shared framework into separa… (dotn…
Browse files Browse the repository at this point in the history
…et/coreclr#27841)

* 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 dotnet/coreclr@03b7b31
  • Loading branch information
jkoritzinsky authored Nov 13, 2019
1 parent 3b21198 commit e6d3afb
Show file tree
Hide file tree
Showing 28 changed files with 88 additions and 47 deletions.
52 changes: 34 additions & 18 deletions src/coreclr/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/src/ToolBox/SOS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ if(WIN32)
endif(WIN32)

_install(FILES SOS_README.md DESTINATION .)
_install(FILES SOS_README.md DESTINATION sharedFramework)
4 changes: 2 additions & 2 deletions src/coreclr/src/coreclr/hosts/coreconsole/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
endif(CLR_CMAKE_PLATFORM_UNIX)
4 changes: 2 additions & 2 deletions src/coreclr/src/coreclr/hosts/corerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
endif(CLR_CMAKE_PLATFORM_UNIX)
2 changes: 1 addition & 1 deletion src/coreclr/src/coreclr/hosts/coreshim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ target_link_libraries(CoreShim
${STATIC_MT_VCRT_LIB}
)

install_clr(CoreShim)
install_clr(TARGETS CoreShim)
2 changes: 1 addition & 1 deletion src/coreclr/src/coreclr/hosts/osxbundlerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ add_dependencies(osxbundlerun
coreclr
)

install_clr(osxbundlerun)
install_clr(TARGETS osxbundlerun)
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ if(NOT CLR_CMAKE_PLATFORM_ANDROID)
)
endif()

install_clr(coreconsole)
install_clr(TARGETS coreconsole)
2 changes: 1 addition & 1 deletion src/coreclr/src/coreclr/hosts/unixcorerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ if(NOT CLR_CMAKE_PLATFORM_ANDROID)
)
endif()

install_clr(corerun)
install_clr(TARGETS corerun)
Original file line number Diff line number Diff line change
Expand Up @@ -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 .)
2 changes: 1 addition & 1 deletion src/coreclr/src/debug/createdump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ target_link_libraries(createdump

add_dependencies(createdump mscordaccore)

install_clr(createdump)
install_clr(TARGETS createdump)
3 changes: 2 additions & 1 deletion src/coreclr/src/dlls/clretwrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion src/coreclr/src/dlls/dbgshim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 17 additions & 1 deletion src/coreclr/src/dlls/mscordac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
3 changes: 2 additions & 1 deletion src/coreclr/src/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion src/coreclr/src/dlls/mscorrc/full/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/src/dlls/mscorrc/small/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ add_library_clr(mscorrc SHARED
../mscorrc.small.rc
)

# add the install targets
install_clr (mscorrc)
install_clr(TARGETS mscorrc)
install_clr(TARGETS mscorrc DESTINATION sharedFramework)
2 changes: 1 addition & 1 deletion src/coreclr/src/gc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/ilasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ else()
)
endif(CLR_CMAKE_PLATFORM_UNIX)

install_clr(ilasm)
install_clr(TARGETS ilasm)
2 changes: 1 addition & 1 deletion src/coreclr/src/ildasm/exe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ else()
)
endif(CLR_CMAKE_PLATFORM_UNIX)

install_clr(ildasm)
install_clr(TARGETS ildasm)
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/armelnonjit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ target_link_libraries(armelnonjit
)

# add the install targets
install_clr(armelnonjit)
install_clr(TARGETS armelnonjit)
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/linuxnonjit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ target_link_libraries(linuxnonjit
)

# add the install targets
install_clr(linuxnonjit)
install_clr(TARGETS linuxnonjit)
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/protojit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ target_link_libraries(protojit
)

# add the install targets
install_clr(protojit)
install_clr(TARGETS protojit)
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/protononjit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ target_link_libraries(protononjit
)

# add the install targets
install_clr(protononjit)
install_clr(TARGETS protononjit)
3 changes: 2 additions & 1 deletion src/coreclr/src/jit/standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion src/coreclr/src/tools/crossgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ add_library_clr(jitinterface
${NATIVE_SOURCES}
)

install_clr(jitinterface)
install_clr(TARGETS jitinterface)

0 comments on commit e6d3afb

Please sign in to comment.