summaryrefslogtreecommitdiff
path: root/configurecompiler.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'configurecompiler.cmake')
-rw-r--r--configurecompiler.cmake27
1 files changed, 12 insertions, 15 deletions
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.