summaryrefslogtreecommitdiff
path: root/configurecompiler.cmake
diff options
context:
space:
mode:
authorJeremy Koritzinsky <jkoritzinsky@gmail.com>2019-05-29 21:40:31 (GMT)
committerGitHub <noreply@github.com>2019-05-29 21:40:31 (GMT)
commit38f121b06910b25080b5f3259152effc0fe3c672 (patch)
treead313488576479428681f18678be4b3f7962735f /configurecompiler.cmake
parent3ac776125f4b9182de05abb1daccb98221509cc1 (diff)
downloadcoreclr-38f121b06910b25080b5f3259152effc0fe3c672.zip
coreclr-38f121b06910b25080b5f3259152effc0fe3c672.tar.gz
coreclr-38f121b06910b25080b5f3259152effc0fe3c672.tar.bz2
Refactor native build to remove the compiler-override files (#23897)
* On systems that have both cmake 2 and cmake 3, use cmake 3. Move CMAKE_EXPORT_COMPILE_COMMANDS to top level instead of in gen-buildsys-*. Define the CMake install prefix in gen-buildsys-* instead of pulling from an environment variable. Define C++ standard as CMake property instead of as flag. Move CLR_DEFINES_*_INIT out of overrides and into configurecompiler.cmake Move flags that generate debug info into configurecompiler.cmake Remove the CMAKE_USER_RULES_OVERRIDE files. Add cmake version output for determining what cmake versions each CI system has. Fix syntax in gen-buildsys-clang. Change add_compile_definitions back to add_definitions Add -D prefix for adding definitions via add_definitions Remove extraneous double-quote Change default config definition adding to the syntax in master Switch back to old CMAKE_<LANG>_FLAGS way of setting the language standards and try to go back to 2.8.12 minimum Switch back setting compile definitions for non-Windows branch too. Use SET with CMAKE_<LANG>_FLAGS. Convert some usages of appending to CMAKE_<LANG>_FLAGS to add_compile_options where possible. Set CMAKE_<LANG>_FLAGS_INIT instead of CMAKE_<LANG>_FLAGS Make sure configureopimitzation.cmake is included correctly in test build. Try to add brackets to get the Linux ARM compilation working correctly. Define standard language version in configurecompiler.cmake instead of root CMakeLists (so tests get it) Try to move langauge standard check to configure.cmake define language standard in each root CMakeLists.txt Fix off-Windows test build. Set CMAKE_EXPORT_COMPILE_COMMANDS after the project() call * Set CMAKE_USER_MAKE_RULES_OVERRIDE to "" to not break incremental builds after building on a branch that had it set to a path. * Remove CMake version output. * Move comment outside of multiline command. * Retry setting CMAKE_USER_MAKE_RULES_OVERRIDE * Remove unnecessary variable wrappers. * Simplify cmake 3 resolution. * Explicitly use CMAKE_CXX_FLAGS for C++-only flags that GCC complains about on C files. * Set -Wall via CMAKE_<LANG>_FLAGS until we can move all flag settings to add_compile_options * Fix typos * Another temporary precedence issue. * include configureoptimization.cmake in configurecompiler.cmake * Move setting CMAKE_EXPORT_COMPILE_COMMANDS to configurecompiler.cmake. * Rename configure.cmake -> verify_lto.cmake. * Fix path to verify-lto * Try using CMAKE_<LANG>_FLAGS instead of CMAKE_<LANG>_FLAGS_INIT. * Revert name change to configure.camek
Diffstat (limited to 'configurecompiler.cmake')
-rw-r--r--configurecompiler.cmake32
1 files changed, 29 insertions, 3 deletions
diff --git a/configurecompiler.cmake b/configurecompiler.cmake
index 38d8d43..5b6d767 100644
--- a/configurecompiler.cmake
+++ b/configurecompiler.cmake
@@ -1,3 +1,12 @@
+# Set initial flags for each configuration
+
+set(CMAKE_EXPORT_COMPILE_COMMANDS 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)
+set(CLR_DEFINES_RELEASE_INIT NDEBUG URTBLDENV_FRIENDLY=Retail)
+set(CLR_DEFINES_RELWITHDEBINFO_INIT NDEBUG URTBLDENV_FRIENDLY=Retail)
+
#----------------------------------------
# Detect and set platform variable names
# - for non-windows build platform & architecture is detected using inbuilt CMAKE variables and cross target component configure
@@ -174,12 +183,27 @@ endif()
# Initialize Cmake compiler flags and other variables
#-----------------------------------------------------
+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(-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")
+ endif()
+endif()
+
if (CMAKE_CONFIGURATION_TYPES) # multi-configuration generator?
set(CMAKE_CONFIGURATION_TYPES "Debug;Checked;Release;RelWithDebInfo" CACHE STRING "" FORCE)
endif (CMAKE_CONFIGURATION_TYPES)
-set(CMAKE_C_FLAGS_CHECKED ${CLR_C_FLAGS_CHECKED_INIT} CACHE STRING "Flags used by the compiler during checked builds.")
-set(CMAKE_CXX_FLAGS_CHECKED ${CLR_CXX_FLAGS_CHECKED_INIT} CACHE STRING "Flags used by the compiler during checked builds.")
+set(CMAKE_C_FLAGS_CHECKED "")
+set(CMAKE_CXX_FLAGS_CHECKED "")
set(CMAKE_EXE_LINKER_FLAGS_CHECKED "")
set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "")
@@ -263,7 +287,7 @@ elseif (CLR_CMAKE_PLATFORM_UNIX)
# set the different configuration defines.
if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
# First DEBUG
- set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_DEBUG_INIT})
+ set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_DEBUG_INIT})
elseif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
# Then CHECKED
set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_CHECKED_INIT})
@@ -604,3 +628,5 @@ if(CLR_CMAKE_ENABLE_CODE_COVERAGE)
endif(CLR_CMAKE_PLATFORM_UNIX)
endif(CLR_CMAKE_ENABLE_CODE_COVERAGE)
+
+include(${CMAKE_CURRENT_LIST_DIR}/configureoptimization.cmake)