diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt index a9f44e720..0f24d4458 100644 --- a/src/native/corehost/nethost/CMakeLists.txt +++ b/src/native/corehost/nethost/CMakeLists.txt @@ -1,11 +1,14 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. +cmake_minimum_required (VERSION 3.14.5) project(nethost) set(DOTNET_PROJECT_NAME "nethost") # Include directories +include(../../../../eng/native/configurepaths.cmake) +include("${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake") include_directories(../fxr) # CMake does not recommend using globbing since it messes with the freshness checks @@ -19,12 +22,23 @@ if(CLR_CMAKE_TARGET_WIN32) Exports.def) endif() +if(BUILD_SHARED_LIBS) include(../lib.cmake) +set(targets nethost) +else() +include(../hostmisc/hostmisc.cmake) include(../lib_static.cmake) +add_library(nethost INTERFACE) +target_link_libraries(nethost INTERFACE libnethost) +set(targets libnethost nethost) +target_include_directories(libnethost INTERFACE $) +endif() +target_include_directories(nethost INTERFACE $) add_definitions(-DFEATURE_LIBHOST=1) add_definitions(-DNETHOST_EXPORT) +if(NOT BUILD_SHARED_LIBS) # Copy static lib PDB to the project output directory if (WIN32) set_target_properties(libnethost PROPERTIES @@ -32,15 +46,18 @@ if (WIN32) COMPILE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" ) endif(WIN32) +endif() -install(FILES ../coreclr_delegates.h DESTINATION corehost) -install(FILES ../hostfxr.h DESTINATION corehost) -install(FILES nethost.h DESTINATION corehost) -install_with_stripped_symbols(nethost TARGETS corehost) +set(NETHOST_HEADERS nethost.h ../coreclr_delegates.h ../hostfxr.h) +install(FILES ${NETHOST_HEADERS} DESTINATION include) +install(TARGETS ${targets} EXPORT unofficial-nethost-config + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) -# Only Windows creates a symbols file for static libs. -if (WIN32) - install_with_stripped_symbols(libnethost TARGETS corehost) -else() - install(TARGETS libnethost DESTINATION corehost) -endif(WIN32) \ No newline at end of file +install(EXPORT unofficial-nethost-config + DESTINATION share/unofficial-nethost + FILE unofficial-nethost-config.cmake + NAMESPACE unofficial::nethost:: +)