Commit Graph

89 Commits

Author SHA1 Message Date
Keno Fischer
3cff031c9a FindOpenMP: Handle non-Apple clang on macOS
I was noticing that FindOpenMP was failing to find my openmp installation
on macos when building with a custom-compiled clang. Upon inspection it
appears that FindOpenMP is looking for `AppleClang` as a compiler
identification and the `Clang` case is only applicable for Win32.
Try to fix that by treating custom `Clang` on macos the same as
`AppleClang`.
2023-09-24 19:28:58 +02:00
Brad King
56ff12501f FindOpenMP: Keep flags together in imported target usage requirements
If `OpenMP_C_FLAGS` contains `-Xclang -fopenmp`, the flag pair needs to
be preserved as a shell command fragment, and must not be split by
de-duplication with other `target_compile_options`.

Fixes: #24966
2023-06-01 15:18:33 -04:00
Andrey Alekseenko
6e53d74147 FindOpenMP: Use OpenMP_<lang>_INCLUDE_DIR
If `OpenMP_<lang>_INCLUDE_DIR` is defined, add it to the list of include
directories before checking flags. Previously, this variable was
ignored for all compilers but AppleClang, despite the documentation
mentioning it as one of the possible inputs.

Fixes: #24260
2023-01-23 19:37:26 +01:00
Brad King
f6ed2585e5 Modules: Record system inspection steps in the configure log
Replace old-style `file(APPEND .../CMake{Output,Error}.log)` logging
with calls to `message(CONFIGURE_LOG)` to record the steps in the
`CMakeConfigureLog.yaml` configure log instead.

Issue: #23200
2023-01-18 17:59:10 -05:00
Brad King
0f688386ea Modules: Drop redundant check logging to CMakeOutput.log and CMakeError.log
`try_compile` and `try_run` now automatically log checks using them to
`CMakeConfigureLog.yaml`.

Add `LOG_DESCRIPTION` arguments to some `try_compile` calls to
replace the description previously written to the old logs.

Issue: #23200
2023-01-18 16:41:01 -05:00
Matthew Woehlke
41f7b1169a Modules: Use new SOURCES_FROM_* try_compile (2/2)
Modify some additional modules that ship with CMake to use the new
SOURCES_FROM_* arguments to try_compile / try_run as added by commits
cb14ae2b87 (try_compile: Add SOURCE_FROM_{ARG,VAR}, 2022-09-21) and
611d801790 (try_compile: Add SOURCE_FROM_FILE, 2022-09-22). This covers
modules that need to read and alter a template source file, which were
not addressed in the previous commit.

Note that FindOpenACC.cmake does not actually need configure_file
functionality; it appears to have inherited the (gratuitous) use thereof
from FindOpenMP.cmake, with which its code bears significant similarity.
2022-09-27 13:29:52 -04:00
Matthew Woehlke
2edf0fc6d7 Modules: Use new keyword-dispatched try_compile signature
Modify most of the modules that ship with CMake to use the new
try_compile / try_run signatures added by commit aa9220d3a0
(try_compile: Add keyword-dispatched signature, 2022-09-02). This
improves debugging by each invocation using its own directory so that
the results of multiple invocations can be retained.

This does not cover any invocations which provide an entire project, as
that flavor of try_compile has not yet been updated.
2022-09-14 07:52:16 -04:00
Brad King
138337f53c Merge topic 'implicit-link-info-msvc'
93f2cd5b7c CMakeParseImplicitLinkInfo: Better detection of msvc

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7619
2022-09-06 09:02:05 -04:00
Robert Maynard
93f2cd5b7c CMakeParseImplicitLinkInfo: Better detection of msvc
Use the compiler id information in addition to checking for `cl.exe`.
2022-09-02 08:04:39 -04:00
Brad King
52dec3f11f Merge topic 'enable-intel-llvm-ipo-3'
c633bd76d8 Add linker prefix for "-stack" flag on MSVC builds
6823db0c5a Enable IPO for IntelLLVM compilers on Linux and Windows
adbffd204d Propagate OpenMP compiler flags to linker for IntelLLVM
3640842df2 Tests: Update ModuleDefinition for IntelLLVM MSVC Frontend Variant
5d5a712303 IntelLLVM: Pass linker flags to the compiler when used as linker

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7533
2022-08-04 09:37:47 -04:00
William R. Dieter
adbffd204d Propagate OpenMP compiler flags to linker for IntelLLVM
When compiling for offload and in general when OpenMP is enabled while
compiling, it should also be enabled when linking.

