summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt11
-rw-r--r--configurecompiler.cmake27
-rw-r--r--configureoptimization.cmake2
-rw-r--r--src/ToolBox/SOS/Strike/CMakeLists.txt4
-rw-r--r--src/ToolBox/SOS/lldbplugin/CMakeLists.txt2
-rw-r--r--src/dlls/mscorpe/CMakeLists.txt2
-rw-r--r--src/ilasm/CMakeLists.txt2
-rw-r--r--src/inc/CMakeLists.txt2
-rw-r--r--src/jit/CMakeLists.txt2
-rw-r--r--src/pal/src/libunwind/src/CMakeLists.txt6
-rw-r--r--src/pal/tests/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/CMakeLists.txt4
-rw-r--r--tests/CMakeLists.txt9
13 files changed, 31 insertions, 44 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ca5a69b544..ab5c441785 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,14 +1,7 @@
# Verify minimum required version
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.5.1)
-if(CMAKE_VERSION VERSION_EQUAL 3.0 OR CMAKE_VERSION VERSION_GREATER 3.0)
- cmake_policy(SET CMP0042 NEW)
-endif()
-
-if (NOT WIN32)
- set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -std=c++11" CACHE STRING "Flags used by the compiler during all build types.")
- set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -std=c11" CACHE STRING "Flags used by the compiler during all build types.")
-endif()
+cmake_policy(SET CMP0042 NEW)
# Set the project name
project(CoreCLR)
diff --git a/configurecompiler.cmake b/configurecompiler.cmake
index a8a8ffcd62..a5e44bbc4e 100644
--- a/configurecompiler.cmake
+++ b/configurecompiler.cmake
@@ -1,6 +1,10 @@
# Set initial flags for each configuration
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_C_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CLR_DEFINES_DEBUG_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
set(CLR_DEFINES_CHECKED_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
@@ -73,11 +77,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(CLR_CMAKE_PLATFORM_UNIX 1)
set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
set(CLR_CMAKE_PLATFORM_DARWIN 1)
- if(CMAKE_VERSION VERSION_LESS "3.4.0")
- set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> -o <OBJECT> -c <SOURCE>")
- else()
- set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
- endif(CMAKE_VERSION VERSION_LESS "3.4.0")
+ set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
@@ -189,14 +189,11 @@ if(WIN32)
add_compile_options(/Zi /FC /Zc:strictStrings)
elseif (CLR_CMAKE_PLATFORM_UNIX)
add_compile_options(-g)
- # We need to add -Wall to CMAKE_<LANG>_FLAGS since add_compile_options takes precedence
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ add_compile_options(-Wall)
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-null-conversion)
else()
- # We need to add -Werror=conversion-null to CMAKE_<LANG>_FLAGS since add_compile_options takes precedence
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=conversion-null")
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror=conversion-null>)
endif()
endif()
@@ -479,9 +476,9 @@ if (CLR_CMAKE_PLATFORM_UNIX)
add_compile_options(-Wno-unused-function)
#These seem to indicate real issues
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof")
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-invalid-offsetof>)
- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop
# after hitting just about 20 errors.
add_compile_options(-ferror-limit=4096)
@@ -515,7 +512,7 @@ if (CLR_CMAKE_PLATFORM_UNIX)
add_compile_options(-Wno-nonnull-compare)
endif()
if (COMPILER_SUPPORTS_F_ALIGNED_NEW)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new")
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-faligned-new>)
endif()
endif()
@@ -595,7 +592,7 @@ if (WIN32)
# enable control-flow-guard support for native components for non-Arm64 builds
# Added using variables instead of add_compile_options to let individual projects override it
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /guard:cf")
- set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} /guard:cf")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf")
# Statically linked CRT (libcmt[d].lib, libvcruntime[d].lib and libucrt[d].lib) by default. This is done to avoid
# linking in VCRUNTIME140.DLL for a simplified xcopy experience by reducing the dependency on VC REDIST.
diff --git a/configureoptimization.cmake b/configureoptimization.cmake
index ad9f4a4907..dd26849a1b 100644
--- a/configureoptimization.cmake
+++ b/configureoptimization.cmake
@@ -6,7 +6,7 @@ if(WIN32)
elseif(CLR_CMAKE_PLATFORM_UNIX)
set(CLR_CMAKE_ARM_OPTIMIZATION_FALLBACK OFF)
if(CLR_CMAKE_TARGET_ARCH STREQUAL "arm" OR CLR_CMAKE_TARGET_ARCH STREQUAL "armel")
- if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.9))
+ if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.9))
set(CLR_CMAKE_ARM_OPTIMIZATION_FALLBACK ON)
endif()
endif()
diff --git a/src/ToolBox/SOS/Strike/CMakeLists.txt b/src/ToolBox/SOS/Strike/CMakeLists.txt
index 8e0218a341..7047e3291c 100644
--- a/src/ToolBox/SOS/Strike/CMakeLists.txt
+++ b/src/ToolBox/SOS/Strike/CMakeLists.txt
@@ -106,10 +106,10 @@ if(WIN32)
)
else(WIN32)
add_definitions(-DPAL_STDCPP_COMPAT=1)
- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-null-arithmetic)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion-null")
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-conversion-null>)
add_compile_options(-Wno-pointer-arith)
endif()
add_compile_options(-Wno-format)
diff --git a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt
index 0e4d40a706..2b65f52cba 100644
--- a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt
+++ b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt
@@ -124,7 +124,7 @@ endif()
message(STATUS "LLDB_H: ${LLDB_H}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
+add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-delete-non-virtual-dtor>)
include_directories(inc)
include_directories("${LLDB_H}")
diff --git a/src/dlls/mscorpe/CMakeLists.txt b/src/dlls/mscorpe/CMakeLists.txt
index 43deb47ec9..6a8919326b 100644
--- a/src/dlls/mscorpe/CMakeLists.txt
+++ b/src/dlls/mscorpe/CMakeLists.txt
@@ -10,7 +10,7 @@ set(MSCORPE_SOURCES
)
if(NOT WIN32)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-delete-non-virtual-dtor>)
endif()
add_library_clr(mscorpe STATIC
diff --git a/src/ilasm/CMakeLists.txt b/src/ilasm/CMakeLists.txt
index 3d1a74dae6..f780dcae11 100644
--- a/src/ilasm/CMakeLists.txt
+++ b/src/ilasm/CMakeLists.txt
@@ -51,7 +51,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
# Need generate a right form of asmparse.cpp to avoid the following options.
# Clang also produces a bad-codegen on this prebuilt file with optimization.
# https://github.com/dotnet/coreclr/issues/2305
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor -Wno-register")
+ add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wno-delete-non-virtual-dtor;-Wno-register>")
add_compile_options(-Wno-array-bounds)
add_compile_options(-Wno-unused-label)
set_source_files_properties( prebuilt/asmparse.cpp PROPERTIES COMPILE_FLAGS "-O0" )
diff --git a/src/inc/CMakeLists.txt b/src/inc/CMakeLists.txt
index 517ea8e0f4..c38d59587a 100644
--- a/src/inc/CMakeLists.txt
+++ b/src/inc/CMakeLists.txt
@@ -49,7 +49,7 @@ else()
# The prebuilt files contain extra '!_MIDL_USE_GUIDDEF_' after the #endif, but not in the comment.
# In order to not to have to modify these prebuilt files, we disable the extra tokens warning.
-if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-extra-tokens)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-endif-labels)
diff --git a/src/jit/CMakeLists.txt b/src/jit/CMakeLists.txt
index 5e7c9c50d2..8a3475605b 100644
--- a/src/jit/CMakeLists.txt
+++ b/src/jit/CMakeLists.txt
@@ -4,7 +4,7 @@ include_directories("./jitstd")
include_directories("../inc")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fpermissive>)
add_compile_options(-Wno-error)
endif()
diff --git a/src/pal/src/libunwind/src/CMakeLists.txt b/src/pal/src/libunwind/src/CMakeLists.txt
index b29e7ee9a2..93b4daf3a6 100644
--- a/src/pal/src/libunwind/src/CMakeLists.txt
+++ b/src/pal/src/libunwind/src/CMakeLists.txt
@@ -22,7 +22,7 @@ add_definitions("-Ddwarf_search_unwind_table_int=UNW_OBJ(dwarf_search_unwind_tab
# Disable warning due to incorrect format specifier in debugging printf via the Debug macro
add_compile_options(-Wno-format)
-if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-header-guard)
elseif()
add_compile_options(-Wno-unused-value)
@@ -33,7 +33,7 @@ if(CLR_CMAKE_PLATFORM_ARCH_ARM)
add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)")
# Disable warning in asm: use of SP or PC in the list is deprecated
add_compile_options(-Wno-inline-asm)
- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Disable warning due to labs function called on unsigned argument
add_compile_options(-Wno-absolute-value)
endif()
@@ -48,7 +48,7 @@ if(CLR_CMAKE_PLATFORM_ARCH_ARM)
# the include/tdep-arm to include directories
include_directories(../include/tdep-arm)
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Disable warning due to labs function called on unsigned argument
add_compile_options(-Wno-absolute-value)
endif()
diff --git a/src/pal/tests/CMakeLists.txt b/src/pal/tests/CMakeLists.txt
index 5597922f72..0ec630df8c 100644
--- a/src/pal/tests/CMakeLists.txt
+++ b/src/pal/tests/CMakeLists.txt
@@ -32,7 +32,7 @@ endif()
# C++ emits errors and warnings for c-string literal fed into char* parameter
# this is just to take care of the warnings
-if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-writable-strings)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-write-strings)
diff --git a/src/pal/tests/palsuite/CMakeLists.txt b/src/pal/tests/palsuite/CMakeLists.txt
index 6726165caf..00a4301784 100644
--- a/src/pal/tests/palsuite/CMakeLists.txt
+++ b/src/pal/tests/palsuite/CMakeLists.txt
@@ -14,13 +14,13 @@ endif()
list(APPEND COMMON_TEST_LIBRARIES coreclrpal)
-if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers)
add_compile_options(-Wno-int-to-void-pointer-cast)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-sign-compare)
add_compile_options(-Wno-narrowing)
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive" )
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fpermissive>)
add_compile_options(-Wno-int-to-pointer-cast)
endif()
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 54ea1ec953..937ecd30cc 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,10 +1,7 @@
-# Require at least version 2.8.12 of CMake
-cmake_minimum_required(VERSION 2.8.12)
+# Require at least version 3.5.1 of CMake
+cmake_minimum_required(VERSION 3.5.1)
-if (NOT WIN32)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
-endif()
+cmake_policy(SET CMP0042 NEW)
set(INC_PLATFORM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Common/Platform)
if (WIN32)