Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use common CLR_CMAKE_* variables in more places #31659

Merged
merged 5 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
include(CheckPIESupported)

# All code we build should be compiled as position independent
check_pie_supported(OUTPUT_VARIABLE PIE_SUPPORT_OUTPUT LANGUAGES CXX)
if(NOT MSVC AND NOT CMAKE_CXX_LINK_PIE_SUPPORTED)
message(WARNING "PIE is not supported at link time: ${PIE_SUPPORT_OUTPUT}.\n"
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
set(CLR_CMAKE_HOST_ARCH_WASM 1)
endif(CMAKE_SYSTEM_NAME STREQUAL Emscripten)

if(NOT CLR_CMAKE_HOST_ARCH_WASM)
# 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()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif(NOT CLR_CMAKE_HOST_ARCH_WASM)

#----------------------------------------
# Detect and set platform variable names
Expand Down Expand Up @@ -42,6 +54,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
set(CLR_CMAKE_HOST_UNIX_ARM 1)
set(CLR_CMAKE_HOST_UNIX_ARMV7L 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
set(CLR_CMAKE_HOST_UNIX_ARM 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
Expand Down Expand Up @@ -72,6 +85,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
elseif(CLR_CMAKE_LINUX_ID STREQUAL alpine)
set(CLR_CMAKE_HOST_ALPINE_LINUX 1)
set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_LINUX_ID})
elseif(CLR_CMAKE_LINUX_ID STREQUAL android)
set(CLR_CMAKE_HOST_ANDROID 1)
set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_LINUX_ID})
endif()
endif(DEFINED CLR_CMAKE_LINUX_ID)
endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
Expand Down Expand Up @@ -120,7 +136,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
set(CLR_CMAKE_HOST_OS Windows_NT)
endif(CMAKE_SYSTEM_NAME STREQUAL Windows)


#--------------------------------------------
# This repo builds two set of binaries
# 1. binaries which execute on target arch machine
Expand All @@ -135,6 +150,10 @@ endif(CMAKE_SYSTEM_NAME STREQUAL Windows)
if(CLR_CMAKE_HOST_UNIX_ARM)
set(CLR_CMAKE_HOST_ARCH_ARM 1)
set(CLR_CMAKE_HOST_ARCH "arm")

if(CLR_CMAKE_HOST_HOST_ARMV7L)
set(CLR_CMAKE_HOST_ARCH_ARMV7L 1)
endif()
elseif(CLR_CMAKE_HOST_UNIX_ARM64)
set(CLR_CMAKE_HOST_ARCH_ARM64 1)
set(CLR_CMAKE_HOST_ARCH "arm64")
Expand Down Expand Up @@ -206,6 +225,12 @@ if(CLR_CMAKE_TARGET_OS STREQUAL alpine)
set(CLR_CMAKE_TARGET_ALPINE_LINUX 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL alpine)

if(CLR_CMAKE_TARGET_OS STREQUAL android)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_LINUX 1)
set(CLR_CMAKE_TARGET_ANDROID 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL android)

if(CLR_CMAKE_TARGET_OS STREQUAL Darwin)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_DARWIN 1)
Expand Down
24 changes: 13 additions & 11 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ cmake_policy(SET CMP0042 NEW)
# Set the project name
project(CoreCLR)

include(${CLR_ENG_NATIVE_DIR}/configureplatform.cmake)

# Include cmake functions
include(${CLR_ENG_NATIVE_DIR}/functions.cmake)

if (WIN32)
if (CLR_CMAKE_TARGET_WIN32)
message(STATUS "VS_PLATFORM_TOOLSET is ${CMAKE_VS_PLATFORM_TOOLSET}")
message(STATUS "VS_PLATFORM_NAME is ${CMAKE_VS_PLATFORM_NAME}")
endif (WIN32)
endif (CLR_CMAKE_TARGET_WIN32)

# Set commonly used directory names
set(CLR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Expand All @@ -34,8 +36,8 @@ OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF)
OPTION(CLR_CMAKE_WARNINGS_ARE_ERRORS "Warnings are errors" ON)

