164 Commits

Author SHA1 Message Date
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
Brad King
20f9b6973b Merge topic 'modules-use-new-try_compile-signature'
2edf0fc6d7 Modules: Use new keyword-dispatched try_compile signature

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7656
2022-09-14 08:13:27 -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
Ben Boeckel
08dece8b18 FindMPI: remove unnecessary variable expansions in conditionals 2022-09-12 09:35:48 -04:00
Ben Boeckel
1edc2f337f FindMPI: match full language names when "simplifying"
There is no reason `CSharp` should go down this codepath (assuming it
ever gets here in the first place).
2022-09-12 09:34:16 -04:00
Ben Boeckel
93b5bdb8b4 FindMPI: quote literal values
Some projects accidentally end up doing the equivalent of `set(0 1)`
which makes things work very poorly here. Be more defensive.

See: #23954
2022-09-12 09:32:05 -04:00
Markus Mützel
a606609499 FindMPI: Parse '-l:' flags in pkg-config output
With the msmpi package in MSYS2:

    $ pkg-config --libs msmpi
    -LC:/msys64/mingw64/lib -l:libmsmpi.dll.a

MSYS2-Issue: https://github.com/msys2/MINGW-packages/pull/11839
Fixes: #23620
2022-06-21 12:38:30 -04:00
Robert Maynard
c9c2e040aa FindMPI: Don't check for variables named the same as the languages
We want to see if a language is inside `MPI_FIND_COMPONENTS` not if
the variables `C`/`CXX` is set to a positive value.
2022-04-26 16:16:31 -04:00
Brad King
56d949f05f FindMPI: Fix finding PkgConfg for fallback
In commit 0723b2c935 (MPI: Add fallback detection code for MPI when cross
compiling, 2021-09-17, v3.22.0-rc1~89^2) the FindPkgConfig module was
included directly.  This produces warnings like:

    The package name passed to `find_package_handle_standard_args` (PkgConfig)
    does not match the name of the calling package (MPI).

Use `find_package(PkgConfig)` instead, as other find modules do.

Fixes: #22823
2021-11-01 08:09:15 -04:00
Helmut Grohne
0723b2c935 MPI: Add fallback detection code for MPI when cross compiling
The MPI libraries use a compiler wrapper to automatically inject
required flags and libraries into the compiler argument list. However,
the wrapper does not support cross-compiling: the wrapper will try to
invoke the native compiler which cannot handle the cross architecture
MPI libraries and fail.

This MR adds some fallback code for this case, which tries to bypass the
faulty wrapper and determine the necessary flags and libraries directly
from the MPI pkg-config files. The patch tries to be as unintrusive as
possible and should not break any existing use-cases.

Fixes: #22650
2021-09-17 18:55:02 +02:00
Brad King
38dbf18bb1 Merge topic 'FindMPI-framework-not-a-compile-flag'
2b2a6a7170 FindMPI: do not detect `-framework` as a compile flag

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Utkarsh Ayachit <utkarsh.ayachit@kitware.com>
Merge-request: !6467
2021-08-24 09:54:58 -04:00
Ben Boeckel
2b2a6a7170 FindMPI: do not detect -framework as a compile flag
MPICH 3.4.2 now reports `-framework OpenCL` as one of its compilation
flag. The compile flag extraction is seeing it as a generic `-f` flag
and misses its argument. This ends up with a compile option of
`-framework` which eats the next flag (and may be very important).

It does not seem that passing `-framework` as a link flag is necessary
at this time, so that is being actively ignored for now.

Fixes: #22555
2021-08-19 13:09:39 -04:00
Axel Huebl
d9fcbb06f2 FindMPI: Interrogate Cray compiler
Cray traditionally does not ship mpicc/mpic++ compiler wrappers.
Due to that, the traditional CMake logic to find MPI is to *only*
support MPI on Cray systems if either

1. Cray Wrappers are used for compiling, or
2. an auxiliary MPI executable is found.

On many new Exascale prototypes, using the Cray wrappers for develop
work is extremely painful. Vendors such as AMD and integrators such
as HPE seem not to go well in lock-step in Cray programming envs,
making offloading with Cray wrappers too challenging. On the other
hand, using the working experimental Vendor compilers works well,
as long as one does not need MPI.

Extend the fallback MPI search logic by also interrogating the
CC/cc/ftn binaries if found for their MPI flags. This does not
change existing logic, i.e. using the Cray wrappers directly, but
provides an additional way to get MPI programs compiled on Cray.

