Skip to content

Commit

Permalink
Adds a new compiler family MSVC_INTEL.
Browse files Browse the repository at this point in the history
This enables using the Intel compiler toolchain within Visual Studio.

Also updates the blt_append_compiler_flag() macro to accept the MSVC_INTEL
keyword.  When provided, it will override the MSVC keyword within Visual
Studio configurations of blt.
  • Loading branch information
kennyweiss committed Nov 1, 2017
1 parent 5e48a11 commit 3501d27
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
25 changes: 15 additions & 10 deletions cmake/BLTMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -617,24 +617,27 @@ endmacro(blt_add_benchmark)

##------------------------------------------------------------------------------
## blt_append_custom_compiler_flag(
## FLAGS_VAR flagsVar (required)
## DEFAULT defaultFlag (optional)
## GNU gnuFlag (optional)
## CLANG clangFlag (optional)
## INTEL intelFlag (optional)
## XL xlFlag (optional)
## MSVC msvcFlag (optional)
## FLAGS_VAR flagsVar (required)
## DEFAULT defaultFlag (optional)
## GNU gnuFlag (optional)
## CLANG clangFlag (optional)
## INTEL intelFlag (optional)
## XL xlFlag (optional)
## MSVC msvcFlag (optional)
## MSVC_INTEL msvcIntelFlag (optional)
## )
##
## Appends compiler-specific flags to a given variable of flags
##
## If a custom flag is given for the current compiler, we use that,
## If a custom flag is given for the current compiler, we use that.
## Otherwise, we will use the DEFAULT flag (if present)
## When using the Intel toolchain within visual studio, we use the
## MSVC_INTEL flag, when provided, with a fallback to the MSVC flag.
##------------------------------------------------------------------------------
macro(blt_append_custom_compiler_flag)

set(options)
set(singleValueArgs FLAGS_VAR DEFAULT GNU CLANG INTEL XL MSVC)
set(singleValueArgs FLAGS_VAR DEFAULT GNU CLANG INTEL XL MSVC MSVC_INTEL)
set(multiValueArgs)

# Parse the arguments
Expand All @@ -655,7 +658,9 @@ macro(blt_append_custom_compiler_flag)
set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_INTEL} " )
elseif( DEFINED arg_GNU AND COMPILER_FAMILY_IS_GNU )
set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_GNU} " )
elseif( DEFINED arg_MSVC AND COMPILER_FAMILY_IS_MSVC )
elseif( DEFINED arg_MSVC_INTEL AND COMPILER_FAMILY_IS_MSVC_INTEL )
set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_MSVC_INTEL} " )
elseif( DEFINED arg_MSVC AND (COMPILER_FAMILY_IS_MSVC OR COMPILER_FAMILY_IS_MSVC_INTEL) )
set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_MSVC} " )
elseif( DEFINED arg_DEFAULT )
set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_DEFAULT} ")
Expand Down
31 changes: 19 additions & 12 deletions cmake/SetupCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ endif()
if("${CMAKE_BUILD_TOOL}" MATCHES "(msdev|devenv|nmake|MSBuild)")
set(COMPILER_FAMILY_IS_MSVC 1)
message(STATUS "Compiler family is MSVC")


if(CMAKE_GENERATOR_TOOLSET AND "${CMAKE_GENERATOR_TOOLSET}" MATCHES "Intel")
set(COMPILER_FAMILY_IS_MSVC_INTEL 1)
message(STATUS "Toolset is ${CMAKE_GENERATOR_TOOLSET}")
endif()

elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(COMPILER_FAMILY_IS_GNU 1)
message(STATUS "Compiler family is GNU")
Expand All @@ -92,6 +97,8 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
endif()




################################################
# Support for extra compiler flags and defines
################################################
Expand Down Expand Up @@ -263,17 +270,17 @@ message(STATUS "Standard C++${CMAKE_CXX_STANDARD} selected")

blt_append_custom_compiler_flag(
FLAGS_VAR BLT_ENABLE_ALL_WARNINGS_FLAG
DEFAULT "-Wall -Wextra"
CLANG "-Wall -Wextra"
# Additional possibilities for clang include:
# "-Wdocumentation -Wdeprecated -Weverything"
MSVC "/W4"
# Additional possibilities for visual studio include:
# "/Wall /wd4619 /wd4668 /wd4820 /wd4571 /wd4710"
XL "" # qinfo=<grp> produces additional messages on XL
# qflag=<x>:<x> defines min severity level to produce messages on XL
# where x is i info, w warning, e error, s severe; default is:
# (default is qflag=i:i)
DEFAULT "-Wall -Wextra"
CLANG "-Wall -Wextra"
# Additional possibilities for clang include:
# "-Wdocumentation -Wdeprecated -Weverything"
MSVC "/W4"
# Additional possibilities for visual studio include:
# "/Wall /wd4619 /wd4668 /wd4820 /wd4571 /wd4710"
XL "" # qinfo=<grp> produces additional messages on XL
# qflag=<x>:<x> defines min severity level to produce messages on XL
# where x is i info, w warning, e error, s severe; default is:
# (default is qflag=i:i)
)

blt_append_custom_compiler_flag(
Expand Down

0 comments on commit 3501d27

Please sign in to comment.