Signed-off-by: William R. Dieter <william.r.dieter@intel.com>
2022-08-01 19:34:49 -04:00
Sprite
09b4e870a5 FindOpenMP: Restore searching system paths
In commit 98314d536e (FindOpenMP: Use NO_DEFAULT_PATH where appropriate,
2017-11-15, v3.11.0-rc1~334^2) we added `NO_DEFAULT_PATH` so that it no
longer searches in `CMAKE_PREFIX_PATH`, but this also excludes searching
in system paths, which are needed on RISC-V platforms.  Use more granular
exclusions instead.

Fixes: #23469
2022-08-01 10:25:10 -04:00
Balthasar Reuter
878655384e FindOpenMP: Do not overwrite user-set FLAGS, LIB_NAMES
Since commit 2dbff623f9 (FindOpenMP: Save flags/libs in cache entries
each time they are detected, 2020-02-07, v3.17.0-rc1~10^2~1) we replace
both `OpenMP_${LANG}_FLAGS` and `OpenMP_${LANG}_LIB_NAMES` with detected
flags if either one is not set.  That can overwrite user-provided flags.

Update the logic for C, CXX, and Fortran to initialize each
`OpenMP_${LANG}_{FLAGS,LIB_NAMES}` variable only if it has not already
been set by the user.

Fixes: #23743
2022-07-20 12:21:38 -04:00
makise-homura
0eea1e8563 LCC: for OpenMP, collectly determine implicit link dirs
It is found out for LCC to not specify all library search paths
when called by cmake_parse_implicit_link_info().
Because of that, FindOpenMP module can't find some libraries,
like libpthread. For this, we should analyze -print-search-dirs
output and append library paths to implicit link ones.
2022-06-30 22:48:45 +03:00
makise-homura
e5d9fce03f LCC: Add dedicated support for MCST LCC compiler
Divert LCC compiler as a new one, instead of treating it as GNU.

Since old times, Elbrus C/C++/Fortran Compiler (LCC) by MCST has been
passing checks for GNU compilers, so it has been identified as GNU.
Now, with intent of seriously upstreaming its support, it has been
added as a separate LCC compiler, and its version displays not a
supported GCC version, but LCC version itself (e.g. LCC 1.25.19 instead
of GNU 7.3.0).

This commit adds its support for detection, and also converts basically
every check like 'is this compiler GNU?' to 'is this compiler GNU or
LCC?'. The only places where this check is untouched, is where it
regards other platforms where LCC is unavailable (primarily non-Linux),
and where it REALLY differs from GNU compiler.

Note: this transition may break software that are already ported to
Elbrus, but hardly relies that LCC will be detected as GNU; still such
software is not known.
2021-10-15 05:05:19 +03:00
Eisuke Kawashima
b3bf33539b FindOpenMP: Link with OpenMP flags on Fujitsu
Fixes: #22332
2021-06-24 09:09:49 -04:00
Chuck Atkins
376c300b25 FindOpenMP: Add support for Fujitsu compilers
Co-Author: Yuichiro Utsumi <utsumi.yuichiro@jp.fujitsu.com>
2021-03-31 09:14:45 -04:00
William R. Dieter
6fd014a4b6 FindOpenMP: Use -Qiopenmp instead of -fiopenmp for IntelLLVM on Windows
The Windows driver does not like the `-f` form of this option.

Note that we prefer `-Qiopenmp/-fiopenmp` over `-Qopenmp/-fopenmp` in
order to generate LLVM IR with parallelization information, which the
backend uses to generate parallelized code.

