5

The Intel C/C++ has a bunch of custom flags, some of which mix compilation and linking, (such as -qopenmp), and others are just idiosyncratic alternative forms (such as -ipp for linking with Intel's ipp libraries).

I can add such flags "manually" to the compiler flags, and ignore the fact they may have linking implications; or add them both to the compilation and linking flags. But both of these alternatives seem "off". How do I properly work with the various ICC-specific flags in CMake?

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • Cmake is supposed to be for cross platform projects and such compiler specific options do not "belong" in the cmakelists ;-). Have you considered a toolchain file instead? – André Jan 02 '22 at 15:29
  • @André: 1. What is a "toolchain file"? 2. I realize that CMake is cross-platform, but it does have some facilities which translate into compiler-specific options, e.g. `CMAKE_CXX_STANDARD` and friends which pass different things to MSVC and GCC/clang. I thought maybe there was something similar - even a module - for these kinds of options. – einpoklum Jan 02 '22 at 16:09
  • Hence the ;-). https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html. It is intended for cross compilation, but I have used it succesfully in the past on compute clusters, supercomputers, etc. to specify hardware specific flags. – André Jan 02 '22 at 16:33
  • @André: It looks like those files are simply a bunch of CMake commands, most of which I already know. I don't quite see how that would help me. Or - are you saying that if I put the custom icc junk in a toolchain file it's somehow more legitimate? – einpoklum Jan 02 '22 at 16:58

1 Answers1

0

First looking at: https://cmake.org/cmake/help/latest/release/3.20.html#compilers

The Intel oneAPI NextGen LLVM compilers are now supported with compiler id IntelLLVM:
The icx/icpx C/C++ compilers on Linux, and the icx C/C++ compiler on Windows, are fully supported as of oneAPI 2021.1.
The ifx Fortran compiler on Linux is supported as of oneAPI 2021.1.
The ifx Fortran compiler on Windows is not yet supported.
The Intel oneAPI Classic compilers (icc, icpc, and ifort) continue to be supported with compiler id Intel.

So If i were you I would use the compiler id Intel to pass icc scpecific flags.
ref: https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html

if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
  add_compile_definitions(...) # CMake 3.12
  add_compile_options(...)
  add_link_options(...) # CMake 3.13
endif()

ref:

Mizux
  • 8,222
  • 7
  • 32
  • 48