# Ensure other tools are present
if (WIN32)
if(CLR_CMAKE_HOST_ARCH STREQUAL arm)
if (CLR_CMAKE_TARGET_WIN32)
if(CLR_CMAKE_TARGET_ARCH_ARM)

# Confirm that Windows SDK is present
if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
Expand All @@ -53,7 +55,7 @@ if (WIN32)
# Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
# use ml[64].exe as the assembler.
enable_language(ASM)
elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm64)
elseif(CLR_CMAKE_TARGET_ARCH_ARM64)

# Confirm that Windows SDK is present
if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
Expand Down Expand Up @@ -81,7 +83,7 @@ if (WIN32)
message(FATAL_ERROR "MC not found")
endif()

else (WIN32)
else (CLR_CMAKE_TARGET_WIN32)
enable_language(ASM)

# Ensure that awk is present
Expand All @@ -95,7 +97,7 @@ else (WIN32)
# to prevent applications to create executable memory mappings.
find_program(PAXCTL paxctl)

if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
if (CLR_CMAKE_HOST_DARWIN)

# Ensure that dsymutil and strip are present
find_program(DSYMUTIL dsymutil)
Expand All @@ -109,7 +111,7 @@ else (WIN32)
endif()

endif()
endif(WIN32)
endif(CLR_CMAKE_TARGET_WIN32)

#----------------------------------------------------
# Configure compiler settings for environment
Expand Down Expand Up @@ -146,7 +148,7 @@ add_subdirectory(src/pal/prebuilt/inc)

add_subdirectory(src/debug/debug-pal)

if(WIN32)
if(CLR_CMAKE_TARGET_WIN32)
add_subdirectory(src/gc/sample)
endif()

Expand All @@ -155,10 +157,10 @@ add_subdirectory(src/tools/crossgen2/jitinterface)
# Above projects do not build with these compile options
# All of the compiler options are specified in file compileoptions.cmake
# Do not add any new options here. They should be added in compileoptions.cmake
if(WIN32)
if(CLR_CMAKE_TARGET_WIN32)
add_compile_options(/FIWarningControl.h) # force include of WarningControl.h
add_compile_options(/Zl) # omit default library name in .OBJ
endif(WIN32)
endif(CLR_CMAKE_TARGET_WIN32)

#--------------------------------
# Definition directives
Expand Down
14 changes: 7 additions & 7 deletions src/coreclr/clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(PRERELEASE 1)

# Features we're currently flighting, but don't intend to ship in officially supported releases
if (PRERELEASE)
add_definitions(-DFEATURE_UTF8STRING)
add_definitions(-DFEATURE_UTF8STRING)
# add_definitions(-DFEATURE_XXX)
endif (PRERELEASE)