Signed-off-by: William R. Dieter <william.r.dieter@intel.com>
2021-03-15 14:43:23 -04:00
William R. Dieter
042aba3db4 FindOpenMP: Add support for IntelLLVM
Signed-off-by: William R. Dieter <william.r.dieter@intel.com>
2021-01-28 09:07:00 -05:00
Tin Huynh
90502d76b7 FindOpenMP: Add support for NVHPC compiler 2021-01-27 09:53:02 -05:00
Nikita Nemkin
8fea95319b Help: Add .. versionadded directives to module docs
Issue: #19715
2020-12-02 21:00:30 +05:00
Brad King
656d6ea821 FindOpenMP: Set version variables every time CMake runs
The version is determined in two steps.  First, the "spec date" is
detected and cached.  Second, the date is converted to a version.
Move the second step out of the spec date cache guard condition
so that it runs every time even if the spec date is already cached.

Fixes: #19150
2020-07-09 06:17:44 -04:00
Tim Hutton
ceb5ee4a7b FindOpenMP: Add support for Clang on Windows
Fixes: #19404
2020-02-10 17:20:19 -05:00
Tim Hutton
2dbff623f9 FindOpenMP: Save flags/libs in cache entries each time they are detected 2020-02-10 17:20:19 -05:00
Ben Boeckel
be4d1bdf9a FPHSA: acknowledge the name mismatches in CMake-owned modules 2020-01-14 17:25:49 -05:00
Brad King
ede1bebd50 Merge topic 'FindOpenMP-include-dir'
409891baf7 FindOpenMP: Allow try_compile() to find omp.h for AppleClang

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3916
2019-10-21 11:20:33 -04:00
Craig Scott
409891baf7 FindOpenMP: Allow try_compile() to find omp.h for AppleClang
Fixes: #18098 #18470 #18520
2019-10-17 18:50:05 +11:00
Konstantin Pyzhov
db5a8d7876 FindOpenMP: Add support for HIP clang device pass
The HIP clang makes 2 passes when compiling HIP programs: the DEVICE
pass and the HOST pass.  For openmp, the `-fopenmp` option is only
passed to the HOST compilation pass.  Therefore, the small test that
CMake uses for OpenMP detection fails to compile, and CMake reports
failure to detect OpenMP support in the compiler.  The suggested
solution is to add check for `__HIP_DEVICE_COMPILE__` macro defined by
HIP clang for the DEVICE pass to the OpenMP detection test.
2019-10-12 11:04:45 -04:00
Christian Pfeiffer
26f2b65fec FindOpenMP: Add 5.0 and VS19 spec dates
Fixes: #19289
2019-05-24 19:01:28 +02:00
Bartosz Kosiorek
cb811d11ce Help: Improve description of modules 2019-04-23 10:39:34 +02:00
Brad King
214fcefa52 Remove now-unused code once used for MIPSpro on IRIX
In commit beb991110d (Remove now-unused code once used on IRIX,
2019-01-11, v3.14.0-rc1~167^2) we removed remnants of IRIX support.
Also remove remnants of MIPSpro compiler support.
2019-02-21 11:12:51 -05:00
Brad King
a67d1e824c Merge topic 'FindOpenMP-log-errors'
272c4c3dee FindOpenMP: Log error output
db0445f0c8 FindOpenMP: Fix warnings with -Wstrict-prototypes

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Christian Pfeiffer <cpfeiffer@live.de>
Merge-request: !2574
2018-11-07 07:46:40 -05:00
Ivan Pozdeev
272c4c3dee FindOpenMP: Log error output 2018-11-07 07:38:54 -05:00
Ivan Pozdeev
db0445f0c8 FindOpenMP: Fix warnings with -Wstrict-prototypes
With -Wstrict-prototype -Werror, the check would fail
2018-11-07 07:38:54 -05:00
Kitware Robot
df4ed1e9ff Help: Convert remaining modules to block-style comments 2018-10-22 11:09:34 -04:00
Brad King
826bf5c454 FindOpenMP: Avoid warning in check code
The test code added by commit v3.12.0-rc1~411^2~1 (FindOpenMP: Verify in
test source that OMP library is linked, 2018-03-01) leaves an unused
variable warning.  This breaks the check with `-Werror`.  Remove the
variable and leave just the function call, which should still check that
the OMP library is linked.

