Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 37 additions & 19 deletions eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -291,47 +291,65 @@ function(strip_symbols targetName outputFilename)
endif (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_IOS)

set(${outputFilename} ${strip_destination_file} PARENT_SCOPE)
else(CLR_CMAKE_HOST_UNIX)
set(${outputFilename} ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb PARENT_SCOPE)
endif(CLR_CMAKE_HOST_UNIX)
endfunction()

function(install_symbols targetName destination_path)
strip_symbols(${targetName} strip_destination_file)
function(install_with_stripped_symbols targetName kind destination)
strip_symbols(${targetName} symbol_file)
install_symbols(${symbol_file} ${destination})
if ("${kind}" STREQUAL "TARGETS")
set(install_source ${targetName})
elseif("${kind}" STREQUAL "PROGRAMS")
set(install_source $<TARGET_FILE:${targetName}>)
else()
message(FATAL_ERROR "The `kind` argument has to be either TARGETS or PROGRAMS, ${kind} was provided instead")
endif()
install(${kind} ${install_source} DESTINATION ${destination})
endfunction()

function(install_symbols symbol_file destination_path)
if(CLR_CMAKE_TARGET_WIN32)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb DESTINATION ${destination_path}/PDB)
install(FILES ${symbol_file} DESTINATION ${destination_path}/PDB)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better, if we do not modify this (Windows) part at this stage, as it is working out fine. Otherwise we would need to update libraries and installer as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll rather look into fixing the libraries and installer. I have forgotten that they use these now too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I remember doing similar cleanup in libraries, it was something like touching one file (src/libraries/Native/Unix/CMakeLists.txt) vs. multiple other CMakeLists.txt under libraries, therefore, ended up favoring the common pattern so to touch fewer files. :)

else()
install(FILES ${strip_destination_file} DESTINATION ${destination_path})
install(FILES ${symbol_file} DESTINATION ${destination_path})
endif()
endfunction()

# install_clr(TARGETS TARGETS targetName [targetName2 ...] [DESTINATION destination])
# install_clr(TARGETS TARGETS targetName [targetName2 ...] [ADDITIONAL_DESTINATION destination])
function(install_clr)
set(oneValueArgs DESTINATION)
set(oneValueArgs ADDITIONAL_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 ".")
set(destinations ".")

if (NOT "${INSTALL_CLR_ADDITIONAL_DESTINATION}" STREQUAL "")
list(APPEND destinations ${INSTALL_CLR_ADDITIONAL_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)
install_symbols(${targetName} ${INSTALL_CLR_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 ${INSTALL_CLR_DESTINATION})

if(CLR_CMAKE_PGO_INSTRUMENT)
if(WIN32)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pgd DESTINATION ${INSTALL_CLR_DESTINATION}/PGD OPTIONAL)
endif()
endif()
strip_symbols(${targetName} symbol_file)

foreach(destination in ${destinations})
# 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 ${destination})
install_symbols(${symbol_file} ${destination})

if(CLR_CMAKE_PGO_INSTRUMENT)
if(WIN32)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pgd DESTINATION ${destination}/PGD OPTIONAL)
endif()
endif()
endforeach()
endif()
endforeach()
endfunction()
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/src/debug/createdump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ target_link_libraries(createdump

add_dependencies(createdump mscordaccore)

install_clr(TARGETS createdump)
install_clr(TARGETS createdump DESTINATION sharedFramework)
install_clr(TARGETS createdump ADDITIONAL_DESTINATION sharedFramework)
3 changes: 1 addition & 2 deletions src/coreclr/src/dlls/clretwrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ add_library_clr(clretwrc SHARED
)

# add the install targets
install_clr(TARGETS clretwrc)
install_clr(TARGETS clretwrc DESTINATION sharedFramework)
install_clr(TARGETS clretwrc ADDITIONAL_DESTINATION sharedFramework)

add_dependencies(clretwrc eventing_headers)
3 changes: 1 addition & 2 deletions src/coreclr/src/dlls/dbgshim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,4 @@ endif(CLR_CMAKE_HOST_WIN32)
target_link_libraries(dbgshim ${DBGSHIM_LIBRARIES})

# add the install targets
install_clr(TARGETS dbgshim)
install_clr(TARGETS dbgshim DESTINATION sharedFramework)
install_clr(TARGETS dbgshim ADDITIONAL_DESTINATION sharedFramework)
3 changes: 1 addition & 2 deletions src/coreclr/src/dlls/mscordac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ endif(CLR_CMAKE_HOST_WIN32)
target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES})

# add the install targets
install_clr(TARGETS mscordaccore)
install_clr(TARGETS mscordaccore DESTINATION sharedFramework)
install_clr(TARGETS mscordaccore ADDITIONAL_DESTINATION sharedFramework)

if(CLR_CMAKE_HOST_WIN32)
set(LONG_NAME_HOST_ARCH ${CLR_CMAKE_HOST_ARCH})
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/src/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,4 @@ elseif(CLR_CMAKE_HOST_UNIX)
endif(CLR_CMAKE_HOST_WIN32)