Expand All @@ -22,11 +22,11 @@ if (CLR_CMAKE_TARGET_ARCH_ARM64)
endif()
add_definitions(-DFEATURE_MULTIREG_RETURN)
elseif (CLR_CMAKE_TARGET_ARCH_ARM)
if (WIN32 AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
if (CLR_CMAKE_TARGET_WIN32 AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
# Set this to ensure we can use Arm SDK for Desktop binary linkage when doing native (Arm32) build
add_definitions(-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE)
add_definitions(-D_ARM_WORKAROUND_)
endif (WIN32 AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
endif (CLR_CMAKE_TARGET_WIN32 AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
add_definitions(-DFEATURE_EMULATE_SINGLESTEP)
endif (CLR_CMAKE_TARGET_ARCH_ARM64)

Expand Down Expand Up @@ -58,14 +58,14 @@ add_definitions(-DDEBUGGING_SUPPORTED)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>:PROFILING_SUPPORTED>)
add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>:PROFILING_SUPPORTED_DATA>)

if(WIN32)
if(CLR_CMAKE_TARGET_WIN32)
add_definitions(-DWIN32)
add_definitions(-D_WIN32)
add_definitions(-DWINVER=0x0602)
add_definitions(-D_WIN32_WINNT=0x0602)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(WIN32)
endif(CLR_CMAKE_TARGET_WIN32)
if(CLR_CMAKE_TARGET_WIN32)
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
# Only enable edit and continue on windows x86 and x64
Expand Down Expand Up @@ -134,9 +134,9 @@ if(CLR_CMAKE_TARGET_UNIX)
add_definitions(-DFEATURE_EVENTSOURCE_XPLAT)
endif(CLR_CMAKE_TARGET_UNIX)
# NetBSD doesn't implement this feature
if(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
if(NOT CLR_CMAKE_TARGET_NETBSD)
add_definitions(-DFEATURE_HIJACK)
endif(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
endif(NOT CLR_CMAKE_TARGET_NETBSD)
add_definitions(-DFEATURE_ICASTABLE)
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_ARM64))
add_definitions(-DFEATURE_INTEROP_DEBUGGING)
Expand Down
5 changes: 2 additions & 3 deletions src/coreclr/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ cmake_policy(SET CMP0083 NEW)

include(CheckCXXCompilerFlag)

include(${CLR_ENG_NATIVE_DIR}/configureplatform.cmake)
# "configureoptimization.cmake" must be included after CLR_CMAKE_HOST_UNIX has been set.
include(${CMAKE_CURRENT_LIST_DIR}/configureoptimization.cmake)

Expand Down Expand Up @@ -235,14 +234,14 @@ if (CLR_CMAKE_HOST_UNIX)
endif(CLR_CMAKE_HOST_NETBSD)
endif(CLR_CMAKE_HOST_UNIX)

if (WIN32)
if (CLR_CMAKE_TARGET_WIN32)
add_definitions(-DHOST_WINDOWS)

# Define the CRT lib references that link into Desktop imports
set(STATIC_MT_CRT_LIB "libcmt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
set(STATIC_MT_VCRT_LIB "libvcruntime$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
set(STATIC_MT_CPP_LIB "libcpmt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
endif(WIN32)
endif(CLR_CMAKE_TARGET_WIN32)

# Architecture specific files folder name
if (CLR_CMAKE_TARGET_ARCH_AMD64)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/configureoptimization.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if(WIN32)
if(CLR_CMAKE_TARGET_WIN32)
add_compile_options($<$<CONFIG:Debug>:/Od>)
add_compile_options($<$<CONFIG:Checked>:/O1>)
add_compile_options($<$<CONFIG:Release>:/Ox>)
Expand Down
20 changes: 10 additions & 10 deletions src/coreclr/pgosupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ check_ipo_supported(RESULT HAVE_LTO)

# Adds Profile Guided Optimization (PGO) flags to the current target
function(add_pgo TargetName)
if(WIN32)
if(CLR_CMAKE_TARGET_WIN32)
set(ProfileFileName "${TargetName}.pgd")
else(WIN32)
else(CLR_CMAKE_TARGET_WIN32)
set(ProfileFileName "${TargetName}.profdata")
endif(WIN32)
endif(CLR_CMAKE_TARGET_WIN32)

file(TO_NATIVE_PATH
"${CLR_CMAKE_OPTDATA_PATH}/data/${ProfileFileName}"
ProfilePath
)

if(CLR_CMAKE_PGO_INSTRUMENT)
if(WIN32)
if(CLR_CMAKE_TARGET_WIN32)
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELEASE " /LTCG /GENPROFILE")
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /LTCG /GENPROFILE")
else(WIN32)
else(CLR_CMAKE_TARGET_WIN32)
if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
target_compile_options(${TargetName} PRIVATE -flto -fprofile-instr-generate)
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -flto -fuse-ld=gold -fprofile-instr-generate")
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
endif(WIN32)
endif(CLR_CMAKE_TARGET_WIN32)
elseif(CLR_CMAKE_PGO_OPTIMIZE)
# If we don't have profile data availble, gracefully fall back to a non-PGO opt build
if(NOT EXISTS ${ProfilePath})
message("PGO data file NOT found: ${ProfilePath}")
else(NOT EXISTS ${ProfilePath})
if(WIN32)
if(CLR_CMAKE_TARGET_WIN32)
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELEASE " /LTCG /USEPROFILE:PGD=${ProfilePath}")
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /LTCG /USEPROFILE:PGD=${ProfilePath}")
else(WIN32)
else(CLR_CMAKE_TARGET_WIN32)
if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
if(HAVE_LTO)
Expand All @@ -45,7 +45,7 @@ function(add_pgo TargetName)
message(WARNING "PGO is not supported; Clang 3.6 or later is required for profile guided optimizations")
endif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
endif(WIN32)
endif(CLR_CMAKE_TARGET_WIN32)
endif(NOT EXISTS ${ProfilePath})
endif(CLR_CMAKE_PGO_INSTRUMENT)
endfunction(add_pgo)
6 changes: 3 additions & 3 deletions src/coreclr/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ include_directories("classlibnative/cryptography")
include_directories("classlibnative/inc")
include_directories("${GENERATED_INCLUDE_DIR}")

if(WIN32 AND FEATURE_EVENT_TRACE)
if(CLR_CMAKE_TARGET_WIN32 AND FEATURE_EVENT_TRACE)
include_directories("${GENERATED_INCLUDE_DIR}/etw")
endif(WIN32 AND FEATURE_EVENT_TRACE)
endif(CLR_CMAKE_TARGET_WIN32 AND FEATURE_EVENT_TRACE)


if(CLR_CMAKE_HOST_UNIX)
Expand Down Expand Up @@ -76,6 +76,6 @@ add_subdirectory(ilasm)

if(CLR_CMAKE_HOST_UNIX)
add_subdirectory(palrt)
elseif(WIN32)
elseif(CLR_CMAKE_TARGET_WIN32)
add_subdirectory(hosts)
endif(CLR_CMAKE_HOST_UNIX)
4 changes: 2 additions & 2 deletions src/coreclr/src/ToolBox/SOS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
if(WIN32)
if(CLR_CMAKE_TARGET_WIN32)
if (CMAKE_GENERATOR MATCHES "Visual Studio .*")
add_subdirectory(DacTableGen)
endif()
endif(WIN32)
endif(CLR_CMAKE_TARGET_WIN32)

_install(FILES SOS_README.md DESTINATION .)
_install(FILES SOS_README.md DESTINATION sharedFramework)
4 changes: 2 additions & 2 deletions src/coreclr/src/ToolBox/superpmi/mcs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ project(mcs)
add_definitions(-DFEATURE_NO_HOST)
add_definitions(-DSELF_NO_HOST)

if(WIN32)
if(CLR_CMAKE_TARGET_WIN32)
#use static crt
add_definitions(-MT)
endif(WIN32)
endif(CLR_CMAKE_TARGET_WIN32)

include_directories(.)
include_directories(../superpmi-shared)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ remove_definitions(-D_UNICODE)
add_definitions(-DFEATURE_NO_HOST)
add_definitions(-DSELF_NO_HOST)

if(WIN32)
if(CLR_CMAKE_TARGET_WIN32)
#use static crt
add_definitions(-MT)
endif(WIN32)
endif(CLR_CMAKE_TARGET_WIN32)

include_directories(.)
include_directories(../superpmi-shared)
Expand All @@ -35,11 +35,11 @@ set(SUPERPMI_SHIM_COLLECTOR_SOURCES
../superpmi-shared/typeutils.cpp
../superpmi-shared/spmidumphelper.cpp
)
if (WIN32)
if (CLR_CMAKE_TARGET_WIN32)
preprocess_file(${CMAKE_CURRENT_SOURCE_DIR}/superpmi-shim-collector.def ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-collector.def)

list(APPEND SUPERPMI_SHIM_COLLECTOR_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/superpmi-shim-collector.def)
endif (WIN32)
endif (CLR_CMAKE_TARGET_WIN32)

_add_library(superpmi-shim-collector
SHARED
Expand Down
Loading