Fixes: #18102
2018-06-27 15:24:22 -04:00
Brad King
6ff8e34e5e Merge topic 'FindOpenMP-Intel-Windows'
0c7433e874 FindOpenMP: Fix support for Intel on Windows

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1957
2018-04-17 07:29:33 -04:00
Roland Schulz
0c7433e874 FindOpenMP: Fix support for Intel on Windows
The change in commit v3.11.0-rc1~334^2 (FindOpenMP: Use NO_DEFAULT_PATH
where appropriate, 2017-11-15) broke partial support for Intel on Windows.
Since `OpenMP_${LANG}_IMPLICIT_LINK_DIRS` is empty for this compiler
the `find_library` call without `NO_DEFAULT_PATH` worked accidentally
in environments with the needed libraries in the search path already.

Fix support for Intel on Windows by simply removing our explicit search
for the `libiomp5md` library.  In cases that it is needed, the compiler
already inserts metadata in `.obj` files to tell the MSVC linker to use
the library.

Suggested-by: Christian Pfeiffer <cpfeiffer@live.de>
Fixes: #17910
2018-04-16 14:11:12 -04:00
Henry Fredrick Schreiner
e3cd7c1e01 FindOpenMP: Add support for AppleClang compiler
This is possible using an external `omp` library and by passing
the flag past the compiler driver via `-Xclang -fopenmp`.

Fixes: #17775
2018-03-07 08:27:35 -05:00
Henry Fredrick Schreiner
b4c539e651 FindOpenMP: Verify in test source that OMP library is linked 2018-03-07 08:25:45 -05:00
Henry Fredrick Schreiner
7dd8c7a680 FindOpenMP: Improve inclusion of helper modules
Use `CMAKE_CURRENT_LIST_DIR` instead of `CMAKE_ROOT`.
Do not include modules inside a loop.
2018-03-07 08:24:27 -05:00
Christian Pfeiffer
ffa6f8752b FindOpenMP: Employ genex where possible
Fixes: #17610
2018-01-19 16:38:52 +01:00
Christian Pfeiffer
8e6d6337cd Merge topic 'fomp-cmp0012'
36cc4378 FindOpenMP: Enable policy CMP0012

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1490
2017-11-17 07:20:37 -05:00
Christian Pfeiffer
36cc43788a FindOpenMP: Enable policy CMP0012
Fixes: #17476
2017-11-16 15:22:37 +01:00
Christian Pfeiffer
98314d536e FindOpenMP: Use NO_DEFAULT_PATH where appropriate
OpenMP libraries must always be found in the implicit linking
directories of a compiler when using the OpenMP compile flag. If a suitable OpenMP library is also found in for example some CMAKE_PREFIX_PATH, this can lead to the module finding the incorrect library.
On the other hand, CMAKE_PREFIX_PATH can't ever be a location that we
need to consider since the OpenMP compile flag would not work if we
needed to.
2017-11-15 15:05:41 +01:00
Brad King
fe4d6f1fd6 Merge topic 'omp-oacc-werror-return-type'
15da0ba3 Find{OpenMP,OpenACC}: Fix detection with -Werror=return-type

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1406
2017-10-25 08:12:30 -04:00
Christian Pfeiffer
15da0ba3a2 Find{OpenMP,OpenACC}: Fix detection with -Werror=return-type
Explicitly return a value from `main` in our test sources.

Fixes: #17391
2017-10-24 10:55:06 -04:00
Brad King
1f436c5803 Merge topic 'findopenmp-lib-paths'
f4cc7109 FindOpenMP: Improve OMP libraries search

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1385
2017-10-18 09:35:29 -04:00
Christian Pfeiffer
f4cc71099a FindOpenMP: Improve OMP libraries search
This supports libraries given as full path and filters libraries given
in CMAKE_<LANG>_STANDARD_LIBRARIES.

Fixes: #17351
2017-10-17 09:53:57 -04:00
Brad King
e67eb42fa1 Merge topic 'findopenmp-fix-verbose'
e25d88ec FindOpenMP: Fix link flags being used for compile

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1348
2017-10-06 07:15:24 -04:00