# add the install targets
install_clr(TARGETS mscordbi)
install_clr(TARGETS mscordbi DESTINATION sharedFramework)
install_clr(TARGETS mscordbi ADDITIONAL_DESTINATION sharedFramework)
3 changes: 1 addition & 2 deletions src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ if(CLR_CMAKE_TARGET_WIN32)
endif(CLR_CMAKE_TARGET_WIN32)

# add the install targets
install_clr(TARGETS coreclr)
install_clr(TARGETS coreclr DESTINATION sharedFramework)
install_clr(TARGETS coreclr ADDITIONAL_DESTINATION sharedFramework)

# Enable profile guided optimization
add_pgo(coreclr)
3 changes: 1 addition & 2 deletions src/coreclr/src/dlls/mscorrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ if(CLR_CMAKE_HOST_WIN32)
include.rc
)

install_clr(TARGETS mscorrc)
install_clr(TARGETS mscorrc DESTINATION sharedFramework)
install_clr(TARGETS mscorrc ADDITIONAL_DESTINATION sharedFramework)
else()
build_resources(${CMAKE_CURRENT_SOURCE_DIR}/include.rc mscorrc TARGET_CPP_FILE)

Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/src/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ else()
endif(CLR_CMAKE_HOST_UNIX)

# Shared function for generating JIT
# optional arguments: ADDITIONAL_DESTINATION path
function(add_jit jitName)
if(CLR_CMAKE_TARGET_WIN32)
add_definitions(-DFX_VER_INTERNALNAME_STR=${jitName}.dll)
Expand All @@ -385,7 +386,7 @@ function(add_jit jitName)
)

# add the install targets
install_clr(TARGETS ${jitName})
install_clr(TARGETS ${jitName} ${ARGN})
endfunction()

