diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index b976f5fdc6cf1..e5bec2b3b8ceb 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -48,11 +48,6 @@ check_prereqs() { echo "Checking prerequisites..." - if ! cmake --help 2>&1 | grep -q \\-B; then - echo "Please install cmake v3.14.5 or newer from https://www.cmake.org/download/." - exit 1 - fi - if [[ "$__HostOS" == "OSX" ]]; then # Check presence of pkg-config on the path command -v pkg-config 2>/dev/null || { echo >&2 "Please install pkg-config before running this script, see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/macos-requirements.md"; exit 1; } @@ -177,8 +172,8 @@ EOF cmake_command="emcmake $cmake_command" fi - echo "Executing $cmake_command --build \"$intermediatesDir\" --target install -j $__NumProc" - $cmake_command --build "$intermediatesDir" --target install -j "$__NumProc" + echo "Executing $cmake_command --build \"$intermediatesDir\" --target install -- -j $__NumProc" + $cmake_command --build "$intermediatesDir" --target install -- -j "$__NumProc" fi local exit_code="$?" diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 9d1b88f080113..b8eed677264ce 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -8,8 +8,6 @@ set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -cmake_policy(SET CMP0083 NEW) - include(CheckCXXCompilerFlag) # "configureoptimization.cmake" must be included after CLR_CMAKE_HOST_UNIX has been set. @@ -40,11 +38,18 @@ set(CMAKE_CXX_FLAGS_CHECKED "") set(CMAKE_EXE_LINKER_FLAGS_CHECKED "") set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") +set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "") +set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "") +set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") +set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "") + add_compile_definitions("$<$,$>:DEBUG;_DEBUG;_DBG;URTBLDENV_FRIENDLY=Checked;BUILDENV_CHECKED=1>") add_compile_definitions("$<$,$>:NDEBUG;URTBLDENV_FRIENDLY=Retail>") if (MSVC) - add_link_options(/GUARD:CF) + add_linker_flag(/GUARD:CF) # Linker flags # @@ -57,48 +62,51 @@ if (MSVC) endif () #Do not create Side-by-Side Assembly Manifest - add_link_options($<$,SHARED_LIBRARY>:/MANIFEST:NO>) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") # can handle addresses larger than 2 gigabytes - add_link_options($<$,SHARED_LIBRARY>:/LARGEADDRESSAWARE>) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE") #Compatible with Data Execution Prevention - add_link_options($<$,SHARED_LIBRARY>:/NXCOMPAT>) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NXCOMPAT") #Use address space layout randomization - add_link_options($<$,SHARED_LIBRARY>:/DYNAMICBASE>) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DYNAMICBASE") #shrink pdb size - add_link_options($<$,SHARED_LIBRARY>:/PDBCOMPRESS>) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /PDBCOMPRESS") - add_link_options($<$,SHARED_LIBRARY>:/DEBUG>) - add_link_options($<$,SHARED_LIBRARY>:/IGNORE:4197,4013,4254,4070,4221>) - add_link_options($<$,SHARED_LIBRARY>:/SUBSYSTEM:WINDOWS,${WINDOWS_SUBSYSTEM_VERSION}>) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4197,4013,4254,4070,4221") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,${WINDOWS_SUBSYSTEM_VERSION}") set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221") - add_link_options($<$,EXECUTABLE>:/DEBUG>) - add_link_options($<$,EXECUTABLE>:/PDBCOMPRESS>) - add_link_options($<$,EXECUTABLE>:/STACK:1572864>) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /PDBCOMPRESS") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1572864") # Debug build specific flags - add_link_options($<$,$>,$,SHARED_LIBRARY>>:/NOVCFEATURE>) + set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NOVCFEATURE") + set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "${CMAKE_SHARED_LINKER_FLAGS_CHECKED} /NOVCFEATURE") # Checked build specific flags - add_link_options($<$:/INCREMENTAL:NO>) # prevent "warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification" - add_link_options($<$:/OPT:REF>) - add_link_options($<$:/OPT:NOICF>) + add_linker_flag(/INCREMENTAL:NO CHECKED) # prevent "warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification" + add_linker_flag(/OPT:REF CHECKED) + add_linker_flag(/OPT:NOICF CHECKED) # Release build specific flags - add_link_options($<$:/LTCG>) - add_link_options($<$:/OPT:REF>) - add_link_options($<$:/OPT:ICF>) + add_linker_flag(/LTCG RELEASE) + add_linker_flag(/OPT:REF RELEASE) + add_linker_flag(/OPT:ICF RELEASE) + add_linker_flag(/INCREMENTAL:NO RELEASE) set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG") # ReleaseWithDebugInfo build specific flags - add_link_options($<$:/LTCG>) - add_link_options($<$:/OPT:REF>) - add_link_options($<$:/OPT:ICF>) + add_linker_flag(/LTCG RELWITHDEBINFO) + add_linker_flag(/OPT:REF RELWITHDEBINFO) + add_linker_flag(/OPT:ICF RELWITHDEBINFO) set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") # Force uCRT to be dynamically linked for Release build - add_link_options("$<$:/NODEFAULTLIB:libucrt.lib;/DEFAULTLIB:ucrt.lib>") + add_linker_flag(/NODEFAULTLIB:libucrt.lib RELEASE) + add_linker_flag(/DEFAULTLIB:ucrt.lib RELEASE) elseif (CLR_CMAKE_HOST_UNIX) # Set the values to display when interactively configuring CMAKE_BUILD_TYPE @@ -157,11 +165,10 @@ elseif (CLR_CMAKE_HOST_UNIX) # -fdata-sections -ffunction-sections: each function has own section instead of one per .o file (needed for --gc-sections) # -O1: optimization level used instead of -O0 to avoid compile error "invalid operand for inline asm constraint" - add_compile_definitions("$<$,$>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>") - add_link_options($<$,$>,$,EXECUTABLE>>:${CLR_SANITIZE_LINK_OPTIONS}>) - + add_compile_options("$<$,$>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>") + add_linker_flag("${CLR_SANITIZE_LINK_OPTIONS}" DEBUG CHECKED) # -Wl and --gc-sections: drop unused sections\functions (similar to Windows /Gy function-level-linking) - add_link_options("$<$,$>,$,SHARED_LIBRARY>>:${CLR_SANITIZE_LINK_OPTIONS};-Wl,--gc-sections>") + add_linker_flag("-Wl,--gc-sections" DEBUG CHECKED) endif () endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED) endif(MSVC) @@ -173,15 +180,18 @@ endif(MSVC) # ./build-native.sh cmakeargs "-DCLR_ADDITIONAL_COMPILER_OPTIONS=<...>" cmakeargs "-DCLR_ADDITIONAL_LINKER_FLAGS=<...>" # if(CLR_CMAKE_HOST_UNIX) - add_link_options(${CLR_ADDITIONAL_LINKER_FLAGS}) + foreach(ADDTL_LINKER_FLAG ${CLR_ADDITIONAL_LINKER_FLAGS}) + add_linker_flag(${ADDTL_LINKER_FLAG}) + endforeach() endif(CLR_CMAKE_HOST_UNIX) if(CLR_CMAKE_HOST_LINUX) add_compile_options($<$:-Wa,--noexecstack>) - add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now) + add_linker_flag(-Wl,--build-id=sha1) + add_linker_flag(-Wl,-z,relro,-z,now) elseif(CLR_CMAKE_HOST_FREEBSD) add_compile_options($<$:-Wa,--noexecstack>) - add_link_options(LINKER:--build-id=sha1) + add_linker_flag("-Wl,--build-id=sha1") elseif(CLR_CMAKE_HOST_SUNOS) add_compile_options($<$:-Wa,--noexecstack>) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector") @@ -361,7 +371,7 @@ if (CLR_CMAKE_HOST_UNIX) if(CLR_CMAKE_HOST_OSX) set(MACOS_VERSION_MIN_FLAGS -mmacosx-version-min=10.12) add_compile_options(${MACOS_VERSION_MIN_FLAGS}) - add_link_options(${MACOS_VERSION_MIN_FLAGS}) + add_linker_flag(${MACOS_VERSION_MIN_FLAGS}) endif(CLR_CMAKE_HOST_OSX) endif(CLR_CMAKE_HOST_UNIX) @@ -517,7 +527,7 @@ if(CLR_CMAKE_ENABLE_CODE_COVERAGE) add_compile_options(-fprofile-arcs) add_compile_options(-ftest-coverage) - add_link_options(--coverage) + add_linker_flag(--coverage) else() message(FATAL_ERROR "Code coverage builds not supported on current platform") endif(CLR_CMAKE_HOST_UNIX) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index b42a4ea5f5b82..7042bc4c1550a 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -1,4 +1,3 @@ -include(CheckPIESupported) include(${CMAKE_CURRENT_LIST_DIR}/functions.cmake) # If set, indicates that this is not an officially supported release @@ -382,24 +381,11 @@ else() endif() if(NOT CLR_CMAKE_TARGET_BROWSER) - # Skip check_pie_supported call on Android as ld from llvm toolchain with NDK API level 21 - # complains about missing linker flag `-no-pie` (while level 28's ld does support this flag, - # but since we know that PIE is supported, we can safely skip this redundant check). - # # The default linker on Solaris also does not support PIE. - if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS) - # All code we build should be compiled as position independent - get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) - if("CXX" IN_LIST languages) - set(CLR_PIE_LANGUAGE CXX) - else() - set(CLR_PIE_LANGUAGE C) - endif() - check_pie_supported(OUTPUT_VARIABLE PIE_SUPPORT_OUTPUT LANGUAGES ${CLR_PIE_LANGUAGE}) - if(NOT MSVC AND NOT CMAKE_${CLR_PIE_LANGUAGE}_LINK_PIE_SUPPORTED) - message(WARNING "PIE is not supported at link time: ${PIE_SUPPORT_OUTPUT}.\n" - "PIE link options will not be passed to linker.") - endif() + if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS AND NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_IOS AND NOT MSVC) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") + add_compile_options($<$,EXECUTABLE>:-fPIE>) + add_compile_options($<$,SHARED_LIBRARY>:-fPIC>) endif() set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index 8b73581ed1426..1509a17fa59b0 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -148,7 +148,7 @@ function(preprocess_compile_asm) set(options "") set(oneValueArgs TARGET OUTPUT_OBJECTS) set(multiValueArgs ASM_FILES) - cmake_parse_arguments(PARSE_ARGV 0 COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}") + cmake_parse_arguments(COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}) get_include_directories_asm(ASM_INCLUDE_DIRECTORIES) @@ -241,7 +241,7 @@ function(target_precompile_header) set(options "") set(oneValueArgs TARGET HEADER) set(multiValueArgs ADDITIONAL_INCLUDE_DIRECTORIES) - cmake_parse_arguments(PARSE_ARGV 0 PRECOMPILE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}") + cmake_parse_arguments(PRECOMPILE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}) if ("${PRECOMPILE_HEADERS_TARGET}" STREQUAL "") message(SEND_ERROR "No target supplied to target_precompile_header.") @@ -360,7 +360,7 @@ endfunction() function(install_clr) set(oneValueArgs ADDITIONAL_DESTINATION) set(multiValueArgs TARGETS) - cmake_parse_arguments(PARSE_ARGV 0 INSTALL_CLR "${options}" "${oneValueArgs}" "${multiValueArgs}") + cmake_parse_arguments(INSTALL_CLR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}) if ("${INSTALL_CLR_TARGETS}" STREQUAL "") message(FATAL_ERROR "At least one target must be passed to install_clr(TARGETS )") @@ -416,6 +416,15 @@ function(disable_pax_mprotect targetName) endif() endfunction() +if (CMAKE_VERSION VERSION_LESS "3.12") + # Polyfill add_compile_definitions when it is unavailable + function(add_compile_definitions) + get_directory_property(DIR_COMPILE_DEFINITIONS COMPILE_DEFINITIONS) + list(APPEND DIR_COMPILE_DEFINITIONS ${ARGV}) + set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${DIR_COMPILE_DEFINITIONS}") + endfunction() +endif() + function(_add_executable) if(NOT WIN32) add_executable(${ARGV} ${VERSION_FILE_PATH}) @@ -479,3 +488,16 @@ function(generate_module_index Target ModuleIndexFile) DEPENDS ${ModuleIndexFile} ) endfunction(generate_module_index) + +# add_linker_flag(Flag [Config1 Config2 ...]) +function(add_linker_flag Flag) + if (ARGN STREQUAL "") + set("CMAKE_EXE_LINKER_FLAGS" "${CMAKE_EXE_LINKER_FLAGS} ${Flag}" PARENT_SCOPE) + set("CMAKE_SHARED_LINKER_FLAGS" "${CMAKE_SHARED_LINKER_FLAGS} ${Flag}" PARENT_SCOPE) + else() + foreach(Config ${ARGN}) + set("CMAKE_EXE_LINKER_FLAGS_${Config}" "${CMAKE_EXE_LINKER_FLAGS_${Config}} ${Flag}" PARENT_SCOPE) + set("CMAKE_SHARED_LINKER_FLAGS_${Config}" "${CMAKE_SHARED_LINKER_FLAGS_${Config}} ${Flag}" PARENT_SCOPE) + endforeach() + endif() +endfunction() diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index f27bb33e35778..1b4c2e02c597f 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -91,6 +91,9 @@ if [[ "$build_arch" == "wasm" ]]; then cmake_command="emcmake $cmake_command" fi +# We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options +pushd "$3" + # Include CMAKE_USER_MAKE_RULES_OVERRIDE as uninitialized since it will hold its value in the CMake cache otherwise can cause issues when branch switching $cmake_command \ -G "$generator" \ @@ -98,5 +101,6 @@ $cmake_command \ "-DCMAKE_INSTALL_PREFIX=$__CMakeBinDir" \ $cmake_extra_defines \ $__UnprocessedCMakeArgs \ - -S "$1" \ - -B "$3" + "$1" + +popd diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 0d60cf16fc106..b94eb54a67154 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14.5) +cmake_minimum_required(VERSION 3.6.2) cmake_policy(SET CMP0042 NEW) diff --git a/src/coreclr/pgosupport.cmake b/src/coreclr/pgosupport.cmake index 4b11980901712..04bde2bc20bca 100644 --- a/src/coreclr/pgosupport.cmake +++ b/src/coreclr/pgosupport.cmake @@ -1,5 +1,18 @@ -include(CheckIPOSupported) -check_ipo_supported(RESULT HAVE_LTO) +include(CheckCXXSourceCompiles) +include(CheckCXXCompilerFlag) + +# VC++ guarantees support for LTCG (LTO's equivalent) +if(NOT WIN32) + # Function required to give CMAKE_REQUIRED_* local scope + function(check_have_lto) + set(CMAKE_REQUIRED_FLAGS -flto) + set(CMAKE_REQUIRED_LIBRARIES -flto -fuse-ld=gold) + check_cxx_source_compiles("int main() { return 0; }" HAVE_LTO) + endfunction(check_have_lto) + check_have_lto() + + check_cxx_compiler_flag(-faligned-new COMPILER_SUPPORTS_F_ALIGNED_NEW) +endif(NOT WIN32) # Adds Profile Guided Optimization (PGO) flags to the current target function(add_pgo TargetName) diff --git a/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt b/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt index e3fc3ed9e3a5e..98cc178b8a300 100644 --- a/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt +++ b/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.8) # Quick note: The CMake C# support is using the CSC bundled with the MSBuild that the native build runs on, not the one supplied by the local .NET SDK. project(DacTableGen LANGUAGES CSharp) diff --git a/src/coreclr/src/binder/CMakeLists.txt b/src/coreclr/src/binder/CMakeLists.txt index 9c242ed1518df..208f1214dd0da 100644 --- a/src/coreclr/src/binder/CMakeLists.txt +++ b/src/coreclr/src/binder/CMakeLists.txt @@ -82,11 +82,13 @@ endif(CLR_CMAKE_TARGET_WIN32) convert_to_absolute_path(BINDER_SOURCES ${BINDER_SOURCES}) convert_to_absolute_path(BINDER_CROSSGEN_SOURCES ${BINDER_CROSSGEN_SOURCES}) -add_library_clr(v3binder +add_library_clr(v3binder_obj OBJECT ${BINDER_SOURCES} ) -add_dependencies(v3binder eventing_headers) +add_dependencies(v3binder_obj eventing_headers) +add_library(v3binder INTERFACE) +target_sources(v3binder INTERFACE $) add_library_clr(v3binder_crossgen STATIC diff --git a/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt b/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt index c3122ec12ec3d..fdcf344c16ac5 100644 --- a/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt +++ b/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt @@ -10,9 +10,11 @@ set(BCLTYPE_SOURCES variant.cpp ) -add_library_clr(bcltype +add_library_clr(bcltype_obj OBJECT ${BCLTYPE_SOURCES} ) -add_dependencies(bcltype eventing_headers) +add_dependencies(bcltype_obj eventing_headers) +add_library(bcltype INTERFACE) +target_sources(bcltype INTERFACE $) diff --git a/src/coreclr/src/classlibnative/float/CMakeLists.txt b/src/coreclr/src/classlibnative/float/CMakeLists.txt index 2345ad0b91354..b2c47ea39b65e 100644 --- a/src/coreclr/src/classlibnative/float/CMakeLists.txt +++ b/src/coreclr/src/classlibnative/float/CMakeLists.txt @@ -7,9 +7,12 @@ set(FLOAT_SOURCES floatsingle.cpp ) -add_library_clr(comfloat_wks +add_library_clr(comfloat_wks_obj OBJECT ${FLOAT_SOURCES} ) -add_dependencies(comfloat_wks eventing_headers) +add_dependencies(comfloat_wks_obj eventing_headers) + +add_library(comfloat_wks INTERFACE) +target_sources(comfloat_wks INTERFACE $) \ No newline at end of file diff --git a/src/coreclr/src/debug/debug-pal/CMakeLists.txt b/src/coreclr/src/debug/debug-pal/CMakeLists.txt index 12a0005c05322..213fa59e784c5 100644 --- a/src/coreclr/src/debug/debug-pal/CMakeLists.txt +++ b/src/coreclr/src/debug/debug-pal/CMakeLists.txt @@ -34,4 +34,6 @@ if(CLR_CMAKE_HOST_UNIX) endif(CLR_CMAKE_HOST_UNIX) -_add_library(debug-pal OBJECT ${TWO_WAY_PIPE_SOURCES}) +_add_library(debug-pal_obj OBJECT ${TWO_WAY_PIPE_SOURCES}) +add_library(debug-pal INTERFACE) +target_sources(debug-pal INTERFACE $) diff --git a/src/coreclr/src/debug/ee/wks/CMakeLists.txt b/src/coreclr/src/debug/ee/wks/CMakeLists.txt index a6891ebb052cb..3dd5e3612dfc8 100644 --- a/src/coreclr/src/debug/ee/wks/CMakeLists.txt +++ b/src/coreclr/src/debug/ee/wks/CMakeLists.txt @@ -9,9 +9,9 @@ if (CLR_CMAKE_TARGET_WIN32) if(CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64) - preprocess_compile_asm(TARGET cordbee_wks ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS) + preprocess_compile_asm(TARGET cordbee_wks_obj ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS) - add_library_clr(cordbee_wks OBJECT ${CORDBEE_SOURCES_WKS} ${ASM_FILE} ${ASM_OBJECTS}) + add_library_clr(cordbee_wks_obj OBJECT ${CORDBEE_SOURCES_WKS} ${ASM_FILE} ${ASM_OBJECTS}) else () @@ -23,19 +23,21 @@ if (CLR_CMAKE_TARGET_WIN32) set_source_files_properties(${ASM_FILE} PROPERTIES COMPILE_OPTIONS "${ASM_OPTIONS}") - add_library_clr(cordbee_wks OBJECT ${CORDBEE_SOURCES_WKS} ${ASM_FILE}) + add_library_clr(cordbee_wks_obj OBJECT ${CORDBEE_SOURCES_WKS} ${ASM_FILE}) endif() else () if(CLR_CMAKE_HOST_ARCH_AMD64 OR CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64 OR CLR_CMAKE_HOST_ARCH_I386) - add_library_clr(cordbee_wks OBJECT ${CORDBEE_SOURCES_WKS} ../${ARCH_SOURCES_DIR}/dbghelpers.S) + add_library_clr(cordbee_wks_obj OBJECT ${CORDBEE_SOURCES_WKS} ../${ARCH_SOURCES_DIR}/dbghelpers.S) else() message(FATAL_ERROR "Unknown platform") endif() endif (CLR_CMAKE_TARGET_WIN32) -target_precompile_header(TARGET cordbee_wks HEADER stdafx.h) -add_dependencies(cordbee_wks eventing_headers) +target_precompile_header(TARGET cordbee_wks_obj HEADER stdafx.h) +add_dependencies(cordbee_wks_obj eventing_headers) +add_library(cordbee_wks INTERFACE) +target_sources(cordbee_wks INTERFACE $) diff --git a/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt b/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt index b5b249228d26f..362da1f648302 100644 --- a/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt +++ b/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt @@ -10,5 +10,6 @@ set( ILDBSYMLIB_SOURCES symwrite.cpp ) -add_library_clr(ildbsymlib OBJECT ${ILDBSYMLIB_SOURCES}) - +add_library_clr(ildbsymlib_obj OBJECT ${ILDBSYMLIB_SOURCES}) +add_library(ildbsymlib INTERFACE) +target_sources(ildbsymlib INTERFACE $) diff --git a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt index f01133ce40ffb..2a25b2119b366 100644 --- a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt @@ -10,17 +10,17 @@ if (CLR_CMAKE_HOST_WIN32) list(APPEND CLR_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def) - add_link_options(/ENTRY:CoreDllMain) + add_linker_flag("/ENTRY:CoreDllMain") # Incremental linking results in the linker inserting extra padding and routing function calls via thunks that can break the # invariants (e.g. size of region between Jit_PatchedCodeLast-Jit_PatchCodeStart needs to fit in a page). - add_link_options(/INCREMENTAL:NO) + add_linker_flag("/INCREMENTAL:NO") # Delay load libraries required for WinRT as that is not supported on all platforms - add_link_options("/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll") + add_linker_flag("/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll") # Delay load version.dll so that we can specify how to search when loading it as it is not part of Windows' known DLLs - add_link_options("/DELAYLOAD:version.dll") + add_linker_flag("/DELAYLOAD:version.dll") # No library groups for Win32 set(START_LIBRARY_GROUP) @@ -33,7 +33,7 @@ else(CLR_CMAKE_HOST_WIN32) if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) # This option is necessary to ensure that the overloaded delete operator defined inside # of the utilcode will be used instead of the standard library delete operator. - add_link_options("LINKER:-Bsymbolic") + add_linker_flag("-Wl,-Bsymbolic") # The following linked options can be inserted into the linker libraries list to # ensure proper resolving of circular references between a subset of the libraries. @@ -109,7 +109,7 @@ set(CORECLR_LIBRARIES ildbsymlib utilcode v3binder - System.Globalization.Native-Static + System.Globalization.Native-static interop ) @@ -168,8 +168,10 @@ if(FEATURE_MERGE_JIT_AND_ENGINE) set(CLRJIT_STATIC clrjit_static) endif(FEATURE_MERGE_JIT_AND_ENGINE) -target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} cee_wks cee_wks_core) -target_link_libraries(coreclr_static PUBLIC ${CORECLR_LIBRARIES} clrjit_static cee_wks_mergeable cee_wks_core) +target_sources(coreclr PUBLIC $) +target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} cee_wks) +target_sources(coreclr_static PUBLIC $) +target_link_libraries(coreclr_static PUBLIC ${CORECLR_LIBRARIES} clrjit_static cee_wks_mergeable) # Create the runtime module index header file containing the coreclr build id # for xplat and the timestamp/size on Windows. diff --git a/src/coreclr/src/dlls/mscorrc/CMakeLists.txt b/src/coreclr/src/dlls/mscorrc/CMakeLists.txt index ed5ee88765087..e114ec19cea63 100644 --- a/src/coreclr/src/dlls/mscorrc/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscorrc/CMakeLists.txt @@ -19,7 +19,9 @@ if(CLR_CMAKE_HOST_WIN32) else() build_resources(${CMAKE_CURRENT_SOURCE_DIR}/include.rc mscorrc TARGET_CPP_FILE) - add_library_clr(mscorrc OBJECT + add_library_clr(mscorrc_obj OBJECT ${TARGET_CPP_FILE} ) + add_library(mscorrc INTERFACE) + target_sources(mscorrc INTERFACE $) endif(CLR_CMAKE_HOST_WIN32) diff --git a/src/coreclr/src/gcinfo/CMakeLists.txt b/src/coreclr/src/gcinfo/CMakeLists.txt index 3862de8633d0c..50a1722a8eab3 100644 --- a/src/coreclr/src/gcinfo/CMakeLists.txt +++ b/src/coreclr/src/gcinfo/CMakeLists.txt @@ -16,11 +16,14 @@ endif(CLR_CMAKE_TARGET_ARCH_I386) convert_to_absolute_path(GCINFO_SOURCES ${GCINFO_SOURCES}) -add_library_clr(gcinfo +add_library_clr(gcinfo_obj OBJECT ${GCINFO_SOURCES} ) +add_library(gcinfo INTERFACE) +target_sources(gcinfo INTERFACE $) + add_library_clr(gcinfo_crossgen STATIC ${GCINFO_SOURCES} diff --git a/src/coreclr/src/inc/CMakeLists.txt b/src/coreclr/src/inc/CMakeLists.txt index 8176220125166..4f75d3a882d4c 100644 --- a/src/coreclr/src/inc/CMakeLists.txt +++ b/src/coreclr/src/inc/CMakeLists.txt @@ -58,7 +58,9 @@ if(FEATURE_JIT_PITCHING) endif(FEATURE_JIT_PITCHING) # Compile *_i.cpp to lib -_add_library(corguids OBJECT ${CORGUIDS_SOURCES}) +_add_library(corguids_obj OBJECT ${CORGUIDS_SOURCES}) +add_library(corguids INTERFACE) +target_sources(corguids INTERFACE $) # Binplace the inc files for packaging later. @@ -75,4 +77,3 @@ _install (FILES cfi.h gcinfoencoder.h gcinfotypes.h DESTINATION inc) -_install (TARGETS corguids DESTINATION lib) diff --git a/src/coreclr/src/interop/CMakeLists.txt b/src/coreclr/src/interop/CMakeLists.txt index b8a0e769318db..1642f55a04da5 100644 --- a/src/coreclr/src/interop/CMakeLists.txt +++ b/src/coreclr/src/interop/CMakeLists.txt @@ -30,7 +30,10 @@ endif(WIN32) convert_to_absolute_path(INTEROP_SOURCES ${INTEROP_SOURCES}) -add_library_clr(interop +add_library_clr(interop_obj OBJECT ${INTEROP_SOURCES} ) + +add_library(interop INTERFACE) +target_sources(interop INTERFACE $) \ No newline at end of file diff --git a/src/coreclr/src/jit/static/CMakeLists.txt b/src/coreclr/src/jit/static/CMakeLists.txt index b4e62c041cd44..01bdbf5a731f5 100644 --- a/src/coreclr/src/jit/static/CMakeLists.txt +++ b/src/coreclr/src/jit/static/CMakeLists.txt @@ -2,14 +2,17 @@ project(ClrJit) set_source_files_properties(${JIT_EXPORTS_FILE} PROPERTIES GENERATED TRUE) -add_library_clr(clrjit_static +add_library_clr(clrjit_obj OBJECT ${JIT_CORE_SOURCES} ${JIT_ARCH_SOURCES} ) if(CLR_CMAKE_HOST_UNIX) - add_dependencies(clrjit_static coreclrpal gcinfo) + add_dependencies(clrjit_obj coreclrpal gcinfo) endif(CLR_CMAKE_HOST_UNIX) -target_precompile_header(TARGET clrjit_static HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR}) +target_precompile_header(TARGET clrjit_obj HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR}) + +add_library(clrjit_static INTERFACE) +target_sources(clrjit_static INTERFACE $) diff --git a/src/coreclr/src/md/ceefilegen/CMakeLists.txt b/src/coreclr/src/md/ceefilegen/CMakeLists.txt index 39864c71817f5..fd0f8424d97f1 100644 --- a/src/coreclr/src/md/ceefilegen/CMakeLists.txt +++ b/src/coreclr/src/md/ceefilegen/CMakeLists.txt @@ -25,8 +25,11 @@ if (CLR_CMAKE_TARGET_WIN32) list(APPEND CEEFILEGEN_SOURCES ${CEEFILEGEN_HEADERS}) endif (CLR_CMAKE_TARGET_WIN32) -add_library_clr(ceefgen +add_library_clr(ceefgen_obj OBJECT ${CEEFILEGEN_SOURCES} ) -target_precompile_header(TARGET ceefgen HEADER stdafx.h) +target_precompile_header(TARGET ceefgen_obj HEADER stdafx.h) + +add_library(ceefgen INTERFACE) +target_sources(ceefgen INTERFACE $) diff --git a/src/coreclr/src/md/compiler/CMakeLists.txt b/src/coreclr/src/md/compiler/CMakeLists.txt index 495fa4d70ca26..f32c80407c6a5 100644 --- a/src/coreclr/src/md/compiler/CMakeLists.txt +++ b/src/coreclr/src/md/compiler/CMakeLists.txt @@ -68,9 +68,11 @@ add_library_clr(mdcompiler_dac ${MDCOMPILER_SOURCES}) set_target_properties(mdcompiler_dac PROPERTIES DAC_COMPONENT TRUE) target_precompile_header(TARGET mdcompiler_dac HEADER stdafx.h) -add_library_clr(mdcompiler_wks OBJECT ${MDCOMPILER_WKS_SOURCES}) -target_compile_definitions(mdcompiler_wks PRIVATE FEATURE_METADATA_EMIT_ALL) -target_precompile_header(TARGET mdcompiler_wks HEADER stdafx.h) +add_library_clr(mdcompiler_wks_obj OBJECT ${MDCOMPILER_WKS_SOURCES}) +target_compile_definitions(mdcompiler_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL) +target_precompile_header(TARGET mdcompiler_wks_obj HEADER stdafx.h) +add_library(mdcompiler_wks INTERFACE) +target_sources(mdcompiler_wks INTERFACE $) add_library_clr(mdcompiler-dbi ${MDCOMPILER_SOURCES}) set_target_properties(mdcompiler-dbi PROPERTIES DBI_COMPONENT TRUE) diff --git a/src/coreclr/src/md/enc/CMakeLists.txt b/src/coreclr/src/md/enc/CMakeLists.txt index 14ed0a267fae6..e30c51b1e37c4 100644 --- a/src/coreclr/src/md/enc/CMakeLists.txt +++ b/src/coreclr/src/md/enc/CMakeLists.txt @@ -52,9 +52,11 @@ add_library_clr(mdruntimerw_dac ${MDRUNTIMERW_SOURCES}) set_target_properties(mdruntimerw_dac PROPERTIES DAC_COMPONENT TRUE) target_precompile_header(TARGET mdruntimerw_dac HEADER stdafx.h) -add_library_clr(mdruntimerw_wks OBJECT ${MDRUNTIMERW_SOURCES}) -target_compile_definitions(mdruntimerw_wks PRIVATE FEATURE_METADATA_EMIT_ALL) -target_precompile_header(TARGET mdruntimerw_wks HEADER stdafx.h) +add_library_clr(mdruntimerw_wks_obj OBJECT ${MDRUNTIMERW_SOURCES}) +target_compile_definitions(mdruntimerw_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL) +target_precompile_header(TARGET mdruntimerw_wks_obj HEADER stdafx.h) +add_library(mdruntimerw_wks INTERFACE) +target_sources(mdruntimerw_wks INTERFACE $) add_library_clr(mdruntimerw-dbi ${MDRUNTIMERW_SOURCES}) set_target_properties(mdruntimerw-dbi PROPERTIES DBI_COMPONENT TRUE) diff --git a/src/coreclr/src/md/hotdata/CMakeLists.txt b/src/coreclr/src/md/hotdata/CMakeLists.txt index 03430e292c75d..46381cf7dddd1 100644 --- a/src/coreclr/src/md/hotdata/CMakeLists.txt +++ b/src/coreclr/src/md/hotdata/CMakeLists.txt @@ -33,8 +33,10 @@ add_library_clr(mdhotdata_dac ${MDHOTDATA_SOURCES}) set_target_properties(mdhotdata_dac PROPERTIES DAC_COMPONENT TRUE) target_precompile_header(TARGET mdhotdata_dac HEADER external.h) -add_library_clr(mdhotdata_full OBJECT ${MDHOTDATA_SOURCES}) -target_precompile_header(TARGET mdhotdata_full HEADER external.h) +add_library_clr(mdhotdata_full_obj OBJECT ${MDHOTDATA_SOURCES}) +target_precompile_header(TARGET mdhotdata_full_obj HEADER external.h) +add_library(mdhotdata_full INTERFACE) +target_sources(mdhotdata_full INTERFACE $) add_library_clr(mdhotdata_crossgen ${MDHOTDATA_SOURCES}) set_target_properties(mdhotdata_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE) diff --git a/src/coreclr/src/md/runtime/CMakeLists.txt b/src/coreclr/src/md/runtime/CMakeLists.txt index 5753e655abf99..06e9e83000195 100644 --- a/src/coreclr/src/md/runtime/CMakeLists.txt +++ b/src/coreclr/src/md/runtime/CMakeLists.txt @@ -49,9 +49,11 @@ add_library_clr(mdruntime_dac ${MDRUNTIME_SOURCES}) set_target_properties(mdruntime_dac PROPERTIES DAC_COMPONENT TRUE) target_precompile_header(TARGET mdruntime_dac HEADER stdafx.h) -add_library_clr(mdruntime_wks OBJECT ${MDRUNTIME_SOURCES}) -target_compile_definitions(mdruntime_wks PRIVATE FEATURE_METADATA_EMIT_ALL) -target_precompile_header(TARGET mdruntime_wks HEADER stdafx.h) +add_library_clr(mdruntime_wks_obj OBJECT ${MDRUNTIME_SOURCES}) +target_compile_definitions(mdruntime_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL) +target_precompile_header(TARGET mdruntime_wks_obj HEADER stdafx.h) +add_library(mdruntime_wks INTERFACE) +target_sources(mdruntime_wks INTERFACE $) add_library_clr(mdruntime-dbi ${MDRUNTIME_SOURCES}) set_target_properties(mdruntime-dbi PROPERTIES DBI_COMPONENT TRUE) diff --git a/src/coreclr/src/pal/src/CMakeLists.txt b/src/coreclr/src/pal/src/CMakeLists.txt index 094f14cabf821..712dabf46a3e6 100644 --- a/src/coreclr/src/pal/src/CMakeLists.txt +++ b/src/coreclr/src/pal/src/CMakeLists.txt @@ -267,10 +267,12 @@ endif(CLR_CMAKE_TARGET_OSX) # > warning for library: libtracepointprovider.a the table of contents is empty (no object file members in the library define global symbols) # if(CLR_CMAKE_TARGET_LINUX) - add_library(tracepointprovider + add_library(tracepointprovider_obj OBJECT misc/tracepointprovider.cpp ) + add_library(tracepointprovider INTERFACE) + target_sources(tracepointprovider INTERFACE $) endif(CLR_CMAKE_TARGET_LINUX) if(CLR_CMAKE_TARGET_OSX) diff --git a/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt b/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt index 39b9826d1ab5a..8e6968cf783d4 100644 --- a/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt +++ b/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt @@ -1,8 +1,8 @@ -include(FindPython) +include(FindPythonInterp) set (GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genDummyProvider.py) -set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) +set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) execute_process( COMMAND ${GENERATE_COMMAND} --dry-run diff --git a/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt b/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt index 234dea19b753d..d55dab3557f35 100644 --- a/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt +++ b/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt @@ -1,7 +1,7 @@ -include(FindPython) +include(FindPythonInterp) set (GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genLttngProvider.py) -set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) +set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) execute_process( COMMAND ${GENERATE_COMMAND} --dry-run diff --git a/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt b/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt index 000ee2d2fb0d1..845fae656be41 100644 --- a/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt +++ b/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt @@ -5,10 +5,10 @@ set(SOURCES set(EVENT_MANIFEST ${VM_DIR}/ClrEtwAll.man) set(TEST_GENERATOR ${CLR_DIR}/src/scripts/genEventingTests.py) -include(FindPython) +include(FindPythonInterp) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clralltestevents.cpp - COMMAND ${Python_EXECUTABLE} ${TEST_GENERATOR} --testdir "${CMAKE_CURRENT_BINARY_DIR}" --man "${EVENT_MANIFEST}" + COMMAND ${PYTHON_EXECUTABLE} ${TEST_GENERATOR} --testdir "${CMAKE_CURRENT_BINARY_DIR}" --man "${EVENT_MANIFEST}" DEPENDS ${EVENT_MANIFEST} ${TEST_GENERATOR} COMMENT "Updating clralltestevents.cpp" ) diff --git a/src/coreclr/src/unwinder/CMakeLists.txt b/src/coreclr/src/unwinder/CMakeLists.txt index 98cdb0c0b7a89..e9af2458140d1 100644 --- a/src/coreclr/src/unwinder/CMakeLists.txt +++ b/src/coreclr/src/unwinder/CMakeLists.txt @@ -20,8 +20,10 @@ list(APPEND UNWINDER_SOURCES convert_to_absolute_path(UNWINDER_SOURCES ${UNWINDER_SOURCES}) if(CLR_CMAKE_HOST_UNIX) - add_library_clr(unwinder_wks OBJECT ${UNWINDER_SOURCES}) - add_dependencies(unwinder_wks eventing_headers) + add_library_clr(unwinder_wks_obj OBJECT ${UNWINDER_SOURCES}) + add_dependencies(unwinder_wks_obj eventing_headers) + add_library(unwinder_wks INTERFACE) + target_sources(unwinder_wks INTERFACE $) endif(CLR_CMAKE_HOST_UNIX) add_library_clr(unwinder_dac ${UNWINDER_SOURCES}) diff --git a/src/coreclr/src/utilcode/CMakeLists.txt b/src/coreclr/src/utilcode/CMakeLists.txt index 4c1ce806b6510..35bc84a48c852 100644 --- a/src/coreclr/src/utilcode/CMakeLists.txt +++ b/src/coreclr/src/utilcode/CMakeLists.txt @@ -97,7 +97,9 @@ convert_to_absolute_path(UTILCODE_CROSSGEN_SOURCES ${UTILCODE_CROSSGEN_SOURCES}) convert_to_absolute_path(UTILCODE_STATICNOHOST_SOURCES ${UTILCODE_STATICNOHOST_SOURCES}) add_library_clr(utilcode_dac STATIC ${UTILCODE_DAC_SOURCES}) -add_library_clr(utilcode OBJECT ${UTILCODE_SOURCES}) +add_library_clr(utilcode_obj OBJECT ${UTILCODE_SOURCES}) +add_library(utilcode INTERFACE) +target_sources(utilcode INTERFACE $) add_library_clr(utilcodestaticnohost STATIC ${UTILCODE_STATICNOHOST_SOURCES}) add_library_clr(utilcode_crossgen STATIC ${UTILCODE_CROSSGEN_SOURCES}) @@ -105,9 +107,9 @@ if(CLR_CMAKE_HOST_UNIX) target_link_libraries(utilcodestaticnohost nativeresourcestring) target_link_libraries(utilcode_crossgen nativeresourcestring) target_link_libraries(utilcode_dac nativeresourcestring) - target_link_libraries(utilcode nativeresourcestring) + target_link_libraries(utilcode INTERFACE nativeresourcestring) add_dependencies(utilcode_dac coreclrpal) - add_dependencies(utilcode coreclrpal) + add_dependencies(utilcode_obj coreclrpal) endif(CLR_CMAKE_HOST_UNIX) @@ -120,10 +122,10 @@ set_target_properties(utilcode_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE) target_compile_definitions(utilcode_dac PRIVATE SELF_NO_HOST) target_compile_definitions(utilcodestaticnohost PRIVATE SELF_NO_HOST) add_dependencies(utilcode_dac ${UTILCODE_DEPENDENCIES}) -add_dependencies(utilcode ${UTILCODE_DEPENDENCIES}) +add_dependencies(utilcode_obj ${UTILCODE_DEPENDENCIES}) add_dependencies(utilcode_crossgen ${UTILCODE_DEPENDENCIES}) add_dependencies(utilcodestaticnohost ${UTILCODE_DEPENDENCIES}) target_precompile_header(TARGET utilcode_dac HEADER stdafx.h) -target_precompile_header(TARGET utilcode HEADER stdafx.h) +target_precompile_header(TARGET utilcode_obj HEADER stdafx.h) target_precompile_header(TARGET utilcode_crossgen HEADER stdafx.h) target_precompile_header(TARGET utilcodestaticnohost HEADER stdafx.h) diff --git a/src/coreclr/src/vm/CMakeLists.txt b/src/coreclr/src/vm/CMakeLists.txt index 81d0e8c21b108..0dfecfe7741b0 100644 --- a/src/coreclr/src/vm/CMakeLists.txt +++ b/src/coreclr/src/vm/CMakeLists.txt @@ -921,7 +921,7 @@ list(APPEND VM_HEADERS_DAC if (CLR_CMAKE_TARGET_WIN32) list(APPEND VM_SOURCES_WKS ${VM_HEADERS_WKS}) - list(APPEND VM_SOURCES_WKS_ARCH_ASM ${VM_HEADERS_WKS_ARCH_ASM}) + list(APPEND VM_SOURCES_WKS ${VM_HEADERS_WKS_ARCH_ASM}) list(APPEND VM_SOURCES_DAC ${VM_HEADERS_DAC}) endif(CLR_CMAKE_TARGET_WIN32) diff --git a/src/coreclr/src/vm/eventing/CMakeLists.txt b/src/coreclr/src/vm/eventing/CMakeLists.txt index 98dd158df5457..e2bf024fc59fd 100644 --- a/src/coreclr/src/vm/eventing/CMakeLists.txt +++ b/src/coreclr/src/vm/eventing/CMakeLists.txt @@ -8,12 +8,13 @@ else() set(NEED_XPLAT_HEADER ON) endif() -include(FindPython) +include(FindPythonInterp) set (EventingHeaders ${GENERATED_INCLUDE_DIR}/etmdummy.h ${GENERATED_INCLUDE_DIR}/clretwallmain.h ${GENERATED_INCLUDE_DIR}/clreventpipewriteevents.h + ${GENERATED_INCLUDE_DIR}/clrproviders.h ) if (NEED_XPLAT_HEADER) @@ -24,7 +25,7 @@ endif() set(GENEVENTING_SCRIPT ${CLR_DIR}/src/scripts/genEventing.py) add_custom_target(eventing_headers - ${Python_EXECUTABLE} ${GENEVENTING_SCRIPT} --man ${EVENT_MANIFEST} --inc ${GENERATED_INCLUDE_DIR} --dummy ${GENERATED_INCLUDE_DIR}/etmdummy.h ${NONEXTERN_ARG} ${NOXPLATHEADER_ARG} + ${PYTHON_EXECUTABLE} ${GENEVENTING_SCRIPT} --man ${EVENT_MANIFEST} --inc ${GENERATED_INCLUDE_DIR} --dummy ${GENERATED_INCLUDE_DIR}/etmdummy.h ${NONEXTERN_ARG} ${NOXPLATHEADER_ARG} DEPENDS ${EVENT_MANIFEST} ${GENEVENTING_SCRIPT} VERBATIM ) diff --git a/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt b/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt index 34a067e1ec542..4c7df2fbb3cf1 100644 --- a/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt +++ b/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt @@ -1,4 +1,4 @@ -include(FindPython) +include(FindPythonInterp) set(ETW_PROVIDER_SCRIPT ${CLR_DIR}/src/scripts/genEtwProvider.py) @@ -14,5 +14,5 @@ set (ETW_PROVIDER_OUTPUTS set_source_files_properties(${ETW_PROVIDER_OUTPUTS} PROPERTIES GENERATED TRUE) add_custom_target(eventprovider - ${Python_EXECUTABLE} ${ETW_PROVIDER_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${GENERATED_INCLUDE_DIR} + ${PYTHON_EXECUTABLE} ${ETW_PROVIDER_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${GENERATED_INCLUDE_DIR} DEPENDS ${EVENT_MANIFEST} ${EVENT_EXCLUSIONS} ${ETW_PROVIDER_SCRIPT}) diff --git a/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt b/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt index 4e816676b8a75..00d79737e54cf 100644 --- a/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt +++ b/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt @@ -1,9 +1,9 @@ -include(FindPython) +include(FindPythonInterp) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genEventPipe.py) -set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${CMAKE_CURRENT_BINARY_DIR} ${NONEXTERN_ARG}) +set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${CMAKE_CURRENT_BINARY_DIR} ${NONEXTERN_ARG}) execute_process( COMMAND ${GENERATE_COMMAND} --dry-run @@ -28,10 +28,8 @@ add_custom_command(OUTPUT ${EVENTPIPE_SOURCES} COMMAND ${GENERATE_COMMAND} DEPENDS ${GENERATE_SCRIPT} ${EVENT_MANIFEST} ${EVENT_EXCLUSIONS}) -add_library_clr(eventpipe OBJECT ${EVENTPIPE_SOURCES}) -set_target_properties(eventpipe PROPERTIES LINKER_LANGUAGE CXX) -add_dependencies(eventpipe eventing_headers) - -if (NOT CLR_CMAKE_TARGET_WIN32) - _install(TARGETS eventpipe DESTINATION lib) -endif() +add_library_clr(eventpipe_obj OBJECT ${EVENTPIPE_SOURCES}) +set_target_properties(eventpipe_obj PROPERTIES LINKER_LANGUAGE CXX) +add_dependencies(eventpipe_obj eventing_headers) +add_library(eventpipe INTERFACE) +target_sources(eventpipe INTERFACE $) diff --git a/src/coreclr/src/vm/wks/CMakeLists.txt b/src/coreclr/src/vm/wks/CMakeLists.txt index bd675204bd78a..0c0daa2d18ebe 100644 --- a/src/coreclr/src/vm/wks/CMakeLists.txt +++ b/src/coreclr/src/vm/wks/CMakeLists.txt @@ -8,8 +8,12 @@ if (CLR_CMAKE_TARGET_WIN32) endif (CLR_CMAKE_TARGET_WIN32) add_library_clr(cee_wks_core OBJECT ${VM_SOURCES_WKS} ${VM_SOURCES_WKS_ARCH_ASM}) +add_library_clr(cee_wks_obj OBJECT ${VM_SOURCES_WKS_SPECIAL}) +add_library_clr(cee_wks_mergeable_obj OBJECT ${VM_SOURCES_WKS_SPECIAL}) target_precompile_header(TARGET cee_wks_core HEADER common.h) +target_precompile_header(TARGET cee_wks_obj HEADER common.h) +target_precompile_header(TARGET cee_wks_mergeable_obj HEADER common.h) if (MSVC) # mscorlib.cpp does not compile with precompiled header file @@ -17,6 +21,8 @@ if (MSVC) endif() add_dependencies(cee_wks_core eventing_headers) +add_dependencies(cee_wks_obj eventing_headers) +add_dependencies(cee_wks_mergeable_obj eventing_headers) if (CLR_CMAKE_TARGET_WIN32) @@ -49,20 +55,23 @@ if (CLR_CMAKE_TARGET_WIN32) ) add_dependencies(cee_wks_core asmconstants_inc) + add_dependencies(cee_wks_obj asmconstants_inc) + add_dependencies(cee_wks_mergeable_obj asmconstants_inc) endif(NOT CLR_CMAKE_HOST_ARCH_ARM AND NOT CLR_CMAKE_HOST_ARCH_ARM64) endif (CLR_CMAKE_TARGET_WIN32) -add_library_clr(cee_wks OBJECT ${VM_SOURCES_WKS_SPECIAL} $ ${VM_WKS_ARCH_ASM_OBJECTS}) -add_library_clr(cee_wks_mergeable OBJECT ${VM_SOURCES_WKS_SPECIAL} $ ${VM_WKS_ARCH_ASM_OBJECTS}) - add_custom_target(preprocessd_asm DEPENDS ${VM_WKS_ARCH_ASM_OBJECTS}) -add_dependencies(cee_wks preprocessd_asm) -add_dependencies(cee_wks_mergeable preprocessd_asm) +add_dependencies(cee_wks_core preprocessd_asm) +add_dependencies(cee_wks_obj preprocessd_asm) +add_dependencies(cee_wks_mergeable_obj preprocessd_asm) + -target_precompile_header(TARGET cee_wks HEADER common.h) -target_precompile_header(TARGET cee_wks_mergeable HEADER common.h) +target_compile_definitions(cee_wks_mergeable_obj PUBLIC FEATURE_MERGE_JIT_AND_ENGINE) +target_compile_definitions(cee_wks_mergeable_obj PUBLIC CORECLR_EMBEDDED) -target_compile_definitions(cee_wks_mergeable PUBLIC FEATURE_MERGE_JIT_AND_ENGINE) -target_compile_definitions(cee_wks_mergeable PUBLIC CORECLR_EMBEDDED) +add_library(cee_wks INTERFACE) +target_sources(cee_wks INTERFACE $ ${VM_WKS_ARCH_ASM_OBJECTS}) +add_library(cee_wks_mergeable INTERFACE) +target_sources(cee_wks_mergeable INTERFACE $ $ ${VM_WKS_ARCH_ASM_OBJECTS}) diff --git a/src/installer/corehost/CMakeLists.txt b/src/installer/corehost/CMakeLists.txt index 651a63be0cac9..46d1c5e898142 100644 --- a/src/installer/corehost/CMakeLists.txt +++ b/src/installer/corehost/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14.5) +cmake_minimum_required(VERSION 3.6.2) project(corehost) diff --git a/src/installer/corehost/cli/apphost/static/CMakeLists.txt b/src/installer/corehost/cli/apphost/static/CMakeLists.txt index 6d8d3f431aef2..85ea6ffe642df 100644 --- a/src/installer/corehost/cli/apphost/static/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/static/CMakeLists.txt @@ -30,6 +30,8 @@ set(HEADERS ../../../hostfxr_resolver.h ) +list(APPEND SOURCES $ $) + if(CLR_CMAKE_TARGET_WIN32) list(APPEND SOURCES ../apphost.windows.cpp) @@ -199,8 +201,6 @@ endif(NOT CLR_CMAKE_TARGET_LINUX) set_property(TARGET singlefilehost PROPERTY ENABLE_EXPORTS 1) target_link_libraries(singlefilehost - libhostfxr_static - libhostpolicy_static libhostcommon ${CORECLR_LIBRARIES} diff --git a/src/installer/corehost/cli/exe.cmake b/src/installer/corehost/cli/exe.cmake index fed0bdd455b27..6431edfbc4f9b 100644 --- a/src/installer/corehost/cli/exe.cmake +++ b/src/installer/corehost/cli/exe.cmake @@ -4,7 +4,6 @@ project (${DOTNET_PROJECT_NAME}) cmake_policy(SET CMP0011 NEW) -cmake_policy(SET CMP0083 NEW) include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) include(${CMAKE_CURRENT_LIST_DIR}/hostmisc/hostmisc.cmake) diff --git a/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt b/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt index d6c147f8f5880..c6b07eba340c9 100644 --- a/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt @@ -12,6 +12,7 @@ include_directories(../../fxr) # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES ./hostpolicy_resolver.cpp + $ ) set(HEADERS @@ -48,4 +49,4 @@ if(CLR_CMAKE_HOST_UNIX) endif(CLR_CMAKE_HOST_UNIX) install_with_stripped_symbols(hostfxr TARGETS corehost) -target_link_libraries(hostfxr libhostcommon libhostfxr_static) +target_link_libraries(hostfxr libhostcommon) diff --git a/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt b/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt index 94099c49c1d6e..8b5a55fe9b177 100644 --- a/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt +++ b/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt @@ -1,7 +1,6 @@ # 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(mockhostfxr_2_2) set(DOTNET_PROJECT_NAME "mockhostfxr_2_2") diff --git a/src/libraries/Native/Unix/CMakeLists.txt b/src/libraries/Native/Unix/CMakeLists.txt index 6c1c4ea45861b..3168c7e55c833 100644 --- a/src/libraries/Native/Unix/CMakeLists.txt +++ b/src/libraries/Native/Unix/CMakeLists.txt @@ -1,14 +1,14 @@ -cmake_minimum_required(VERSION 3.14.5) +cmake_minimum_required(VERSION 3.6.2) +if(CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + # CMake 3.14.5 contains bug fixes for iOS + cmake_minimum_required(VERSION 3.14.5) + endif() cmake_policy(SET CMP0042 NEW) project(CoreFX C) include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake) -if(NOT CLR_CMAKE_TARGET_BROWSER) - cmake_policy(SET CMP0083 NEW) -endif(NOT CLR_CMAKE_TARGET_BROWSER) - set(CMAKE_MACOSX_RPATH ON) set(CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir}) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -161,7 +161,8 @@ if(CLR_CMAKE_TARGET_UNIX) if(NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) if(CLR_CMAKE_TARGET_OSX) add_definitions(-DTARGET_OSX) - add_link_options(-Wl,-bind_at_load) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-bind_at_load") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-bind_at_load" ) else() add_compile_options($<$:-Wa,--noexecstack>) if(CLR_CMAKE_TARGET_SUNOS) @@ -169,7 +170,8 @@ if(CLR_CMAKE_TARGET_UNIX) else() # -z,now is required for full relro. # see https://www.redhat.com/en/blog/hardening-elf-binaries-using-relocation-read-only-relro - add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1 -Wl,-z,relro,-z,now") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1 -Wl,-z,relro,-z,now" ) endif() endif() endif() diff --git a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt index f71af8ada58e3..475ffc5788659 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt @@ -80,14 +80,15 @@ if (GEN_SHARED_LIB) install_with_stripped_symbols (System.Globalization.Native PROGRAMS .) endif() -add_library(System.Globalization.Native-Static +add_library(System.Globalization.Native_obj OBJECT ${NATIVEGLOBALIZATION_SOURCES} ) -set_target_properties(System.Globalization.Native-Static PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1) +set_target_properties(System.Globalization.Native_obj PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1) -install (TARGETS System.Globalization.Native-Static DESTINATION .) +add_library(System.Globalization.Native-static INTERFACE) +target_sources(System.Globalization.Native-static INTERFACE $) if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID) if (GEN_SHARED_LIB) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 0523d165acba3..77fcc16a01f92 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14.5) +cmake_minimum_required(VERSION 3.6.2) cmake_policy(SET CMP0042 NEW) project(Tests)