diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index 358b885724507..a7b2c82de668d 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -4,6 +4,8 @@ project(corehost) include(../../../eng/native/configurepaths.cmake) include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake) +set(COREHOST_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + if (MSVC) # Host components don't try to handle asynchronous exceptions set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHsc) @@ -19,7 +21,70 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU) add_compile_options($<$:-fno-use-cxa-atexit>) endif() +set(CMAKE_INCLUDE_CURRENT_DIR ON) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CLR_ARTIFACTS_OBJ_DIR}) # Generated version files + +if (NOT ${CLR_SINGLE_FILE_HOST_ONLY}) + if("${CLI_CMAKE_PKG_RID}" STREQUAL "") + message(FATAL_ERROR "A minimum supported package rid is not specified (ex: win7-x86 or ubuntu.14.04-x64, osx.10.12-x64, rhel.7-x64)") + endif() + if("${CLI_CMAKE_COMMIT_HASH}" STREQUAL "") + message(FATAL_ERROR "Commit hash needs to be specified to build the host") + endif() +endif() + +if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "") + message(FATAL_ERROR "Fallback rid needs to be specified to build the host") +endif() + +if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "${CLR_CMAKE_TARGET_OS}") + add_compile_definitions(FALLBACK_OS_IS_SAME_AS_TARGET_OS) +endif() + +# Find support libraries that we need if they're present on the system. +find_library(PTHREAD_LIB pthread) + +# Prefer libatomic.a over libatomic.so. +set(_current_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) +list(PREPEND CMAKE_FIND_LIBRARY_SUFFIXES .a) +find_library(ATOMIC_SUPPORT_LIB atomic) +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_current_CMAKE_FIND_LIBRARY_SUFFIXES}) +unset(_current_CMAKE_FIND_LIBRARY_SUFFIXES) + +configure_file(configure.h.in ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + +# add_version_info_to_target(targetName [resourceDirName]) +function(add_version_info_to_target targetName) + set(RESOURCE_INCLUDE_DIR ${targetName}) + if (${ARGC} GREATER 1) + set(RESOURCE_INCLUDE_DIR ${ARGV1}) + endif() + + if (CLR_CMAKE_TARGET_WIN32) + target_sources(${targetName} PRIVATE ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/native.rc) + set_property(SOURCE ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/native.rc + TARGET_DIRECTORY ${targetName} + APPEND PROPERTY INCLUDE_DIRECTORIES + ${CLI_CMAKE_RESOURCE_DIR}/${RESOURCE_INCLUDE_DIR}) + else() + target_sources(${targetName} PRIVATE ${VERSION_FILE_PATH}) + endif() +endfunction() + +# This is required to map a symbol reference to a matching definition local to the module (.so) +# containing the reference instead of using definitions from other modules. +if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_SUNOS) + add_link_options(LINKER:-Bsymbolic) +endif() + +add_library(fxr_resolver INTERFACE) +target_sources(fxr_resolver INTERFACE fxr_resolver.cpp) +target_include_directories(fxr_resolver INTERFACE fxr) + add_subdirectory(hostcommon) +add_subdirectory(hostmisc) add_subdirectory(fxr) add_subdirectory(hostpolicy) diff --git a/src/native/corehost/apphost/standalone/CMakeLists.txt b/src/native/corehost/apphost/standalone/CMakeLists.txt index 8a6a23934d85d..2630aed0deca3 100644 --- a/src/native/corehost/apphost/standalone/CMakeLists.txt +++ b/src/native/corehost/apphost/standalone/CMakeLists.txt @@ -1,9 +1,6 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(apphost) -set(DOTNET_PROJECT_NAME "apphost") - # Add RPATH to the apphost binary that allows using local copies of shared libraries # dotnet core depends on for special scenarios when system wide installation of such # dependencies is not possible for some reason. @@ -14,13 +11,12 @@ if (NOT CLR_CMAKE_TARGET_OSX) set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps") endif() -set(SKIP_VERSIONING 1) - include_directories(..) set(SOURCES ../bundle_marker.cpp ./hostfxr_resolver.cpp + ../../corehost.cpp ) set(HEADERS @@ -29,7 +25,7 @@ set(HEADERS ) if(CLR_CMAKE_TARGET_WIN32) - add_definitions(-DUNICODE) + add_compile_definitions(UNICODE) list(APPEND SOURCES ../apphost.windows.cpp) @@ -37,20 +33,31 @@ if(CLR_CMAKE_TARGET_WIN32) ../apphost.windows.h) endif() -include(../../exe.cmake) +if(CLR_CMAKE_TARGET_WIN32) + list(APPEND SOURCES ${HEADERS}) +endif() + +add_compile_definitions(FEATURE_APPHOST) + +add_executable(apphost ${SOURCES} ${RESOURCES}) + +target_link_libraries(apphost PRIVATE hostmisc fxr_resolver) + +add_sanitizer_runtime_support(apphost) + +if(NOT CLR_CMAKE_TARGET_WIN32) + disable_pax_mprotect(apphost) +endif() -add_definitions(-DFEATURE_APPHOST=1) +install_with_stripped_symbols(apphost TARGETS corehost) # Disable manifest generation into the file .exe on Windows if(CLR_CMAKE_TARGET_WIN32) - set_property(TARGET ${PROJECT_NAME} PROPERTY - LINK_FLAGS "/MANIFEST:NO" - ) + target_link_options(apphost PRIVATE "/MANIFEST:NO") endif() -# Specify non-default Windows libs to be used for Arm64 builds -if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64) - target_link_libraries(apphost PRIVATE shell32.lib) +if (CLR_CMAKE_TARGET_WIN32) + target_link_libraries(apphost PRIVATE shell32) endif() if (CLR_CMAKE_HOST_APPLE) diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 7a14c7c92ed66..e431b87e33d0c 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -14,29 +14,35 @@ if (NOT CLR_CMAKE_TARGET_APPLE) set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps") endif() -set(SKIP_VERSIONING 1) - include_directories(..) +include_directories(../..) +include_directories(../../hostmisc) include_directories(../../json) include_directories(${CLR_SRC_NATIVE_DIR}/libs/System.IO.Compression.Native) include_directories(${CLR_SRC_NATIVE_DIR}/libs/Common) +include_directories(${CLR_ARTIFACTS_OBJ_DIR}) # Generated version files + +add_subdirectory(../../hostmisc hostmisc) + +configure_file(${CLR_SRC_NATIVE_DIR}/corehost/configure.h.in ${GENERATED_INCLUDE_DIR}/corehost/configure.h) +target_include_directories(hostmisc PUBLIC ${GENERATED_INCLUDE_DIR}/corehost) set(SOURCES ../bundle_marker.cpp ./hostfxr_resolver.cpp ./hostpolicy_resolver.cpp ../../hostpolicy/static/coreclr_resolver.cpp + ../../fxr_resolver.cpp + ../../corehost.cpp ) set(HEADERS ../bundle_marker.h ../../hostfxr_resolver.h + ../../fxr_resolver.h ) -add_definitions(-D_NO_ASYNCRTIMP) -add_definitions(-D_NO_PPLXIMP) -remove_definitions(-DEXPORT_SHARED_API) -add_definitions(-DNATIVE_LIBS_EMBEDDED) +add_compile_definitions(NATIVE_LIBS_EMBEDDED) include(../../fxr/files.cmake) include(../../hostpolicy/files.cmake) @@ -45,6 +51,7 @@ include(../../hostcommon/files.cmake) if(MSVC) # Host components don't try to handle asynchronous exceptions set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHsc) + set_property(TARGET hostmisc PROPERTY CLR_EH_OPTION /EHsc) elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU) # Prevents libc from calling pthread_cond_destroy on static objects in # dlopen()'ed library which we dlclose() in pal::unload_library. @@ -52,7 +59,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU) endif() if(CLR_CMAKE_TARGET_WIN32) - add_definitions(-DUNICODE) + add_compile_definitions(UNICODE) list(APPEND SOURCES ../apphost.windows.cpp ${CLR_SRC_NATIVE_DIR}/libs/Common/delayloadhook_windows.cpp @@ -78,11 +85,16 @@ else() set_exports_linker_option(${EXPORTS_FILE}) endif() -if (CLR_SINGLE_FILE_HOST_ONLY) - set(ADDITIONAL_INSTALL_ARGUMENTS COMPONENT runtime) +add_executable(singlefilehost ${SOURCES}) + +add_sanitizer_runtime_support(singlefilehost) + +if(NOT CLR_CMAKE_TARGET_WIN32) + disable_pax_mprotect(singlefilehost) endif() -include(../../exe.cmake) +install_with_stripped_symbols(singlefilehost TARGETS corehost COMPONENT runtime) + include(configure.cmake) if(CLR_CMAKE_HOST_UNIX) @@ -262,4 +274,6 @@ target_link_libraries( ${END_WHOLE_ARCHIVE} ) +target_link_libraries(singlefilehost PRIVATE hostmisc) + add_sanitizer_runtime_support(singlefilehost) diff --git a/src/native/corehost/comhost/CMakeLists.txt b/src/native/corehost/comhost/CMakeLists.txt index 9f777bff56997..0e7a045146bde 100644 --- a/src/native/corehost/comhost/CMakeLists.txt +++ b/src/native/corehost/comhost/CMakeLists.txt @@ -1,18 +1,12 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(comhost) - -set(DOTNET_PROJECT_NAME "comhost") - # Include directories -include_directories(../fxr) include_directories(../json) # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES comhost.cpp - ../fxr_resolver.cpp clsidmap.cpp ../redirected_error_writer.cpp ) @@ -26,9 +20,12 @@ if(CLR_CMAKE_TARGET_WIN32) Exports.def) endif() -include(../lib.cmake) +add_compile_definitions(FEATURE_LIBHOST) +add_compile_definitions(EXPORT_SHARED_API) + +add_library(comhost SHARED ${SOURCES}) -add_definitions(-DFEATURE_LIBHOST=1) +add_version_info_to_target(comhost) if (CLR_CMAKE_TARGET_WIN32) set(WINLIBS wintrust.lib) @@ -42,4 +39,4 @@ if (CLR_CMAKE_TARGET_WIN32) endif() install_with_stripped_symbols(comhost TARGETS corehost) -target_link_libraries(comhost PRIVATE libhostcommon) +target_link_libraries(comhost PRIVATE libhostcommon fxr_resolver) diff --git a/src/native/corehost/common.cmake b/src/native/corehost/common.cmake deleted file mode 100644 index 9a5e3a6686e07..0000000000000 --- a/src/native/corehost/common.cmake +++ /dev/null @@ -1,58 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(${DOTNET_PROJECT_NAME}) - -include(${CMAKE_CURRENT_LIST_DIR}/setup.cmake) - -# Include directories -if(CLR_CMAKE_TARGET_WIN32) - include_directories("${CLI_CMAKE_RESOURCE_DIR}/${DOTNET_PROJECT_NAME}") -endif() -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) -include_directories(${CMAKE_CURRENT_LIST_DIR}/) -include_directories(${CMAKE_CURRENT_LIST_DIR}/../) -include_directories(${CMAKE_CURRENT_LIST_DIR}/hostmisc) -include_directories(${CLR_ARTIFACTS_OBJ_DIR}) # Generated version files - -set(RESOURCES) -if (CLR_CMAKE_TARGET_WIN32) - if (NOT SKIP_VERSIONING) - list(APPEND RESOURCES ${CMAKE_CURRENT_LIST_DIR}/native.rc) - endif() -else() - list(APPEND SOURCES ${VERSION_FILE_PATH}) -endif() - -if(CLR_CMAKE_TARGET_WIN32) - list(APPEND SOURCES ${HEADERS}) -endif() - -# This is required to map a symbol reference to a matching definition local to the module (.so) -# containing the reference instead of using definitions from other modules. -if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_SUNOS) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic") -endif() - -function(set_common_libs TargetType) - - # Libraries used for exe projects - if (${TargetType} STREQUAL "exe") - if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID) - target_link_libraries (${DOTNET_PROJECT_NAME} PRIVATE "pthread") - endif() - endif() - - if (NOT ${TargetType} STREQUAL "lib-static") - # Specify the import library to link against for Arm32 build since the default set is minimal - if (CLR_CMAKE_TARGET_ARCH_ARM) - if (CLR_CMAKE_TARGET_WIN32) - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE shell32.lib advapi32.lib) - else() - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE atomic.a) - endif() - endif() - - target_link_libraries (${DOTNET_PROJECT_NAME} PRIVATE ${CMAKE_DL_LIBS}) - endif() -endfunction() diff --git a/src/native/corehost/configure.h.in b/src/native/corehost/configure.h.in new file mode 100644 index 0000000000000..4ddf2e6cfa7b0 --- /dev/null +++ b/src/native/corehost/configure.h.in @@ -0,0 +1,23 @@ +#ifndef PAL_HOST_CONFIGURE_H_INCLUDED +#define PAL_HOST_CONFIGURE_H_INCLUDED + +#cmakedefine01 CLR_SINGLE_FILE_HOST_ONLY + +#ifdef CLR_SINGLE_FILE_HOST_ONLY +// When hosting components are all statically linked, +// the versioning information is irrelevant and may only come up in tracing. +// so we will use "static" +#define HOST_POLICY_PKG_NAME "static" +#define HOST_POLICY_PKG_REL_DIR "static" +#define REPO_COMMIT_HASH "static" +#else +#define HOST_POLICY_PKG_NAME "runtime.@CLI_CMAKE_PKG_RID@.Microsoft.NETCore.DotNetHostPolicy" +#define HOST_POLICY_PKG_REL_DIR "runtime.@CLI_CMAKE_PKG_RID@/native" +#define REPO_COMMIT_HASH "@CLI_CMAKE_COMMIT_HASH@" +#endif + +#define FALLBACK_HOST_OS "@CLI_CMAKE_FALLBACK_OS@" +#define CURRENT_OS_NAME "@CLR_CMAKE_TARGET_OS@" +#define CURRENT_ARCH_NAME "@CLR_CMAKE_TARGET_ARCH@" + +#endif // PAL_HOST_CONFIGURE_H_INCLUDED \ No newline at end of file diff --git a/src/native/corehost/corehost.cpp b/src/native/corehost/corehost.cpp index 5edc2fbf5d521..902f8acace131 100644 --- a/src/native/corehost/corehost.cpp +++ b/src/native/corehost/corehost.cpp @@ -99,7 +99,10 @@ void need_newer_framework_error(const pal::string_t& dotnet_root, const pal::str int exe_start(const int argc, const pal::char_t* argv[]) { - pal::initialize_createdump(); +#if defined(FEATURE_STATIC_HOST) && (defined(TARGET_OSX) || defined(TARGET_LINUX)) && !defined(TARGET_X86) + extern void initialize_static_createdump(); + initialize_static_createdump(); +#endif pal::string_t host_path; if (!pal::get_own_executable_path(&host_path) || !pal::realpath(&host_path)) diff --git a/src/native/corehost/dotnet/CMakeLists.txt b/src/native/corehost/dotnet/CMakeLists.txt index d670b95e879c2..5704c911ac956 100644 --- a/src/native/corehost/dotnet/CMakeLists.txt +++ b/src/native/corehost/dotnet/CMakeLists.txt @@ -1,9 +1,6 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(dotnet) -set(DOTNET_PROJECT_NAME "dotnet") - if(CLR_CMAKE_TARGET_WIN32) list(APPEND SOURCES dotnet.manifest @@ -12,9 +9,21 @@ endif() list(APPEND SOURCES ../apphost/standalone/hostfxr_resolver.cpp + ../corehost.cpp ) -include(../exe.cmake) +add_executable(dotnet ${SOURCES}) + +target_link_libraries(dotnet PRIVATE hostmisc fxr_resolver) + +add_sanitizer_runtime_support(dotnet) + +if(NOT CLR_CMAKE_TARGET_WIN32) + disable_pax_mprotect(dotnet) +endif() + +install_with_stripped_symbols(dotnet TARGETS corehost) +add_version_info_to_target(dotnet) if (CLR_CMAKE_HOST_APPLE) adhoc_sign_with_entitlements(dotnet "${CLR_ENG_NATIVE_DIR}/entitlements.plist") diff --git a/src/native/corehost/exe.cmake b/src/native/corehost/exe.cmake deleted file mode 100644 index e4975923f1f23..0000000000000 --- a/src/native/corehost/exe.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project (${DOTNET_PROJECT_NAME}) - -include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/hostmisc/hostmisc.cmake) - -# Include directories -include_directories(${CMAKE_CURRENT_LIST_DIR}/fxr) - -# CMake does not recommend using globbing since it messes with the freshness checks -list(APPEND SOURCES - ${CMAKE_CURRENT_LIST_DIR}/fxr_resolver.cpp - ${CMAKE_CURRENT_LIST_DIR}/corehost.cpp -) -list(APPEND HEADERS - ${CMAKE_CURRENT_LIST_DIR}/hostfxr_resolver.h -) - -add_executable(${DOTNET_PROJECT_NAME} ${SOURCES} ${RESOURCES}) - -add_sanitizer_runtime_support(${DOTNET_PROJECT_NAME}) - -if(NOT CLR_CMAKE_TARGET_WIN32) - disable_pax_mprotect(${DOTNET_PROJECT_NAME}) -endif() - -install_with_stripped_symbols(${DOTNET_PROJECT_NAME} TARGETS corehost ${ADDITIONAL_INSTALL_ARGUMENTS}) - -set_common_libs("exe") diff --git a/src/native/corehost/fxr/standalone/CMakeLists.txt b/src/native/corehost/fxr/standalone/CMakeLists.txt index a809a653cce18..ceb0f9f417536 100644 --- a/src/native/corehost/fxr/standalone/CMakeLists.txt +++ b/src/native/corehost/fxr/standalone/CMakeLists.txt @@ -27,7 +27,11 @@ else(CLR_CMAKE_TARGET_WIN32) set_exports_linker_option(${EXPORTS_FILE}) endif(CLR_CMAKE_TARGET_WIN32) -include(../../lib.cmake) +add_compile_definitions(EXPORT_SHARED_API) + +add_library(hostfxr SHARED ${SOURCES}) + +add_version_info_to_target(hostfxr) if(CLR_CMAKE_HOST_UNIX) add_custom_target(hostfxr_exports DEPENDS ${EXPORTS_FILE}) @@ -41,6 +45,7 @@ install_with_stripped_symbols(hostfxr TARGETS corehost) target_link_libraries(hostfxr PRIVATE libhostcommon) -if (CLR_CMAKE_TARGET_ARCH_ARMV6) - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE atomic) +if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6) + target_link_libraries(hostfxr PRIVATE + $<$:${ATOMIC_SUPPORT_LIB}>) endif() diff --git a/src/native/corehost/fxr/staticlib/CMakeLists.txt b/src/native/corehost/fxr/staticlib/CMakeLists.txt index 6ff3bc27f74c1..9ab84349d1adc 100644 --- a/src/native/corehost/fxr/staticlib/CMakeLists.txt +++ b/src/native/corehost/fxr/staticlib/CMakeLists.txt @@ -14,17 +14,24 @@ set(HEADERS ../hostpolicy_resolver.h ) +add_compile_definitions( + EXPORT_SHARED_API) + include(../../hostcommon/files.cmake) include(../files.cmake) -include(../../hostmisc/hostmisc.cmake) -include(../../lib_static.cmake) +add_library(libhostfxr STATIC ${SOURCES}) + +add_version_info_to_target(libhostfxr hostfxr) + +set_target_properties(libhostfxr PROPERTIES MACOSX_RPATH TRUE) +set_target_properties(libhostfxr PROPERTIES PREFIX "") # Copy static lib PDB to the project output directory if (WIN32) set_target_properties(libhostfxr PROPERTIES COMPILE_PDB_NAME "libhostfxr" - COMPILE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + COMPILE_PDB_OUTPUT_DIRECTORY "$" ) endif(WIN32) @@ -44,3 +51,5 @@ if (WIN32) else() install(TARGETS libhostfxr DESTINATION corehost) endif(WIN32) + +target_link_libraries(libhostfxr PRIVATE hostmisc) diff --git a/src/native/corehost/hostcommon/CMakeLists.txt b/src/native/corehost/hostcommon/CMakeLists.txt index 36b9d140cb95c..2d59348cad29c 100644 --- a/src/native/corehost/hostcommon/CMakeLists.txt +++ b/src/native/corehost/hostcommon/CMakeLists.txt @@ -1,12 +1,19 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(hostcommon) +include(files.cmake) -set(DOTNET_PROJECT_NAME "hostcommon") +add_library(libhostcommon STATIC ${SOURCES}) -include(files.cmake) +target_compile_definitions(libhostcommon PRIVATE EXPORT_SHARED_API) +set_target_properties(libhostcommon PROPERTIES MACOSX_RPATH TRUE) + +if (NOT CLR_CMAKE_TARGET_WIN32) + target_sources(libhostcommon PRIVATE ${VERSION_FILE_PATH}) +endif() -set(SKIP_VERSIONING 1) -include(../lib_static.cmake) +if (MSVC) + target_sources(libhostcommon PRIVATE ${HEADERS}) +endif() +target_link_libraries(libhostcommon PUBLIC hostmisc) diff --git a/src/native/corehost/hostcommon/files.cmake b/src/native/corehost/hostcommon/files.cmake index 43bd124b9b592..9b23d326f4657 100644 --- a/src/native/corehost/hostcommon/files.cmake +++ b/src/native/corehost/hostcommon/files.cmake @@ -11,7 +11,6 @@ list(APPEND SOURCES ${CMAKE_CURRENT_LIST_DIR}/../roll_forward_option.cpp ${CMAKE_CURRENT_LIST_DIR}/../fx_definition.cpp ${CMAKE_CURRENT_LIST_DIR}/../fx_reference.cpp - ${CMAKE_CURRENT_LIST_DIR}/../fxr/fx_ver.cpp ${CMAKE_CURRENT_LIST_DIR}/../version_compatibility_range.cpp ${CMAKE_CURRENT_LIST_DIR}/../runtime_config.cpp ${CMAKE_CURRENT_LIST_DIR}/../bundle/info.cpp diff --git a/src/native/corehost/hostmisc/hostmisc.cmake b/src/native/corehost/hostmisc/CMakeLists.txt similarity index 53% rename from src/native/corehost/hostmisc/hostmisc.cmake rename to src/native/corehost/hostmisc/CMakeLists.txt index 83233a9572ff4..f39b586590c62 100644 --- a/src/native/corehost/hostmisc/hostmisc.cmake +++ b/src/native/corehost/hostmisc/CMakeLists.txt @@ -1,18 +1,16 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -include(${CMAKE_CURRENT_LIST_DIR}/configure.cmake) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) -include_directories("${CLR_SRC_NATIVE_DIR}") +include(configure.cmake) # CMake does not recommend using globbing since it messes with the freshness checks -list(APPEND SOURCES +set(SOURCES ${CMAKE_CURRENT_LIST_DIR}/trace.cpp ${CMAKE_CURRENT_LIST_DIR}/utils.cpp ${CMAKE_CURRENT_LIST_DIR}/../fxr/fx_ver.cpp ) -list(APPEND HEADERS +set(HEADERS ${CMAKE_CURRENT_LIST_DIR}/trace.h ${CMAKE_CURRENT_LIST_DIR}/utils.h ${CMAKE_CURRENT_LIST_DIR}/pal.h @@ -30,3 +28,26 @@ else() list(APPEND SOURCES ${CMAKE_CURRENT_LIST_DIR}/pal.unix.cpp) endif() + +# hostmisc must be an "object library" as we want to build it once +# and embed the objects into static libraries we ship (like libnethost). +add_library(hostmisc OBJECT ${SOURCES}) + +target_include_directories(hostmisc PUBLIC + ${CMAKE_CURRENT_BINARY_DIR} + ${CLR_SRC_NATIVE_DIR} + ${CMAKE_CURRENT_LIST_DIR}) + +if (MSVC) + target_sources(hostmisc PRIVATE ${HEADERS}) + target_link_libraries(hostmisc PUBLIC advapi32) +endif() + +target_link_libraries(hostmisc PUBLIC + ${CMAKE_DL_LIBS} + $<$:${PTHREAD_LIB}>) + +if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6) + target_link_libraries(hostmisc PUBLIC + $<$:${ATOMIC_SUPPORT_LIB}>) +endif() diff --git a/src/native/corehost/hostmisc/pal.h b/src/native/corehost/hostmisc/pal.h index f482b6df63456..8aea41a2f07b4 100644 --- a/src/native/corehost/hostmisc/pal.h +++ b/src/native/corehost/hostmisc/pal.h @@ -58,6 +58,8 @@ #endif +#include "configure.h" + // When running on a platform that is not supported in RID fallback graph (because it was unknown // at the time the SharedFX in question was built), we need to use a reasonable fallback RID to allow // consuming the native assets. @@ -346,8 +348,6 @@ namespace pal bool is_emulating_x64(); bool are_paths_equal_with_normalized_casing(const string_t& path1, const string_t& path2); - - void initialize_createdump(); } #endif // PAL_H diff --git a/src/native/corehost/hostmisc/pal.unix.cpp b/src/native/corehost/hostmisc/pal.unix.cpp index bdd8796c5d8e0..b690b1f100ae8 100644 --- a/src/native/corehost/hostmisc/pal.unix.cpp +++ b/src/native/corehost/hostmisc/pal.unix.cpp @@ -1121,14 +1121,3 @@ bool pal::are_paths_equal_with_normalized_casing(const string_t& path1, const st return path1 == path2; #endif } - -#if defined(FEATURE_STATIC_HOST) && (defined(TARGET_OSX) || defined(TARGET_LINUX)) && !defined(TARGET_X86) -extern void initialize_static_createdump(); -#endif - -void pal::initialize_createdump() -{ -#if defined(FEATURE_STATIC_HOST) && (defined(TARGET_OSX) || defined(TARGET_LINUX)) && !defined(TARGET_X86) - initialize_static_createdump(); -#endif -} diff --git a/src/native/corehost/hostmisc/pal.windows.cpp b/src/native/corehost/hostmisc/pal.windows.cpp index b11610492d321..966725dc93880 100644 --- a/src/native/corehost/hostmisc/pal.windows.cpp +++ b/src/native/corehost/hostmisc/pal.windows.cpp @@ -941,7 +941,3 @@ void pal::mutex_t::unlock() { ::LeaveCriticalSection(&_impl); } - -void pal::initialize_createdump() -{ -} diff --git a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt index f977c733d9968..31f4f8e8e3815 100644 --- a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt +++ b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt @@ -1,10 +1,6 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(hostpolicy) - -set(DOTNET_PROJECT_NAME "hostpolicy") - set(SOURCES ./coreclr_resolver.cpp ) @@ -22,7 +18,10 @@ else(CLR_CMAKE_TARGET_WIN32) set_exports_linker_option(${EXPORTS_FILE}) endif(CLR_CMAKE_TARGET_WIN32) -include(../../lib.cmake) +add_compile_definitions(EXPORT_SHARED_API) + +add_library(hostpolicy SHARED ${SOURCES}) +add_version_info_to_target(hostpolicy) if(CLR_CMAKE_HOST_UNIX) add_custom_target(hostpolicy_exports DEPENDS ${EXPORTS_FILE}) @@ -35,6 +34,7 @@ endif(CLR_CMAKE_HOST_UNIX) install_with_stripped_symbols(hostpolicy TARGETS corehost) target_link_libraries(hostpolicy PRIVATE libhostcommon) -if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID) - target_link_libraries (hostpolicy PRIVATE pthread) -endif() +if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6) + target_link_libraries(hostpolicy INTERFACE + $<$:${ATOMIC_SUPPORT_LIB}>) +endif() \ No newline at end of file diff --git a/src/native/corehost/ijwhost/CMakeLists.txt b/src/native/corehost/ijwhost/CMakeLists.txt index 1661f162974d5..5e5218e578f3f 100644 --- a/src/native/corehost/ijwhost/CMakeLists.txt +++ b/src/native/corehost/ijwhost/CMakeLists.txt @@ -1,19 +1,13 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(ijwhost) - -set(DOTNET_PROJECT_NAME "ijwhost") - # Include directories -include_directories(../fxr) include_directories(${ARCH_SOURCES_DIR}) # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES ijwthunk.cpp ijwhost.cpp - ../fxr_resolver.cpp pedecoder.cpp bootstrap_thunk_chunk.cpp ${ARCH_SOURCES_DIR}/bootstrap_thunk.cpp @@ -27,11 +21,10 @@ endif() set (ASM_HELPERS_SOURCES ${ARCH_SOURCES_DIR}/asmhelpers.asm) -add_definitions(-DFEATURE_LIBHOST=1) - -convert_to_absolute_path(SOURCES ${SOURCES}) convert_to_absolute_path(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES}) +add_compile_definitions(FEATURE_LIBHOST) + if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64) preprocess_files(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES}) if (CMAKE_GENERATOR MATCHES "Visual Studio") @@ -45,11 +38,16 @@ endif () list(APPEND SOURCES ${ASM_HELPERS_SOURCES}) -include(../lib.cmake) +add_compile_definitions(EXPORT_SHARED_API) + +add_library(ijwhost SHARED ${SOURCES} ${RESOURCES}) +add_version_info_to_target(ijwhost) + +target_link_libraries(ijwhost PRIVATE hostmisc fxr_resolver) # Specify non-default Windows libs to be used for Arm64 builds if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64) - target_link_libraries(ijwhost PRIVATE Ole32.lib) + target_link_libraries(ijwhost PRIVATE ole32) endif() install_with_stripped_symbols(ijwhost TARGETS corehost) diff --git a/src/native/corehost/lib.cmake b/src/native/corehost/lib.cmake deleted file mode 100644 index e61eb0a2b3900..0000000000000 --- a/src/native/corehost/lib.cmake +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(${DOTNET_PROJECT_NAME}) - -include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/hostmisc/hostmisc.cmake) - -add_definitions(-D_NO_ASYNCRTIMP) -add_definitions(-D_NO_PPLXIMP) -add_definitions(-DEXPORT_SHARED_API=1) - -add_library(${DOTNET_PROJECT_NAME} SHARED ${SOURCES} ${RESOURCES}) - -set_target_properties(${DOTNET_PROJECT_NAME} PROPERTIES MACOSX_RPATH TRUE) - -set_common_libs("lib") diff --git a/src/native/corehost/lib_static.cmake b/src/native/corehost/lib_static.cmake deleted file mode 100644 index b6d8744e94e0e..0000000000000 --- a/src/native/corehost/lib_static.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(lib${DOTNET_PROJECT_NAME}) - -include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) - -add_definitions(-D_NO_ASYNCRTIMP) -add_definitions(-D_NO_PPLXIMP) -add_definitions(-DEXPORT_SHARED_API=1) - -if (BUILD_OBJECT_LIBRARY) - add_library(lib${DOTNET_PROJECT_NAME} OBJECT ${SOURCES} ${RESOURCES}) -else () - add_library(lib${DOTNET_PROJECT_NAME} STATIC ${SOURCES} ${RESOURCES}) -endif () - -set_target_properties(lib${DOTNET_PROJECT_NAME} PROPERTIES MACOSX_RPATH TRUE) -set_target_properties(lib${DOTNET_PROJECT_NAME} PROPERTIES PREFIX "") - -set_common_libs("lib-static") diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt index 818ed9ced7fce..38b103b7178be 100644 --- a/src/native/corehost/nethost/CMakeLists.txt +++ b/src/native/corehost/nethost/CMakeLists.txt @@ -1,17 +1,9 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(nethost) - -set(DOTNET_PROJECT_NAME "nethost") - -# Include directories -include_directories(../fxr) - # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES nethost.cpp - ../fxr_resolver.cpp ) if(CLR_CMAKE_TARGET_WIN32) @@ -19,20 +11,40 @@ if(CLR_CMAKE_TARGET_WIN32) Exports.def) endif() -include(../lib.cmake) -include(../lib_static.cmake) +add_compile_definitions( + EXPORT_SHARED_API + FEATURE_LIBHOST + NETHOST_EXPORT) + +add_library(nethost SHARED ${SOURCES}) +add_library(libnethost STATIC ${SOURCES}) -add_definitions(-DFEATURE_LIBHOST=1) -add_definitions(-DNETHOST_EXPORT) +add_version_info_to_target(nethost) +add_version_info_to_target(libnethost nethost) + +target_include_directories(nethost PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(libnethost PUBLIC $) # Copy static lib PDB to the project output directory if (WIN32) set_target_properties(libnethost PROPERTIES COMPILE_PDB_NAME "libnethost" - COMPILE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + COMPILE_PDB_OUTPUT_DIRECTORY "$" ) endif(WIN32) +target_link_libraries(nethost PRIVATE hostmisc fxr_resolver) +target_link_libraries(libnethost PRIVATE hostmisc fxr_resolver) +target_compile_definitions(nethost PRIVATE FEATURE_LIBHOST NETHOST_EXPORT) +target_compile_definitions(libnethost PRIVATE FEATURE_LIBHOST NETHOST_EXPORT) + +set_target_properties(nethost PROPERTIES MACOSX_RPATH TRUE) +set_target_properties(libnethost PROPERTIES MACOSX_RPATH TRUE) +set_target_properties(libnethost PROPERTIES PREFIX "") + +target_link_libraries (nethost PRIVATE ${CMAKE_DL_LIBS}) +target_link_libraries (libnethost PUBLIC ${CMAKE_DL_LIBS}) + install(FILES ../coreclr_delegates.h DESTINATION corehost) install(FILES ../hostfxr.h DESTINATION corehost) install(FILES nethost.h DESTINATION corehost) diff --git a/src/native/corehost/setup.cmake b/src/native/corehost/setup.cmake deleted file mode 100644 index 787d2ca775d3c..0000000000000 --- a/src/native/corehost/setup.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -if(CLR_SINGLE_FILE_HOST_ONLY) - # CLR partition builds only the single file host where hosting components are all statically linked. - # the versioning information is irrelevant and may only come up in tracing. - # so we will use "static" - add_definitions(-DHOST_POLICY_PKG_NAME="static") - add_definitions(-DHOST_POLICY_PKG_REL_DIR="static") - add_definitions(-DREPO_COMMIT_HASH="static") -else() - if("${CLI_CMAKE_PKG_RID}" STREQUAL "") - message(FATAL_ERROR "A minimum supported package rid is not specified (ex: win7-x86 or ubuntu.14.04-x64, osx.10.12-x64, rhel.7-x64)") - else() - add_definitions(-DHOST_POLICY_PKG_NAME="runtime.${CLI_CMAKE_PKG_RID}.Microsoft.NETCore.DotNetHostPolicy") - add_definitions(-DHOST_POLICY_PKG_REL_DIR="runtimes/${CLI_CMAKE_PKG_RID}/native") - endif() - - if("${CLI_CMAKE_COMMIT_HASH}" STREQUAL "") - message(FATAL_ERROR "Commit hash needs to be specified to build the host") - else() - add_definitions(-DREPO_COMMIT_HASH="${CLI_CMAKE_COMMIT_HASH}") - endif() -endif() - -if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "") - message(FATAL_ERROR "Fallback rid needs to be specified to build the host") -else() - add_definitions(-DFALLBACK_HOST_OS="${CLI_CMAKE_FALLBACK_OS}") -endif() - -add_definitions(-DCURRENT_OS_NAME="${CLR_CMAKE_TARGET_OS}") -add_definitions(-DCURRENT_ARCH_NAME="${CLR_CMAKE_TARGET_ARCH}") -if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "${CLR_CMAKE_TARGET_OS}") - add_definitions(-DFALLBACK_OS_IS_SAME_AS_TARGET_OS) -endif() diff --git a/src/native/corehost/test/CMakeLists.txt b/src/native/corehost/test/CMakeLists.txt index fac7e76baf6a7..4310a0e8449b3 100644 --- a/src/native/corehost/test/CMakeLists.txt +++ b/src/native/corehost/test/CMakeLists.txt @@ -1,7 +1,6 @@ add_subdirectory(fx_ver) add_subdirectory(mockcoreclr) -add_subdirectory(mockhostfxr/2_2) -add_subdirectory(mockhostfxr/5_0) +add_subdirectory(mockhostfxr) add_subdirectory(mockhostpolicy) add_subdirectory(nativehost) if (NOT RUNTIME_FLAVOR STREQUAL Mono) diff --git a/src/native/corehost/test/comsxs/CMakeLists.txt b/src/native/corehost/test/comsxs/CMakeLists.txt index 673e7f07bdde0..144937e9f8152 100644 --- a/src/native/corehost/test/comsxs/CMakeLists.txt +++ b/src/native/corehost/test/comsxs/CMakeLists.txt @@ -1,18 +1,12 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(comsxs) +add_executable(comsxs + comsxs.cpp + App.manifest) -set(DOTNET_PROJECT_NAME "comsxs") +add_sanitizer_runtime_support(comsxs) -set(SOURCES - ./comsxs.cpp - ./App.manifest -) - - -include(../testexe.cmake) - -target_link_libraries(comsxs PRIVATE ole32 oleaut32) +target_link_libraries(comsxs PRIVATE hostmisc ole32 oleaut32 shell32 advapi32) install_with_stripped_symbols(comsxs TARGETS corehost_test) diff --git a/src/native/corehost/test/fx_ver/CMakeLists.txt b/src/native/corehost/test/fx_ver/CMakeLists.txt index ed39b965966c6..a6bb1421dc7ca 100644 --- a/src/native/corehost/test/fx_ver/CMakeLists.txt +++ b/src/native/corehost/test/fx_ver/CMakeLists.txt @@ -1,18 +1,11 @@ # Copyright (c) .NET Foundation and contributors. All rights reserved. # Licensed under the MIT license. See LICENSE file in the project root for full license information. - -project(test_fx_ver) - -set(DOTNET_PROJECT_NAME "test_fx_ver") - include_directories(../../fxr) -set(SOURCES - test_fx_ver.cpp -) +add_executable(test_fx_ver test_fx_ver.cpp) -include(${CMAKE_CURRENT_LIST_DIR}/../../hostmisc/hostmisc.cmake) +add_sanitizer_runtime_support(test_fx_ver) -include(../testexe.cmake) +target_link_libraries(test_fx_ver PRIVATE libhostcommon hostmisc) -target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE libhostcommon) +install_with_stripped_symbols(test_fx_ver TARGETS corehost_test) diff --git a/src/native/corehost/test/ijw/CMakeLists.txt b/src/native/corehost/test/ijw/CMakeLists.txt index 9e90cfdcf069a..9fbd72412d4c8 100644 --- a/src/native/corehost/test/ijw/CMakeLists.txt +++ b/src/native/corehost/test/ijw/CMakeLists.txt @@ -1,15 +1,10 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(ijw) - -set(SOURCES - ./ijw.cpp) - include(${CLR_ENG_NATIVE_DIR}/ijw/IJW.cmake) -add_library(ijw SHARED ${SOURCES}) -target_link_libraries(ijw PRIVATE ${LINK_LIBRARIES_ADDITIONAL}) +add_library(ijw SHARED ijw.cpp) +target_link_libraries(ijw PRIVATE ijwhost) remove_ijw_incompatible_target_options(ijw) add_ijw_msbuild_project_properties(ijw ijwhost) diff --git a/src/native/corehost/test/mockcoreclr/CMakeLists.txt b/src/native/corehost/test/mockcoreclr/CMakeLists.txt index f7e202fbc1dff..5d809d84b5d56 100644 --- a/src/native/corehost/test/mockcoreclr/CMakeLists.txt +++ b/src/native/corehost/test/mockcoreclr/CMakeLists.txt @@ -1,19 +1,15 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(mockcoreclr) - -set(DOTNET_PROJECT_NAME "mockcoreclr") - -set(SOURCES - ./mockcoreclr.cpp -) +add_library(mockcoreclr SHARED mockcoreclr.cpp) if(CLR_CMAKE_TARGET_WIN32) - list(APPEND SOURCES + target_sources(mockcoreclr PRIVATE mockcoreclr.def) endif() -include(../testlib.cmake) +target_link_libraries(mockcoreclr PRIVATE hostmisc) + +target_compile_definitions(mockcoreclr PRIVATE EXPORT_SHARED_API) install_with_stripped_symbols(mockcoreclr TARGETS corehost_test) diff --git a/src/native/corehost/test/mockhostfxr/2_2/CMakeLists.txt b/src/native/corehost/test/mockhostfxr/2_2/CMakeLists.txt deleted file mode 100644 index 096c3631afbc8..0000000000000 --- a/src/native/corehost/test/mockhostfxr/2_2/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(mockhostfxr_2_2) - -set(DOTNET_PROJECT_NAME "mockhostfxr_2_2") - -add_definitions(-D_MOCKHOSTFXR_2_2) - -set(SOURCES - ./../mockhostfxr.cpp -) - -include(../../testlib.cmake) - -install_with_stripped_symbols(mockhostfxr_2_2 TARGETS corehost_test) diff --git a/src/native/corehost/test/mockhostfxr/5_0/CMakeLists.txt b/src/native/corehost/test/mockhostfxr/5_0/CMakeLists.txt deleted file mode 100644 index 5f9f36c71852a..0000000000000 --- a/src/native/corehost/test/mockhostfxr/5_0/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(mockhostfxr_5_0) - -set(DOTNET_PROJECT_NAME "mockhostfxr_5_0") - -add_definitions(-DMOCKHOSTFXR_5_0) - -set(SOURCES - ./../mockhostfxr.cpp -) - -include(../../testlib.cmake) - -install_with_stripped_symbols(mockhostfxr_5_0 TARGETS corehost_test) diff --git a/src/native/corehost/test/mockhostfxr/CMakeLists.txt b/src/native/corehost/test/mockhostfxr/CMakeLists.txt new file mode 100644 index 0000000000000..6820b27d84715 --- /dev/null +++ b/src/native/corehost/test/mockhostfxr/CMakeLists.txt @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. + +add_library(mockhostfxr_2_2 SHARED mockhostfxr.cpp) +add_library(mockhostfxr_5_0 SHARED mockhostfxr.cpp) + +target_link_libraries(mockhostfxr_2_2 PRIVATE libhostcommon) +target_link_libraries(mockhostfxr_5_0 PRIVATE libhostcommon) + +target_compile_definitions(mockhostfxr_2_2 PRIVATE MOCKHOSTFXR_2_2 EXPORT_SHARED_API) +target_compile_definitions(mockhostfxr_5_0 PRIVATE MOCKHOSTFXR_5_0 EXPORT_SHARED_API) + +install_with_stripped_symbols(mockhostfxr_2_2 TARGETS corehost_test) +install_with_stripped_symbols(mockhostfxr_5_0 TARGETS corehost_test) \ No newline at end of file diff --git a/src/native/corehost/test/mockhostpolicy/CMakeLists.txt b/src/native/corehost/test/mockhostpolicy/CMakeLists.txt index 146cf010e3fa6..d89c06d8d563d 100644 --- a/src/native/corehost/test/mockhostpolicy/CMakeLists.txt +++ b/src/native/corehost/test/mockhostpolicy/CMakeLists.txt @@ -1,14 +1,10 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(mockhostpolicy) +add_library(mockhostpolicy SHARED mockhostpolicy.cpp) -set(DOTNET_PROJECT_NAME "mockhostpolicy") +target_link_libraries(mockhostpolicy PRIVATE hostmisc) -set(SOURCES - ./mockhostpolicy.cpp -) - -include(../testlib.cmake) +target_compile_definitions(mockhostpolicy PRIVATE EXPORT_SHARED_API) install_with_stripped_symbols(mockhostpolicy TARGETS corehost_test) \ No newline at end of file diff --git a/src/native/corehost/test/nativehost/CMakeLists.txt b/src/native/corehost/test/nativehost/CMakeLists.txt index 527ab578d3991..a3c9ed9fa24a3 100644 --- a/src/native/corehost/test/nativehost/CMakeLists.txt +++ b/src/native/corehost/test/nativehost/CMakeLists.txt @@ -3,8 +3,6 @@ project(nativehost) -set(DOTNET_PROJECT_NAME "nativehost") - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(MACOSX_RPATH ON) if (CLR_CMAKE_TARGET_OSX) @@ -13,8 +11,6 @@ else() set(CMAKE_INSTALL_RPATH "\$ORIGIN") endif() -include_directories(${CMAKE_CURRENT_LIST_DIR}/../../nethost) - set(SOURCES ./error_writer_redirector.cpp ./get_native_search_directories_test.cpp @@ -40,25 +36,22 @@ if(CLR_CMAKE_TARGET_WIN32) list(APPEND HEADERS ./comhost_test.h) - - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nethost.dll") endif() -include(../../hostmisc/hostmisc.cmake) +add_executable(nativehost ${SOURCES}) -include(../testexe.cmake) +add_sanitizer_runtime_support(nativehost) -target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE nethost) +install_with_stripped_symbols(nativehost TARGETS corehost_test) -if (CLR_CMAKE_TARGET_WIN32) - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE delayimp.lib) -endif() +target_link_libraries(nativehost PRIVATE + $<$:${PTHREAD_LIB}>) -# Specify non-default Windows libs to be used for Arm/Arm64 builds -if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)) - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE Ole32.lib OleAut32.lib) -endif() -if (CLR_CMAKE_TARGET_ARCH_ARMV6) - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE atomic) +target_link_libraries(nativehost PRIVATE nethost hostmisc) + +if (CLR_CMAKE_TARGET_WIN32) + target_link_options(nativehost PRIVATE /DELAYLOAD:$) + target_link_libraries(nativehost PRIVATE delayimp.lib ole32 oleaut32) endif() + diff --git a/src/native/corehost/test/testexe.cmake b/src/native/corehost/test/testexe.cmake deleted file mode 100644 index 75538c7090a67..0000000000000 --- a/src/native/corehost/test/testexe.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(${DOTNET_PROJECT_NAME}) - -set(SKIP_VERSIONING 1) - -include(${CMAKE_CURRENT_LIST_DIR}/../common.cmake) - -add_executable(${DOTNET_PROJECT_NAME} ${SOURCES}) - -add_sanitizer_runtime_support(${DOTNET_PROJECT_NAME}) - -install_with_stripped_symbols(${DOTNET_PROJECT_NAME} TARGETS corehost_test) - -set_common_libs("exe") diff --git a/src/native/corehost/test/testlib.cmake b/src/native/corehost/test/testlib.cmake deleted file mode 100644 index 6031136fb9750..0000000000000 --- a/src/native/corehost/test/testlib.cmake +++ /dev/null @@ -1,8 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(${DOTNET_PROJECT_NAME}) - -set(SKIP_VERSIONING 1) - -include(${CMAKE_CURRENT_LIST_DIR}/../lib.cmake)