set(JIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down
5 changes: 1 addition & 4 deletions src/coreclr/src/jit/standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ if(FEATURE_READYTORUN)
add_definitions(-DFEATURE_READYTORUN_COMPILER)
endif(FEATURE_READYTORUN)

add_jit(clrjit)

# add the install targets
install_clr(TARGETS clrjit DESTINATION sharedFramework)
add_jit(clrjit ADDITIONAL_DESTINATION sharedFramework)

# Enable profile guided optimization
add_pgo(clrjit)
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,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(TARGETS coreclrtraceptprovider)
install_clr(TARGETS coreclrtraceptprovider DESTINATION sharedFramework)
install_clr(TARGETS coreclrtraceptprovider ADDITIONAL_DESTINATION sharedFramework)
3 changes: 1 addition & 2 deletions src/coreclr/src/tools/crossgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,4 @@ add_subdirectory(../../zap ../../zap)
add_subdirectory(../../vm/crossgen ../../vm/crossgen)

# add the install targets
install_clr(TARGETS crossgen)
install_clr(TARGETS crossgen DESTINATION sharedFramework)
install_clr(TARGETS crossgen ADDITIONAL_DESTINATION sharedFramework)
3 changes: 1 addition & 2 deletions src/installer/corehost/cli/comhost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ if (CLR_CMAKE_TARGET_WIN32)
target_link_libraries(comhost ${WINLIBS})
endif()

install(TARGETS comhost DESTINATION corehost)
install_symbols(comhost corehost)
install_with_stripped_symbols(comhost TARGETS corehost)
target_link_libraries(comhost libhostcommon)
3 changes: 1 addition & 2 deletions src/installer/corehost/cli/exe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ if(NOT CLR_CMAKE_TARGET_WIN32)
disable_pax_mprotect(${DOTNET_PROJECT_NAME})
endif()

install(TARGETS ${DOTNET_PROJECT_NAME} DESTINATION corehost)
install_symbols(${DOTNET_PROJECT_NAME} corehost)
install_with_stripped_symbols(${DOTNET_PROJECT_NAME} TARGETS corehost)

set_common_libs("exe")
3 changes: 1 addition & 2 deletions src/installer/corehost/cli/fxr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,5 @@ set(HEADERS

include(../lib.cmake)

install(TARGETS hostfxr DESTINATION corehost)
install_symbols(hostfxr corehost)
install_with_stripped_symbols(hostfxr TARGETS corehost)
target_link_libraries(hostfxr libhostcommon)
3 changes: 1 addition & 2 deletions src/installer/corehost/cli/hostpolicy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ set(HEADERS

include(../lib.cmake)

install(TARGETS hostpolicy DESTINATION corehost)
install_symbols(hostpolicy corehost)
install_with_stripped_symbols(hostpolicy TARGETS corehost)
target_link_libraries(hostpolicy libhostcommon)
3 changes: 1 addition & 2 deletions src/installer/corehost/cli/ijwhost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_AR
target_link_libraries(ijwhost Advapi32.lib Ole32.lib)
endif()

install(TARGETS ijwhost DESTINATION corehost)
install_symbols (ijwhost corehost)
install_with_stripped_symbols(ijwhost TARGETS corehost)
3 changes: 1 addition & 2 deletions src/installer/corehost/cli/nethost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ add_definitions(-DFEATURE_LIBHOST=1)
add_definitions(-DNETHOST_EXPORT)

install(FILES nethost.h DESTINATION corehost)
install(TARGETS nethost DESTINATION corehost)
install(TARGETS libnethost DESTINATION corehost)
install_symbols(nethost corehost)
install_with_stripped_symbols(nethost TARGETS corehost)
3 changes: 1 addition & 2 deletions src/installer/corehost/cli/test/mockcoreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ endif()

include(../testlib.cmake)

install(TARGETS mockcoreclr DESTINATION corehost_test)
install_symbols(mockcoreclr corehost_test)
install_with_stripped_symbols(mockcoreclr TARGETS corehost_test)
3 changes: 1 addition & 2 deletions src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ set(SOURCES

include(../testlib.cmake)

install(TARGETS mockhostfxr_2_2 DESTINATION corehost_test)
install_symbols(mockhostfxr_2_2 corehost_test)
install_with_stripped_symbols(mockhostfxr_2_2 TARGETS corehost_test)
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ set(SOURCES

include(../testlib.cmake)

install(TARGETS mockhostpolicy DESTINATION corehost_test)
install_symbols(mockhostpolicy corehost_test)
install_with_stripped_symbols(mockhostpolicy TARGETS corehost_test)
3 changes: 1 addition & 2 deletions src/installer/corehost/cli/test/testexe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/../common.cmake)

add_executable(${DOTNET_PROJECT_NAME} ${SOURCES})

install(TARGETS ${DOTNET_PROJECT_NAME} DESTINATION corehost_test)
install_symbols(${DOTNET_PROJECT_NAME} corehost_test)
install_with_stripped_symbols(${DOTNET_PROJECT_NAME} TARGETS corehost_test)

set_common_libs("exe")
3 changes: 1 addition & 2 deletions src/installer/corehost/cli/winrthost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ endif()

target_link_libraries(winrthost RuntimeObject.lib libhostmisc libhostcommon)

install(TARGETS winrthost DESTINATION corehost)
install_symbols(winrthost corehost)
install_with_stripped_symbols(winrthost TARGETS corehost)
6 changes: 0 additions & 6 deletions src/libraries/Native/Unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,6 @@ if(CLR_CMAKE_TARGET_UNIX)
add_definitions(-DTARGET_UNIX)
endif(CLR_CMAKE_TARGET_UNIX)

function(install_library_and_symbols targetName)
install_symbols(${targetName} .)
set(install_source_file $<TARGET_FILE:${targetName}>)
install(PROGRAMS ${install_source_file} DESTINATION .)
endfunction()

include(configure.cmake)

add_subdirectory(System.IO.Compression.Native)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if (GEN_SHARED_LIB)
dl
)

install_library_and_symbols (System.Globalization.Native)
install_with_stripped_symbols (System.Globalization.Native PROGRAMS .)
endif()

add_library(System.Globalization.Native-Static
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if (GEN_SHARED_LIB)
target_link_libraries(System.IO.Compression.Native
${ZLIB_LIBRARIES}
)
install_library_and_symbols (System.IO.Compression.Native)
install_with_stripped_symbols (System.IO.Compression.Native PROGRAMS .)
endif ()

add_library(System.IO.Compression.Native-Static
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ add_library(System.IO.Ports.Native-Static

set_target_properties(System.IO.Ports.Native-Static PROPERTIES OUTPUT_NAME System.IO.Ports.Native CLEAN_DIRECT_OUTPUT 1)

install_library_and_symbols (System.IO.Ports.Native)
install_with_stripped_symbols (System.IO.Ports.Native PROGRAMS .)
install (TARGETS System.IO.Ports.Native-Static DESTINATION .)
2 changes: 1 addition & 1 deletion src/libraries/Native/Unix/System.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if (GEN_SHARED_LIB)
target_link_libraries(System.Native ${INOTIFY_LIBRARY})
endif ()
endif ()
install_library_and_symbols (System.Native)
install_with_stripped_symbols (System.Native PROGRAMS .)
endif ()

add_library(System.Native-Static
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ target_link_libraries(System.Net.Security.Native
${LIBGSS}
)

install_library_and_symbols (System.Net.Security.Native)
install_with_stripped_symbols (System.Net.Security.Native PROGRAMS .)
install (TARGETS System.Net.Security.Native-Static DESTINATION .)
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ target_link_libraries(System.Security.Cryptography.Native.Apple
${SECURITY_LIBRARY}
)

install_library_and_symbols (System.Security.Cryptography.Native.Apple)
install_with_stripped_symbols (System.Security.Cryptography.Native.Apple PROGRAMS .)
install (TARGETS System.Security.Cryptography.Native.Apple-Static DESTINATION .)
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ endif()

include(configure.cmake)

install_library_and_symbols (System.Security.Cryptography.Native.OpenSsl)
install_with_stripped_symbols (System.Security.Cryptography.Native.OpenSsl PROGRAMS .)
install (TARGETS System.Security.Cryptography.Native.OpenSsl-Static DESTINATION .)