From 64e8e02f54f7e4225f05fec41edff8f64f57783c Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Thu, 28 Jul 2016 10:35:21 +0200 Subject: [PATCH] cmake: add Intel's ICC compiler support Full of compilations errors and warnings --- build.sh | 14 +++++++++++++- cmake/BuildParameters.cmake | 30 ++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index 467f0742eb..403d522864 100755 --- a/build.sh +++ b/build.sh @@ -20,6 +20,7 @@ flags=(-DCMAKE_BUILD_PO=FALSE) cleanBuild=0 useClang=0 +useIcc=0 # 0 => no, 1 => yes, 2 => force yes useCross=2 CoverityBuild=0 @@ -52,6 +53,7 @@ for ARG in "$@"; do --clean ) cleanBuild=1 ;; --clang-tidy ) flags+=(-DCMAKE_EXPORT_COMPILE_COMMANDS=ON); clangTidy=1 ;; --clang ) useClang=1 ;; + --intel ) useIcc=1 ;; --cppcheck ) cppcheck=1 ;; --dev|--devel ) flags+=(-DCMAKE_BUILD_TYPE=Devel) build="$root/build_dev";; --dbg|--debug ) flags+=(-DCMAKE_BUILD_TYPE=Debug) build="$root/build_dbg";; @@ -94,6 +96,7 @@ for ARG in "$@"; do echo "--gtk3 : replace GTK2 by GTK3" echo "--no-cross-multilib: Build a native PCSX2" echo "--clang : Build with Clang/llvm" + echo "--intel : Build with ICC (Intel compiler)" echo echo "** Quality & Assurance (Please install the external tool) **" echo "--asan : Enable Address sanitizer" @@ -145,7 +148,16 @@ if [[ "$useClang" -eq 1 ]]; then CC="clang -m32" CXX="clang++ -m32" cmake "${flags[@]}" "$root" 2>&1 | tee -a "$log" fi else - cmake "${flags[@]}" "$root" 2>&1 | tee -a "$log" + if [[ "$useIcc" -eq 1 ]]; then + if [[ "$useCross" -eq 0 ]]; then + CC="icc" CXX="icpc" cmake "${flags[@]}" "$root" 2>&1 | tee -a "$log" + else + CC="icc -m32" CXX="icpc -m32" cmake "${flags[@]}" "$root" 2>&1 | tee -a "$log" + fi + else + # Default compiler AKA GCC + cmake "${flags[@]}" "$root" 2>&1 | tee -a "$log" + fi fi diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index e45e3b0418..19fd664123 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -81,6 +81,14 @@ option(USE_ASAN "Enable address sanitizer") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(USE_CLANG TRUE) message(STATUS "Building with Clang/LLVM.") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set(USE_ICC TRUE) + message(STATUS "Building with Intel's ICC.") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(USE_GCC TRUE) + message(STATUS "Building with GNU GCC") +else() + message(FATAL_ERROR "Unknow compiler: ${CMAKE_CXX_COMPILER_ID}") endif() #------------------------------------------------------------------------------- @@ -291,15 +299,25 @@ set(HARDENING_FLAG "-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security") # -Wno-unused-function: warn for function not used in release build # -Wno-unused-variable: just annoying to manage different level of logging, a couple of extra var won't kill any serious compiler. # -Wno-unused-value: lots of warning for this kind of statements "0 && ...". There are used to disable some parts of code in release/dev build. -set(DEFAULT_WARNINGS "-Wall -Wno-attributes -Wno-missing-field-initializers -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-unused-value ") +set(DEFAULT_WARNINGS "-Wall -Wno-attributes -Wno-missing-field-initializers -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable ") +if (NOT USE_ICC) + set(DEFAULT_WARNINGS "${DEFAULT_WARNINGS} -Wno-unused-value ") +endif() + # -Wstrict-aliasing=n: to fix one day aliasing issue. n=1/2/3 -set(AGGRESSIVE_WARNING "-Wstrict-aliasing -Wstrict-overflow=2 ") +if (USE_ICC) + set(AGGRESSIVE_WARNING "-Wstrict-aliasing ") +else() + set(AGGRESSIVE_WARNING "-Wstrict-aliasing -Wstrict-overflow=2 ") +endif() if (USE_CLANG) # -Wno-deprecated-register: glib issue... set(DEFAULT_WARNINGS "${DEFAULT_WARNINGS} -Wno-deprecated-register -Wno-c++14-extensions") set(DBG "-g -fno-omit-frame-pointer") -else() +elseif (USE_ICC) + set(DBG "-g -fno-omit-frame-pointer") +elseif (USE_GCC) set(DBG "-ggdb3 -fno-omit-frame-pointer") endif() @@ -334,10 +352,10 @@ endif() if(NOT DEFINED OPTIMIZATION_FLAG) if (CMAKE_BUILD_TYPE STREQUAL Debug) - if (USE_CLANG) - set(OPTIMIZATION_FLAG -O0) - else() + if (USE_GCC) set(OPTIMIZATION_FLAG -Og) + else() + set(OPTIMIZATION_FLAG -O0) endif() else() set(OPTIMIZATION_FLAG -O2)