Fixes: #22368
2021-07-13 09:47:51 -04:00
Brad King
dad3a178a4 Merge topic 'FindMPI-adjust-compile-definitions-early'
0c1b9b3516 FindMPI: Choose definitions for MPI_CXX_SKIP_MPICXX before first use

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6303
2021-07-08 07:57:28 -04:00
Ye Luo
0c1b9b3516 FindMPI: Choose definitions for MPI_CXX_SKIP_MPICXX before first use
Fixes: #22391
2021-07-07 09:51:01 -04:00
Brad King
1a9ebd1694 FindMPI: Honor MPI_CXX_SKIP_MPICXX when set as a normal variable
Express the cache entry with `option()`.  In combination with policies
CMP0077 and CMP0102, this allows project code to control the switch with
a variable:

```
set(MPI_CXX_SKIP_MPICXX TRUE)
find_package(MPI COMPONENTS CXX)
```
2021-07-06 19:41:35 -04:00
Brad King
7ce67efda4 Merge topic 'FindMPI-host_link'
666f689e48 FindMPI: avoid host link options to be propagated to device link step

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robertjmaynard@gmail.com>
Acked-by: Alex <leha-bot@yandex.ru>
Merge-request: !5966
2021-04-02 07:53:41 -04:00
Marc Chevrier
666f689e48 FindMPI: avoid host link options to be propagated to device link step
Fixes: #21887
2021-04-01 16:23:08 +02:00
Chuck Atkins
9e0a1cf03e FindMPI: Add support for the Fujitsu compiler wrappers
Co-Author: Yuichiro Utsumi <utsumi.yuichiro@jp.fujitsu.com>
2021-03-31 09:14:45 -04:00
Axel Huebl
8251b62ba0 FindMPI: Fix reason for a non-enabled non-requested language
In pure C/CXX projects, when doing an optional search for C/CXX
MPI APIs, I keep getting a reason appended of the form:

```
-- Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS)
-- Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS)
-- Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND)
    Reason given by package: MPI component 'Fortran' was requested, but language Fortran is not enabled.
```

The reason makes no sense since I did not request Fortran and thus
confuses the reader. It is now only added if the component was truly
requested.
2021-02-11 09:05:19 -05:00
William R. Dieter
90941a1896 FindMPI: Add support for IntelLLVM
Signed-off-by: William R. Dieter <william.r.dieter@intel.com>
2021-01-28 09:07:00 -05:00
Brad King
98084f902b Merge topic 'FindMPI-oneapi-single-quotes'
a5b223aa7f FindMPI: remove single quotes from include path

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5654
2021-01-05 09:03:08 -05:00
Eduard Valeyev
a5b223aa7f FindMPI: remove single quotes from include path
Intel OneAPI's MPI wraps include paths into single quotes,
remove them when sanitizing _MPI_INCLUDE_PATH

Fixes: #21634
2021-01-04 14:13:43 -05:00
Nikita Nemkin
8fea95319b Help: Add .. versionadded directives to module docs
Issue: #19715
2020-12-02 21:00:30 +05:00
Brad King
e029cb1ca6 Merge topic 'FindMPI-cuda-pthread'
47abe5f225 FindMPI: Fix regression in pthread guard

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Raul Tambre <raul@tambre.ee>
Merge-request: !5147
2020-08-20 07:55:23 -04:00
Axel Huebl
47abe5f225 FindMPI: Fix regression in pthread guard
Fix a regression with MPI and CUDA<10.2 that did let `-pthread` flags
slip to nvcc again.  In commit b725a19072 (FindMPI: Deny -fexceptions
from NVCC, 2020-07-02, v3.18.0-rc4~12^2) we accidentally forgot to use
the variable containing the replacement result.

Fixes: #21108
2020-08-20 06:52:45 -04:00
Jean-Christophe Fillion-Robin
207373802e Fix typos identified using codespell
See https://github.com/codespell-project/codespell#readme

The following command was used:

```
codespell -q6 --skip="\
.git,\
*.json,\
./Copyright.txt,\
./Help/command/foreach.rst,\
./Help/prop_test/REQUIRED_FILES.rst,\
./Help/variable/CTEST_COVERAGE_COMMAND.rst,\
./Modules/CMakeCheckCompilerFlagCommonPatterns.cmake,\
./Modules/CMakeRCInformation.cmake,\
./Modules/Internal/CPack/NSIS.template.in,\
./Modules/FindMatlab.cmake,\
./Modules/MatlabTestsRedirect.cmake,\
./Modules/Platform/Windows-Clang.cmake,\
./Modules/Platform/Windows-Intel-Fortran.cmake,\
./Modules/Platform/Windows-MSVC.cmake,\
./Source/CMakeVersion.cmake,\
./Source/cmConvertMSBuildXMLToJSON.py,\
./Source/cmCreateTestSourceList.cxx,\
./Source/cmGlobalVisualStudio10Generator.cxx,\
./Source/cmExportBuildFileGenerator.cxx,\
./Source/cmExportInstallAndroidMKGenerator.cxx,\
./Source/cmExportInstallFileGenerator.cxx,\
./Source/cmExportSet.cxx,\
./Source/cmExportTryCompileFileGenerator.cxx,\
./Source/cmFindPackageCommand.cxx,\
./Source/cmInstallCommand.cxx,\
./Source/cmGeneratorExpressionLexer.cxx,\
./Source/cmLocalVisualStudio7Generator.cxx,\
./Source/cmOrderDirectories.cxx,\
./Source/cmTarget.cxx,\
./Source/kwsys/*,\
./Source/QtDialog/CMakeSetupDialog.ui,\
./Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx,\
./Source/CTest/cmParseCoberturaCoverage.h,\
./Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in,\
./Tests/RunCMake/CPack/tests/DMG_SLA/English.license.rtf,\
./Tests/RunCMake/CPack/tests/DMG_SLA/German.license.txt,\
./Tests/RunCMake/CPack/tests/DMG_SLA/German.menu.txt,\
./Tests/RunCMake/GoogleTest/xml_output.cpp,\
./Tests/RunCMake/Make/TargetMessages*,\
./Utilities/*,\
" \
-L "\
dependees,\
endwhile,\
fo,\
filetest,\
helpfull,\
nd,\
objext,\
stoll,\
supercedes,\
superceded,\
vas,\
varn,\
"
```
2020-07-22 12:44:47 -04:00
Robert Maynard
33192e1b5f FindMPI: Pass -pthread to NVCC through -Xlinker for device linking
Fixes: #20924
2020-07-07 10:23:11 -04:00
Axel Huebl
b725a19072 FindMPI: Deny -fexceptions from NVCC
Do not forward -fexceptions (set from MVAPICH2) to NVCC.

Fixes: #18558
2020-07-06 09:37:11 -04:00
Tobias Ribizel
80d37167fe Find{Threads,MPI}: Add support for CUDA with Clang
Currently CMake passes `-Xcompiler -pthread` flags to CUDA compilers
irrespective of the actual CUDA compiler ID.  This makes sure the
additional `-Xcompiler` flag is only used with nvcc.
2020-05-25 11:17:52 -04:00
Brad King
faa0c62106 FindMPI: Normalize paths from MSMPI environment variables
Fixes: #20606
2020-04-20 13:39:06 -04:00
Brad King
adc58e9612 Merge topic 'FindMPI-pgi-spectrum-mpi-wrappers'
cd449c6175 FindMPI: Add the pgi compiler wrapper names used by IBM Spectrum MPI

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4598
2020-04-13 10:57:23 -04:00
Chuck Atkins
cd449c6175 FindMPI: Add the pgi compiler wrapper names used by IBM Spectrum MPI 2020-04-10 12:01:59 -04:00
Brad King
a63f1c5c03 Merge topic 'FindMPI-fix-rerun'
b4d5ea8233 FindMPI: Preserve order of include directories on re-runs of CMake
8261ee3a9c FindMPI: Restore re-construction of include directories

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4341
2020-02-11 08:17:45 -05:00
Brad King
b4d5ea8233 FindMPI: Preserve order of include directories on re-runs of CMake
The fix in commit 5861c6d450 (FindMPI: Preserve include order when
extracting component directories, 2019-12-19) only works on the first
run of CMake in which we find MPI.  Extend the fix to save the compiler
wrapper's entire include path in our cache without splitting anything
out.  That way we can preserve the order when CMake re-runs.

Fixes: #20338
2020-02-10 11:14:42 -05:00
Brad King
8261ee3a9c FindMPI: Restore re-construction of include directories
The fix in commit 5861c6d450 (FindMPI: Preserve include order when
extracting component directories, 2019-12-19) only works on the first
run of CMake in which we find MPI.  It preserves the include directories
on the first run but still splits them up and saves the pieces in the
cache.  On future runs the pieces are not re-assembled, and we do not
know the order anyway.

Restore the re-assembly step so that at least all the include dirs are
available.  Leave preservation of the original order to later work.

Issue: #20338
2020-02-10 11:10:29 -05:00
Brad King
7cc74a59f3 Merge topic 'findmpi-documentation'
95a501addb Help: Add more variable documentation to FindMPI

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4263
2020-01-23 10:01:57 -05:00
Kyle Edwards
95a501addb Help: Add more variable documentation to FindMPI 2020-01-22 14:46:09 -05:00
Brad King
fbd20759be Merge topic 'FindMPI-fix-return'
8217a26d29 FindMPI: Fix regression when compiling with MPI wrappers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4254
2020-01-22 09:30:53 -05:00
Brad King
8217a26d29 FindMPI: Fix regression when compiling with MPI wrappers
The change in commit 5861c6d450 (FindMPI: Preserve include order when
extracting component directories, 2019-12-19) converted a CMake-language
function to a macro.  However, it contains a `return()` call that now
applies in the caller's scope, which is in correct.  The `return()` is
meant to skip work when using a MPI compiler wrapper as the main
compiler.  Move that condition to the call site instead.

Fixes: #20234
2020-01-21 10:41:20 -05:00
Ben Boeckel
be4d1bdf9a FPHSA: acknowledge the name mismatches in CMake-owned modules 2020-01-14 17:25:49 -05:00
Chuck Atkins
5861c6d450 FindMPI: Preserve include order when extracting component directories
Fixes: #20098
2020-01-10 14:13:44 -05:00
Keith Ballard
e221039e11 FindMPI: Improve error when a component's language is not enabled
Previously, if a CMake project requests a component for a language that is
not enabled, it would simply give an error with the message

    Could NOT find MPI (missing: MPI_${LANG}_FOUND)

which is not indicative that the language was not enabled.  This change
provides an error message indicating that it failed to find the
particular MPI component because no compiler was available for the
language and the language might need to be enabled for the project.

Closes: #19996
2019-11-20 10:23:33 -05:00
Brad King
01c7c4236a Merge topic 'FindMPI-restore-flag-vars'
31b8b28fed FindMPI: Restore MPI_<LANG>_COMPILE_FLAGS and MPI_<LANG>_COMPILE_OPTIONS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3710
2019-08-21 10:28:33 -04:00
Robert Maynard
31b8b28fed FindMPI: Restore MPI_<LANG>_COMPILE_FLAGS and MPI_<LANG>_COMPILE_OPTIONS
In commit e374b9f1eb (FindMPI: Restore MPI_<LANG>_COMPILE_FLAGS as a
command-line string, 2018-09-10, v3.12.3~6^2) we tried to restore the
compile flags but accidentally inverted the arguments to `list(JOIN)`
causing both `MPI_<LANG>_COMPILE_FLAGS` and `MPI_<LANG>_COMPILE_OPTIONS`
to be empty.

Issue: #18349
2019-08-21 10:08:12 -04:00
Brad King
f54c9f6cc3 Merge topic 'FindMPI-link-flags'
cf04da7e70 FindMPI: make sure computed link flags are not de-duplicated

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: Ben Boeckel <ben.boeckel@kitware.com>
Tested-by: Robert Maynard <robert.maynard@kitware.com>
Acked-by: Axel Huebl <axel.huebl@plasma.ninja>
Merge-request: !3605
2019-07-26 07:12:08 -04:00
Robert Maynard
cf04da7e70 FindMPI: make sure computed link flags are not de-duplicated
In commit f7eaa342de (FindMPI: Store imported target link flags as a
list instead of a string, 2019-06-14, v3.15.0-rc2~2^2) we used
`separate_arguments` to parse the extracted link flags and add them to
`INTERFACE_LINK_LIBRARIES`.  That property is not meant for link flags
and CMake may de-duplicate them.  This is particularly problematic for
flags like `-Wl,-rpath -Wl,/path1 -Wl,-rpath -Wl,/path2`.

In commit 39c572c9c9 (FindMPI: Updated to use INTERFACE_LINK_OPTIONS,
2019-06-24) we moved the parsed flags over to `INTERFACE_LINK_OPTIONS`,
but that may still perform de-duplication.  Avoid the parsing and
de-duplication of flags by passing the original string via `SHELL:`
instead.

Fixes: #19516
2019-07-25 12:59:21 -04:00
Brian Carlson
5affe415a3 FindMPI: Add MPI_EXECUTABLE_SUFFIX to every item in lists
Add the `${MPI_EXECUTABLE_SUFFIX}` to each of the items in the
`_MPI_${id}_${LANG}_COMPILER_NAMES` and `_MPI_${LANG}_GENERIC_COMPILER_NAMES` rather
than just adding the suffix to the last item in each list.
2019-06-29 13:35:01 -04:00
Robert Maynard
39c572c9c9 FindMPI: Updated to use INTERFACE_LINK_OPTIONS 2019-06-24 16:45:44 -04:00