diff --git a/CMakeLists.txt b/CMakeLists.txt index 712fb429e..6d1cbb4a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,25 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) message(FATAL_ERROR "g++ version must be at least 5.1!") endif() +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") + include_directories(BEFORE "/opt/intel/include") + add_definitions(-D__PURE_INTEL_C99_HEADERS__) + link_directories(BEFORE "/opt/intel/lib") + if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 17) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)) + # locate best gcc version to pass to icc-18 (gcc-8 doesn't work, for example) + # Use -DICC_GCCVER=6 for example to force 'gcc-6' and 'g++-6' + # Otherwise, the newest available and compatible pair will be selected + find_program(ICC_GXX NAMES "g++-${ICC_GCCVER}" "g++-7" "g++-6" "g++") + get_filename_component(ICC_GXX ${ICC_GXX} NAME) + find_program(ICC_GCC NAMES "gcc-${ICC_GCCVER}" "gcc-7" "gcc-6" "gcc") + get_filename_component(ICC_GCC ${ICC_GCC} NAME) + set(ICC_COMPILERS "-gxx-name=${ICC_GXX} -gcc-name=${ICC_GCC}") + unset(ICC_GXX) + unset(ICC_GCC) + endif() + message(STATUS "Intel ICC-18 subcompiler flags: ${ICC_COMPILERS}") + set(CMAKE_CXX_FLAGS "-O3 -no-prec-div -fp-model fast=2 -std=gnu++11 ${ICC_COMPILERS}") + set(CMAKE_C_FLAGS "-O3 -no-prec-div -fp-model fast=2 -std=gnu99 ${ICC_COMPILERS}") endif() set(BUILD_TYPE "Release;Debug") @@ -39,7 +58,11 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${BUILD_TYPE}") set(XMR-STAK_COMPILE "native" CACHE STRING "select CPU compute architecture") set_property(CACHE XMR-STAK_COMPILE PROPERTY STRINGS "native;generic") if(XMR-STAK_COMPILE STREQUAL "native") - if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + if(CMAKE_CXX_COMPILER_ID MATCHES "Intel") + # activate Intel Compiler options: optimize for current host CPU + set(CMAKE_CXX_FLAGS "-xHOST ${CMAKE_CXX_FLAGS}") + set(CMAKE_C_FLAGS "-xHOST ${CMAKE_C_FLAGS}") + elseif(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(CMAKE_CXX_FLAGS "-march=native -mtune=native ${CMAKE_CXX_FLAGS}") set(CMAKE_C_FLAGS "-march=native -mtune=native ${CMAKE_C_FLAGS}") endif() @@ -429,7 +452,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") add_definitions(-D_CRT_SECURE_NO_DEPRECATE) # disable min define to allow usage of std::min add_definitions(-DNOMINMAX) -else() +elseif(NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel") # activate sse2 and aes-ni set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -maes") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -maes") @@ -450,6 +473,8 @@ if(CMAKE_LINK_STATIC) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "GNU") set(LIBS "-static-libgcc -static-libstdc++ ${LIBS}") + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") + set(LIBS "-static-libgcc -static-libstdc++ -static-intel ${LIBS}") endif() endif()