Bug #1881

cmake: try_run stderr should be ignored

Added by Roland Schulz about 5 years ago. Updated over 4 years ago.

Target version:
Affected version - extra info:
Affected version:


We put any content from executing gmx_cpuid into the cache file and the buildinfo.h. If the executable write other stuff to output besides the normal result and that stuff contains spaces or other special character the build fails with odd compiler errors. Especially because we also capture stderr, any linked library with prints errors can cause this issue. An example is the craype-hugepages:
We should either ignore stderr or test that no extra output is printed.

Associated revisions

Revision 63e5d789 (diff)
Added by Mark Abraham over 4 years ago

Ignore stderr when detecting SIMD and build info

Cray and some other stupid compilers echo extra stuff to stderr when
compiling a normal source file. Unfortunately, the standard CMake
try_run cannot ignore stderr.

Refactored some try_run calls to try_compile + try_run. This
incidentally makes build-host detection run faster because the same
binary is not compiled multiple times. The results of the detections
are now set up so that an initial default value is constructed,
replaced if the compilation and run both succeed, before finally being

Noted some TODOs for future cleanup of the duplication in such code.

Fixes #1881.

Change-Id: Icb770872f853cff3ef60426d9980f463341eb1cf


#1 Updated by Erik Lindahl almost 5 years ago

try_run() doesn't provide for ignoring standard error, so the only option I can think of is for someone to rewrite the code to use try_compile(), copy the generated executable, and the use execute_command() - which can ignore stderr.

#2 Updated by Gerrit Code Review Bot over 4 years ago

Gerrit received a related patchset '1' for Issue #1881.
Uploader: Erik Lindahl ()
Change-Id: Icb770872f853cff3ef60426d9980f463341eb1cf
Gerrit URL:

#3 Updated by Erik Lindahl over 4 years ago

  • Status changed from New to Fix uploaded

#4 Updated by Mark Abraham over 4 years ago

  • Target version set to 5.1.3

We have an updated fix proposed, but it's still unclear which branch it might go into

#5 Updated by Mark Abraham over 4 years ago

  • Status changed from Fix uploaded to Resolved

#6 Updated by Erik Lindahl over 4 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF