Commit Graph

107 Commits

Author SHA1 Message Date
Brad King
e374b9f1eb FindMPI: Restore MPI_<LANG>_COMPILE_FLAGS as a command-line string
Refactoring in commit v3.10.0-rc1~103^2~2 (FindMPI: Modernization from
ground up, 2017-04-25) accidentally left this variable set as a copy of
the `;`-list in `MPI_<LANG>_COMPILE_OPTIONS`, but the flags variable is
documented as a command-line string.  Restore it now.

Fixes: #18349
2018-09-10 14:33:29 -04:00
Chuck Atkins
bab4bc5f32 FindMPI: Fix libname regex to not match the compiler executable
When trying to match full path libraries on the mpicc link line, the
current regex is not strict enough and improperly matches a partial path
to the Xcode compiler path with homebrew mpich.  This adjusts the regex
to look for a space preceeding the library name to prevent the first
argument, i.e. the compiler invocation, from being matched, and require
either a space or end-pattern after the library to prevent mismatches with
arguments that contain the library suffix but don't actually end with it.
2018-04-12 15:07:16 -04:00
Christian Pfeiffer
0def36043f FindMPI: Discard IMPI boilerplate text
Intel MPI on Windows prefixes all outputs with some boilerplate
copyright text. By discarding it, we should prevent any potential
clashes with our regex parsing.
2018-01-31 17:43:30 +01:00
Christian Pfeiffer
9ecbec5e01 FindMPI: Support for IMPI's compiler check
Intel MPI has an optional feature to check compatibility with the
compiler, given by I_MPI_CHECK_COMPILER.
This commit adds support for executing that check.
2018-01-31 17:27:38 +01:00
Christian Pfeiffer
767553674e FindMPI: Set up environment variables for wrapper
For MPICH derivates and Intel MPI, we can improve the compiler wrapper
behavior and accuracy by defining certain environment variables if they
haven't been set otherwise.
2018-01-31 17:27:37 +01:00
Christian Pfeiffer
e7c0298d5c FindMPI: Retain unused link paths
If our ``find_library`` step hasn't used a particular link directory at
all, it's best to retain it in order to prevent issues from secondary
dependencies not being found.
2018-01-30 18:23:45 +01:00
Christian Pfeiffer
8cddc89926 FindMPI: Use more CMake variables
This replaces hardcoded expectations of flags like -l and -L with a
dynamical solution based on CMake platform variables.

Furthermore, the linker flag parsing is dynamified to support more forms
and given linker paths are now removed properly from the linker flags.
2018-01-30 18:23:45 +01:00
Christian Pfeiffer
8b79107add FindMPI: Improve link information parsing
The parsing of link information coming from the compiler wrapper has been improved:

- Support MSVC /link argument separation properly and add support for potential VC++ link flags
- Rely on the global import/static/shared library suffixes instead of hardcoded special values.
This should improve compatibility with Cygwin and MinGW should any MPI implementation there need this behavior.
- Don't use ``find_library`` if the full path of a library is known anyways.
2018-01-25 16:31:10 +01:00
Christian Pfeiffer
5e9512a358 FindMPI: Move MSMPI/MPICH2 mpiexec search
Move the logic to search mpiexec for MSMPI and MPICH2 guesses to their
respective guessing logic. This way, we can prevent mix ups between
their mpiexecs and other potential matches, for example from an Intel
MPI installation.
2018-01-10 18:20:49 +01:00
Brad King
a363c9356d Merge topic 'findmpi-builtin-fix'
d1d8719f FindMPI: Fix various legacy problems

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1569
2017-12-13 07:52:54 -05:00
Christian Pfeiffer
d1d8719f62 FindMPI: Fix various legacy problems
This MR fixes a number of bugs stemming from legacy variable handling,
partially introduced by commit v3.10.0-rc1~103^2 (FindMPI: Add support
for FreeBSD and SLES, 2017-08-09).

* `MPI_COMPILE_OPTIONS` and `MPI_COMPILE_DEFINITIONS` legacy hints were not passed correctly.
* Legacy variables could be parsed after they were set by `FindMPI` cause erroneous hinting on subsequent runs.
* In the case of the compiler supporting MPI implicitly:
	* not all consumption variables would be correctly reset.
	* `MPI_<LANG>_HEADER_DIR` would be set unintentionally.
	* `MPI_<LANG>_LIB_NAMES` appeared in cache despite being ignored.
	* on subsequent passes, `MPI_<LANG>_COMPILER` could be corrupted.
* the C-to-CXX copy logic would take place even if `MPI_SKIP_GUESSING` was turned on
* if only some language compilers were given, inconsistent search behavior could be observed

Issue: #17538
2017-12-12 14:20:02 +01:00
Brad King
22f440ae69 Merge topic 'findmpi-notfound-spam'
bde7513d FindMPI: Correct legacy variable handling

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1557
2017-12-06 08:00:46 -05:00
Brad King
b6dd3969e8 Merge topic 'findmpi-found-cond'
2047eb36 FindMPI: Fix multiple configure runs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1556
2017-12-06 08:00:07 -05:00
Brad King
0418e91f7d Merge branch 'findmpi-notfound-spam' into release-3.10
Merge-request: !1557
2017-12-05 08:37:10 -05:00
Christian Pfeiffer
2047eb360d FindMPI: Fix multiple configure runs
Due to a erroneous logical dependency on a temporary variable, FindMPI
would depend its FOUND status on the set of flags needed to support
compiler-implicit MPI support after the first configure run.

This behavior is especially causing a misreported NOT FOUND status after
the first run on MPI implementations without MPI compiler like MS-MPI or
MPICH2 on Windows.
2017-12-05 14:17:27 +01:00
Christian Pfeiffer
bde7513d2f FindMPI: Correct legacy variable handling
Due to a minor logic error, MPI_LIBRARY, MPI_EXTRA_LIBRARY and
MPI_<LANG>_LIBRARIES hints are currently not correctly handled and
discarded.

Additionally, if either C or CXX aren't enabled, there subsequent calls
to FindMPI will cause cache variables of the sort "MPI_MPI_EXTRA_LIBRARY-NOTFOUND"
to appear due to an error in the compatibility handling. (Doesn't affect
functionality)
2017-12-05 14:14:40 +01:00
Christian Pfeiffer
1615cdedf5 FindMPI: Treat 'command not found' as an error
If the compiler given in I_MPI_... could not be found, the Intel MPI
wrappers emit an error like "line 590: ifort: command not found".
The script should currently fail to match the output of this for
information, but we should generally treat such an output as invalid,
since the displayed configuration line can become a mixup between Intel
and GNU compiler settings.
2017-11-15 15:27:35 +01:00
Christian Pfeiffer
1610f757ac FindMPI: Use physical cores for MPIEXEC_MAX_NUMPROCS
Since commit v3.9.0-rc1~224^2~1 (FindMPI: MPIEXEC handling improvements,
2017-04-21) the `ProcessorCount` module is being used to initialize
`MPIEXEC_MAX_NUMPROCS`.  However, this leads to the logical cores being
counted rather than the physical ones, and some MPI implementations like
OpenMPI will error if mpiexec is called with that number.  Switch it to
the number of physical cores using `cmake_host_system_information`.

This ensures that if `MPIEXEC_MAX_NUMPROCS` is being used to set up MPI
tests with CTest or similar that the tests won't spuriously fail due to
OpenMPI refusing to start the application.
2017-10-24 10:41:02 -04:00
Christian Pfeiffer
bf1e606f60 FindMPI: Add support for FreeBSD and SLES
Fixes: #17117
2017-09-15 14:55:08 +02:00
Christian Pfeiffer
2f673da69f FindMPI: Support components for various languages 2017-09-15 14:55:08 +02:00
Christian Pfeiffer
9a58e69cc8 FindMPI: Modernization from ground up
This is a near-total rewrite of FindMPI implementing the following
features:

Environmental improvements:

- C++ settings can now be picked from C settings if no dedicated C++
  settings are found (some installs of IBM Platform MPI)
- Fortran settings can now be found on MPICH-1, MVAPICH-1, Microsoft
  MPI and MPICH-2 on Windows.

- Improved flag procession logic: Flags related to security enhancements
  of MPI itself, and unrelated to MPI usage (-fstack-protector-strong on
  e.g. RHEL 7 for MPICH and MVAPICH) will be filtered out properly now.
  -pthread is now being handled. -fno-strict-aliasing, which may be needed
  while compiling MVAPICH (e.g. RHEL 7's MVAPICH package) is also
  filtered.

Features added:

- MPI version can be determined for each language and is exposed as the
  package version
- MPI functionality is being tested to ensure the correctness of
  settings
- MPI-2 C++ bindings can be suppressed if desired by the project or
  user. For older MPIs, this often resolves issues and eliminated the
  infamous SEEK_SET trouble.
- MPI-2 C++ bindings are now being searched for and exposed by a
  variable if detected.
- Fortran support now does not make assumptions over the MPI present and
  works with ILP64 MPI implementations.
- Fortran now exposes which bindings (mpif.h, mpi/mpi_f08 modules) are
  available
- MPI detection can now work hybridly, which for example permits using the
  Fortran modules shipped with some compiler suites together with MPI
  (e.g. PGI on Windows shipping MSMPI modules)
- Ability to determine MPI library version (*requires* try_run, caution)
  upon request
- Ability to determine Fortran capabilities from MPI-3 for each of the
  bindings (subarrays, asynchronous attribute protecting entities) (also
  requires try_run)

Fine grained control over the search process:

- Possibility to selectively enable and disable steps like compiler
  wrapper search and guessing. Permits picking Microsoft MPI over Intel
  MPI if both are loaded (previously not possible without removing the
  IMPI compiler wrappers from the environment)
- Ability to pick MPICH2 over MSMPI (previously the first one located
  was taken)
- A user may now pass compiler flags to the compiler wrapper script,
  enabling much more flexibility. This permits for example linking the
  Intel MPI debug runtime, static linking, ILP64 with Fortran,
  linking tracing, ...
- A user may define a suffix for all MPI binaries that are being looked
  for (useful on Debian/Ubuntu where the alternative MPI installs are each
  appended with their name, e.g. mpicc.mpich and mpicc.lam)

Cache variable improvements

- Instead of the previous plural cache variables a list-of-variables
  approach is now in place. Permits correcting individual variables
  instead of having to wade through a list, also speeds up the search
  process and increases comfort by eliminating duplicate entries in
  LIBRARIES over languages
- MPIEXEC was corrected to MPIEXEC_EXECUTABLE in order to fix the
  grouping in the CMake GUI for the variable (previously ungrouped)
2017-09-15 14:55:08 +02:00
Christian Pfeiffer
28d8383797 separgs: Use NATIVE_COMMAND where appropriate 2017-04-26 20:34:23 +02:00
Christian Pfeiffer
ece4f64749 FindMPI: Modernize documentation 2017-04-21 20:02:20 +02:00
Christian Pfeiffer
6d4fa0210e FindMPI: MPIEXEC handling improvements 2017-04-21 20:01:37 +02:00
Brad King
c79e7e09a8 Merge topic 'findmpi-add-imported-targets'
3ed9f635 FindMPI: Add test case
86979bb5 FindMPI: Add IMPORTED targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !707
2017-04-19 10:45:03 -04:00
Christian Pfeiffer
86979bb533 FindMPI: Add IMPORTED targets 2017-04-16 01:12:55 +02:00
Christian Pfeiffer
d9d280f531 FindMPI: Mark old MPI library entries as advanced 2017-04-16 00:24:10 +02:00
Brad King
8e8eeb73ab Merge topic 'findmpi-flags-fix'
a2a73935 FindMPI: Remove leading spaces from flags
93f29be2 FindMPI: Reset MPI_INCLUDE_PATH_WORK before use
2017-02-06 10:29:35 -05:00
Christian Pfeiffer
a2a73935b2 FindMPI: Remove leading spaces from flags 2017-02-02 11:31:22 +01:00
Christian Pfeiffer
93f29be231 FindMPI: Reset MPI_INCLUDE_PATH_WORK before use 2017-02-01 18:45:13 +01:00
Christian Pfeiffer
e6eaf25c3a FindMPI: Strip quotes from include path and convert to CMake path format 2017-01-23 17:30:45 +01:00
Christian Pfeiffer
39bf93c897 FindMPI: Add Intel MPI wrapper names on Windows 2017-01-23 17:30:25 +01:00
Rolf Eike Beer
745b56f58c Find*.cmake: drop the comments before including FPHSA
No need to explain this over and over again.  While at it, do some other
minor cleanups to whitespace and comments (i.e. delete them).
2016-11-28 16:40:13 -05:00
Brad King
86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Daniel Pfeifer
5d0d980d99 Use string(APPEND) in Modules
Automate with:

find Modules -type f -print0 | xargs -0 perl -i -0pe \
's/set\(([a-zA-Z0-9_]+)(\s+)"\$\{\1\}([^"])/string(APPEND \1\2"\3/g'
2016-07-28 00:41:13 +02:00
Dominic Meiser
2a99fae1cc FindMPI: Recognize .lib file names for specification of link libraries
The Intel MPI compiler wrappers link against static MPI libraries simply
by listing the libraries (no `-l`).
2016-04-15 13:42:05 -04:00
Dominic Meiser
c4417b0927 FindMPI: Recognize /LIBPATH for specification of linker paths.
The Intel MPI wrappers use this form of -L to specify library locations.
2016-04-15 13:42:05 -04:00
Christoph Grüninger
875490545d FindMPI: Improve documentation formatting 2016-04-11 09:43:22 -04:00
Brad King
1c46b6aed0 FindMPI: Drop unnecessary and incorrect use of GetPrerequisites
Since commit v2.8.5~121^2~2 (FindMPI: Handle multiple languages,
2010-12-29) we called the GetPrerequisites is_file_executable function
but passed the name of a CMake variable instead of its value.  Therefore
the function has always failed and caused the search for the compiler
name to run even with an absolute path.  Switch to using if(IS_ABSOLUTE)
instead and drop use of GetPrerequisites.
2015-07-31 09:50:31 -04:00
Sean Brennan
cfd23d3f1f FindMPI: Extend Intel-MPI 5+ workaround for recent GCCs
Extend the workaround added by commit v3.2.0-rc1~278^2 (FindMPI:
Workaround Intel MPI 5.0.1 exit code problem, 2014-12-04) with an
additional/alternate keyword to recognize the case with recent GCCs.
2015-07-10 08:55:39 -04:00
Ben Boeckel
68857ccd82 FindMPI: handle trailing slash from $MSMPI_BIN
When installing, MSMPI puts a trailing backslash in the MSMPI_BIN
environment variable. This causes trouble when concatenating in CMake
since the list separator is now escaped and no longer a list separator
due to the trailing backslash. Instead, use file(TO_CMAKE_PATH) to make
the path CMake-friendly.
2015-01-14 10:19:06 -05:00
Ben Boeckel
ab4d1d07e4 FindMPI: MSMPI changed the subdirectories it uses 2015-01-06 12:59:07 -05:00
Ben Boeckel
827243942c FindMPI: add more search paths for MSMPI
Also comment what the various search paths are for.
2015-01-06 12:58:07 -05:00
Brad King
4d2c629045 Merge topic 'FindMPI-parse-Xlinker-flags'
a0792c48 FindMPI: Extract -Xlinker options
2014-12-15 11:06:42 -05:00
Alin Marin Elena
a0792c4851 FindMPI: Extract -Xlinker options
Extend the regex that mathces -Wl, linker options to match -Xlinker too.
These are used by Intel MPI and perhaps others.
2014-12-12 09:53:43 -05:00
Ben Boeckel
17a846ac3e FindMPI: search for msmpi's mpiexec as well 2014-12-11 17:26:06 -05:00
Alin Marin Elena
7626c8dcf6 FindMPI: Workaround Intel MPI 5.0.1 exit code problem (#15182)
This MPI compiler may return zero even in some error cases.  Check the
output to catch such cases.

Suggested-by: Kelly Thompson <kgt@lanl.gov>
2014-12-04 14:15:46 -05:00
Alin Marin Elena
f5ede30006 FindMPI: Factor out compiler wrapper execution into helper 2014-12-04 14:12:34 -05:00
Ben Boeckel
29c3edb87a Avoid if() quoted auto-dereference
When testing CMAKE_<LANG>_COMPILER_ID values, do not explicitly
dereference or quote the variable. We want if() to auto-dereference the
variable and not its value. Also replace MATCHES with STREQUAL where
equivalent.
2014-10-20 11:49:16 -04:00
Marcel Loose
150c2125dd FindMPI: Honor MPI_HOME for MPIEXEC (#14347)
We already use MPI_HOME and ENV{MPI_HOME} as hints for the location
of the MPI compilers.  Do the same for mpiexec, and then use the
location of mpiexec as a hint to find the compilers.
2014-08-11 13:09:02 -04:00