Repository: mesonbuild/meson

Issue:
meson claims Unknown compiler(s): ['c++', 'g++', 'clang++', 'pgc++', 'icpc']
This is kinda weird: I have a very small dummy meson.build which errors out with:

> meson.build:7:0: ERROR: Unknown compiler(s): ['c++', 'g++', 'clang++', 'pgc++', 'icpc']

Whereas it's correct I don't have any of those compilers on my system, there is also no indication in my meson.build that this would be needed.

The sample meson.build is:

```
project('sample',
	'c',
	version: '1.0.0',
	meson_version: '>= 0.47',
)

dep = dependency('doesnotexist', required: false)
```




Discussion:
Hi! Could you please give us more insights on that issue? Specifically, what's your system and which Meson version are you running? Thanks!
openSUSE Tumbleweed, meson 0.53.1
I think perhaps this failure occurs if `cmake` is present, but you don't have a C++ compiler?

Could you run this with `export MESON_FORCE_BACKTRACE=1` to see where that error message comes from exactly?
```
2020-02-06T15:46:44.2717678Z The Meson build system
2020-02-06T15:46:44.2719784Z Version: 0.52.1
2020-02-06T15:46:44.2721431Z Source dir: /cygdrive/d/a/cygport/cygport
2020-02-06T15:46:44.2721722Z Build dir: /cygdrive/d/a/cygport/cygport/_build
2020-02-06T15:46:44.2721981Z Build type: native build
2020-02-06T15:46:44.2722223Z Project name: cygport
2020-02-06T15:46:44.2722522Z Project version: 0.33.1
2020-02-06T15:46:44.2722765Z Host machine cpu family: x86_64
2020-02-06T15:46:44.2723011Z Host machine cpu: x86_64
2020-02-06T15:46:44.2723366Z Configuring cygport using configuration
2020-02-06T15:46:44.2723623Z Configuring cygport-inplace using configuration
2020-02-06T15:46:44.2723856Z Program help2man found: YES (/usr/bin/help2man)
2020-02-06T15:46:44.2724106Z Program groff found: YES (/usr/bin/groff)
2020-02-06T15:46:44.2724354Z Program robodoc found: YES (/usr/bin/robodoc)
2020-02-06T15:46:44.2724618Z Program robodoc.sh found: YES (/cygdrive/d/a/cygport/cygport/doc/robodoc.sh)
2020-02-06T15:46:44.2724894Z Program test-help found: YES (/cygdrive/d/a/cygport/cygport/testsuite/basic/test-help)
2020-02-06T15:46:44.2725177Z Program test-version found: YES (/cygdrive/d/a/cygport/cygport/testsuite/basic/test-version)
2020-02-06T15:46:44.2725457Z Program test-info found: YES (/cygdrive/d/a/cygport/cygport/testsuite/basic/test-info)
2020-02-06T15:46:44.2727067Z Program git-archive-all found: YES (/usr/bin/git-archive-all)
2020-02-06T15:46:44.2727387Z Program test-bootstrap found: YES (/cygdrive/d/a/cygport/cygport/testsuite/basic/test-bootstrap)
2020-02-06T15:46:44.2727673Z Program test-driver found: YES (/cygdrive/d/a/cygport/cygport/testsuite/test-driver)
2020-02-06T15:46:44.2727934Z Program cmake found: YES (/usr/bin/cmake)
2020-02-06T15:46:44.2728168Z Program python2 found: YES (/usr/bin/python2)
2020-02-06T15:46:44.2728413Z Program bzr found: YES (/usr/bin/bzr)
2020-02-06T15:46:44.2728658Z Program cvs found: YES (/usr/bin/cvs)
2020-02-06T15:46:44.2728900Z Program git found: YES (/usr/bin/git)
2020-02-06T15:46:44.2729145Z Program hg found: YES (/usr/bin/hg)
2020-02-06T15:46:44.2729388Z Program mtn found: YES (/usr/bin/mtn)
2020-02-06T15:46:44.2729629Z Program svn found: YES (/usr/bin/svn)
2020-02-06T15:46:44.2729870Z Program aspell found: YES (/usr/bin/aspell)
2020-02-06T15:46:44.2730113Z Program automake found: YES (/usr/bin/automake)
2020-02-06T15:46:44.2730388Z Program gnome-autogen.sh found: YES (/usr/bin/gnome-autogen.sh)
2020-02-06T15:46:44.2730599Z Program mm-common-prepare found: YES (/usr/bin/mm-common-prepare)
2020-02-06T15:46:44.2730785Z Program kconfig_compiler found: NO
2020-02-06T15:46:44.2730967Z Program mate-autogen found: YES (/usr/bin/mate-autogen)
2020-02-06T15:46:44.2731156Z Program xdt-autogen found: YES (/usr/bin/xdt-autogen)
2020-02-06T15:46:44.2731339Z Found pkg-config: /usr/bin/pkg-config (1.6.0)
2020-02-06T15:46:44.2731521Z Found CMake: /usr/bin/cmake (3.14.5)
2020-02-06T15:46:44.2731650Z 
2020-02-06T15:46:44.2731849Z testsuite/autotools/meson.build:8:0: ERROR: Unknown compiler(s): ['c++', 'g++', 'clang++', 'pgc++', 'icpc']
2020-02-06T15:46:44.2732092Z The follow exceptions were encountered:
2020-02-06T15:46:44.2732288Z Running "c++ --version" gave "[Errno 2] No such file or directory: 'c++': 'c++'"
2020-02-06T15:46:44.2732492Z Running "g++ --version" gave "[Errno 2] No such file or directory: 'g++': 'g++'"
2020-02-06T15:46:44.2732709Z Running "clang++ --version" gave "[Errno 2] No such file or directory: 'clang++': 'clang++'"
2020-02-06T15:46:44.2734189Z Running "pgc++ --version" gave "[Errno 2] No such file or directory: 'pgc++': 'pgc++'"
2020-02-06T15:46:44.2734519Z Running "icpc --version" gave "[Errno 2] No such file or directory: 'icpc': 'icpc'"
2020-02-06T15:46:44.2734663Z 
2020-02-06T15:46:44.2734874Z A full log can be found at /cygdrive/d/a/cygport/cygport/_build/meson-logs/meson-log.txt
2020-02-06T15:46:44.2948689Z Traceback (most recent call last):
2020-02-06T15:46:44.2949221Z   File "/usr/bin/meson", line 11, in <module>
2020-02-06T15:46:44.2949501Z     load_entry_point('meson==0.52.1', 'console_scripts', 'meson')()
2020-02-06T15:46:44.2949735Z   File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 226, in main
2020-02-06T15:46:44.2949955Z     return run(sys.argv[1:], launcher)
2020-02-06T15:46:44.2950163Z   File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 217, in run
2020-02-06T15:46:44.2950399Z     return CommandLineParser().run(args)
2020-02-06T15:46:44.2950603Z   File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 129, in run
2020-02-06T15:46:44.2950813Z     return options.run_func(options)
2020-02-06T15:46:44.2951020Z   File "/usr/lib/python3.6/site-packages/mesonbuild/msetup.py", line 245, in run
2020-02-06T15:46:44.2951272Z     app.generate()
2020-02-06T15:46:44.2951483Z   File "/usr/lib/python3.6/site-packages/mesonbuild/msetup.py", line 159, in generate
2020-02-06T15:46:44.2951691Z     self._generate(env)
2020-02-06T15:46:44.2951897Z   File "/usr/lib/python3.6/site-packages/mesonbuild/msetup.py", line 192, in _generate
2020-02-06T15:46:44.2952103Z     intr.run()
2020-02-06T15:46:44.2952306Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 4024, in run
2020-02-06T15:46:44.2952509Z     super().run()
2020-02-06T15:46:44.2952700Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 412, in run
2020-02-06T15:46:44.2953111Z     self.evaluate_codeblock(self.ast, start=1)
2020-02-06T15:46:44.2953339Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 436, in evaluate_codeblock
2020-02-06T15:46:44.2953547Z     raise e
2020-02-06T15:46:44.2953759Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 430, in evaluate_codeblock
2020-02-06T15:46:44.2953976Z     self.evaluate_statement(cur)
2020-02-06T15:46:44.2954190Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 441, in evaluate_statement
2020-02-06T15:46:44.2954394Z     return self.function_call(cur)
2020-02-06T15:46:44.2954605Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 776, in function_call
2020-02-06T15:46:44.2954810Z     return func(node, posargs, kwargs)
2020-02-06T15:46:44.2955019Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 285, in wrapped
2020-02-06T15:46:44.2955220Z     return f(*wrapped_args, **wrapped_kwargs)
2020-02-06T15:46:44.2955438Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 174, in wrapped
2020-02-06T15:46:44.2955654Z     return f(*wrapped_args, **wrapped_kwargs)
2020-02-06T15:46:44.2955892Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 3542, in func_subdir
2020-02-06T15:46:44.2956105Z     self.evaluate_codeblock(codeblock)
2020-02-06T15:46:44.2956329Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 436, in evaluate_codeblock
2020-02-06T15:46:44.2956530Z     raise e
2020-02-06T15:46:44.2956731Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 430, in evaluate_codeblock
2020-02-06T15:46:44.2956931Z     self.evaluate_statement(cur)
2020-02-06T15:46:44.2957133Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 441, in evaluate_statement
2020-02-06T15:46:44.2957332Z     return self.function_call(cur)
2020-02-06T15:46:44.2957539Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 776, in function_call
2020-02-06T15:46:44.2958238Z     return func(node, posargs, kwargs)
2020-02-06T15:46:44.2958472Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 285, in wrapped
2020-02-06T15:46:44.2958674Z     return f(*wrapped_args, **wrapped_kwargs)
2020-02-06T15:46:44.2958879Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 174, in wrapped
2020-02-06T15:46:44.2959077Z     return f(*wrapped_args, **wrapped_kwargs)
2020-02-06T15:46:44.2959280Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 3542, in func_subdir
2020-02-06T15:46:44.2959478Z     self.evaluate_codeblock(codeblock)
2020-02-06T15:46:44.2959683Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 436, in evaluate_codeblock
2020-02-06T15:46:44.2959882Z     raise e
2020-02-06T15:46:44.2960072Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 430, in evaluate_codeblock
2020-02-06T15:46:44.2960273Z     self.evaluate_statement(cur)
2020-02-06T15:46:44.2960484Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 443, in evaluate_statement
2020-02-06T15:46:44.2960685Z     return self.assignment(cur)
2020-02-06T15:46:44.2960890Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 1054, in assignment
2020-02-06T15:46:44.2961092Z     value = self.evaluate_statement(node.value)
2020-02-06T15:46:44.2961300Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 441, in evaluate_statement
2020-02-06T15:46:44.2961497Z     return self.function_call(cur)
2020-02-06T15:46:44.2961701Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 776, in function_call
2020-02-06T15:46:44.2961905Z     return func(node, posargs, kwargs)
2020-02-06T15:46:44.2962092Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 285, in wrapped
2020-02-06T15:46:44.2962360Z     return f(*wrapped_args, **wrapped_kwargs)
2020-02-06T15:46:44.2962568Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 285, in wrapped
2020-02-06T15:46:44.2962771Z     return f(*wrapped_args, **wrapped_kwargs)
2020-02-06T15:46:44.2963090Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 285, in wrapped
2020-02-06T15:46:44.2963291Z     return f(*wrapped_args, **wrapped_kwargs)
2020-02-06T15:46:44.2963482Z   [Previous line repeated 2 more times]
2020-02-06T15:46:44.2963682Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 155, in wrapped
2020-02-06T15:46:44.2963882Z     ret = f(*wrapped_args, **wrapped_kwargs)
2020-02-06T15:46:44.2964091Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 174, in wrapped
2020-02-06T15:46:44.2964273Z     return f(*wrapped_args, **wrapped_kwargs)
2020-02-06T15:46:44.2964487Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 3092, in func_dependency
2020-02-06T15:46:44.2964695Z     d = self.dependency_impl(name, display_name, kwargs)
2020-02-06T15:46:44.2964924Z   File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 3139, in dependency_impl
2020-02-06T15:46:44.2965142Z     dep = dependencies.find_external_dependency(name, self.environment, kwargs)
2020-02-06T15:46:44.2965372Z   File "/usr/lib/python3.6/site-packages/mesonbuild/dependencies/base.py", line 2137, in find_external_dependency
2020-02-06T15:46:44.2965570Z     d = c()
2020-02-06T15:46:44.2965774Z   File "/usr/lib/python3.6/site-packages/mesonbuild/dependencies/base.py", line 1061, in __init__
2020-02-06T15:46:44.2965985Z     CMakeDependency.class_cmakeinfo[self.for_machine] = self._get_cmake_info()
2020-02-06T15:46:44.2966207Z   File "/usr/lib/python3.6/site-packages/mesonbuild/dependencies/base.py", line 1114, in _get_cmake_info
2020-02-06T15:46:44.2966422Z     ret1, out1, err1 = self._call_cmake(cmake_opts, 'CMakePathInfo.txt')
2020-02-06T15:46:44.2966902Z   File "/usr/lib/python3.6/site-packages/mesonbuild/dependencies/base.py", line 1466, in _call_cmake
2020-02-06T15:46:44.2967140Z     return self.cmakebin.call_with_fake_build(args, build_dir, env=env)
2020-02-06T15:46:44.2967363Z   File "/usr/lib/python3.6/site-packages/mesonbuild/cmake/executor.py", line 198, in call_with_fake_build
2020-02-06T15:46:44.2967565Z     cxx_comp, cxx_launcher = choose_compiler('cpp')
2020-02-06T15:46:44.2967775Z   File "/usr/lib/python3.6/site-packages/mesonbuild/cmake/executor.py", line 185, in choose_compiler
2020-02-06T15:46:44.2967990Z     comp_obj = self.environment.compiler_from_language(lang, MachineChoice.BUILD)
2020-02-06T15:46:44.2968215Z   File "/usr/lib/python3.6/site-packages/mesonbuild/environment.py", line 1392, in compiler_from_language
2020-02-06T15:46:44.2968415Z     comp = self.detect_cpp_compiler(for_machine)
2020-02-06T15:46:44.2968626Z   File "/usr/lib/python3.6/site-packages/mesonbuild/environment.py", line 1027, in detect_cpp_compiler
2020-02-06T15:46:44.2968841Z     return self._detect_c_or_cpp_compiler('cpp', for_machine)
2020-02-06T15:46:44.2969061Z   File "/usr/lib/python3.6/site-packages/mesonbuild/environment.py", line 1021, in _detect_c_or_cpp_compiler
2020-02-06T15:46:44.2969270Z     self._handle_exceptions(popen_exceptions, compilers)
2020-02-06T15:46:44.2969465Z   File "/usr/lib/python3.6/site-packages/mesonbuild/environment.py", line 738, in _handle_exceptions
2020-02-06T15:46:44.2969669Z     raise EnvironmentException(errmsg)
2020-02-06T15:46:44.2969898Z mesonbuild.mesonlib.EnvironmentException: Unknown compiler(s): ['c++', 'g++', 'clang++', 'pgc++', 'icpc']
2020-02-06T15:46:44.2970099Z The follow exceptions were encountered:
2020-02-06T15:46:44.2970306Z Running "c++ --version" gave "[Errno 2] No such file or directory: 'c++': 'c++'"
2020-02-06T15:46:44.2970523Z Running "g++ --version" gave "[Errno 2] No such file or directory: 'g++': 'g++'"
2020-02-06T15:46:44.2970794Z Running "clang++ --version" gave "[Errno 2] No such file or directory: 'clang++': 'clang++'"
2020-02-06T15:46:44.2971016Z Running "pgc++ --version" gave "[Errno 2] No such file or directory: 'pgc++': 'pgc++'"
2020-02-06T15:46:44.2971232Z Running "icpc --version" gave "[Errno 2] No such file or directory: 'icpc': 'icpc'"
2020-02-06T15:46:44.5377254Z ##[error]Process completed with exit code 1.
```

> I think perhaps this failure occurs if `cmake` is present, but you don't have a C++ compiler?

That is true - but clearly cmake does not mandate c++; it's common, but not always true.
@mensinda ?

Resolving patch:
diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py
--- a/mesonbuild/cmake/executor.py
+++ b/mesonbuild/cmake/executor.py
@@ -23,6 +23,7 @@
 import os
 import shutil
 import ctypes
+import textwrap
 
 from .. import mlog, mesonlib
 from ..mesonlib import PerMachine, Popen_safe, version_compare, MachineChoice
@@ -264,9 +265,12 @@ def choose_compiler(lang: str) -> T.Tuple[str, str]:
             if lang in compilers:
                 exe_list = compilers[lang].get_exelist()
             else:
-                comp_obj = self.environment.compiler_from_language(lang, MachineChoice.BUILD)
-                if comp_obj is not None:
-                    exe_list = comp_obj.get_exelist()
+                try:
+                    comp_obj = self.environment.compiler_from_language(lang, MachineChoice.BUILD)
+                    if comp_obj is not None:
+                        exe_list = comp_obj.get_exelist()
+                except Exception:
+                    pass
 
             if len(exe_list) == 1:
                 return make_abs(exe_list[0], lang), ''
@@ -278,10 +282,7 @@ def choose_compiler(lang: str) -> T.Tuple[str, str]:
 
         c_comp, c_launcher = choose_compiler('c')
         cxx_comp, cxx_launcher = choose_compiler('cpp')
-        try:
-            fortran_comp, fortran_launcher = choose_compiler('fortran')
-        except Exception:
-            fortran_comp = fortran_launcher = ''
+        fortran_comp, fortran_launcher = choose_compiler('fortran')
 
         # on Windows, choose_compiler returns path with \ as separator - replace by / before writing to CMAKE file
         c_comp = c_comp.replace('\\', '/')
@@ -302,47 +303,50 @@ def choose_compiler(lang: str) -> T.Tuple[str, str]:
         cxx_comp_file = comp_dir / 'CMakeCXXCompiler.cmake'
         fortran_comp_file = comp_dir / 'CMakeFortranCompiler.cmake'
 
-        if not c_comp_file.is_file():
-            c_comp_file.write_text('''# Fake CMake file to skip the boring and slow stuff
-set(CMAKE_C_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
-set(CMAKE_C_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
-set(CMAKE_C_COMPILER_ID "GNU") # Pretend we have found GCC
-set(CMAKE_COMPILER_IS_GNUCC 1)
-set(CMAKE_C_COMPILER_LOADED 1)
-set(CMAKE_C_COMPILER_WORKS TRUE)
-set(CMAKE_C_ABI_COMPILED TRUE)
-set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
-set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
-set(CMAKE_SIZEOF_VOID_P "{}")
-'''.format(c_comp, c_launcher, ctypes.sizeof(ctypes.c_voidp)))
-
-        if not cxx_comp_file.is_file():
-            cxx_comp_file.write_text('''# Fake CMake file to skip the boring and slow stuff
-set(CMAKE_CXX_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
-set(CMAKE_CXX_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
-set(CMAKE_CXX_COMPILER_ID "GNU") # Pretend we have found GCC
-set(CMAKE_COMPILER_IS_GNUCXX 1)
-set(CMAKE_CXX_COMPILER_LOADED 1)
-set(CMAKE_CXX_COMPILER_WORKS TRUE)
-set(CMAKE_CXX_ABI_COMPILED TRUE)
-set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
-set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP)
-set(CMAKE_SIZEOF_VOID_P "{}")
-'''.format(cxx_comp, cxx_launcher, ctypes.sizeof(ctypes.c_voidp)))
+        if c_comp and not c_comp_file.is_file():
+            c_comp_file.write_text(textwrap.dedent('''\
+                # Fake CMake file to skip the boring and slow stuff
+                set(CMAKE_C_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
+                set(CMAKE_C_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
+                set(CMAKE_C_COMPILER_ID "GNU") # Pretend we have found GCC
+                set(CMAKE_COMPILER_IS_GNUCC 1)
+                set(CMAKE_C_COMPILER_LOADED 1)
+                set(CMAKE_C_COMPILER_WORKS TRUE)
+                set(CMAKE_C_ABI_COMPILED TRUE)
+                set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
+                set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
+                set(CMAKE_SIZEOF_VOID_P "{}")
+            '''.format(c_comp, c_launcher, ctypes.sizeof(ctypes.c_voidp))))
+
+        if cxx_comp and not cxx_comp_file.is_file():
+            cxx_comp_file.write_text(textwrap.dedent('''\
+                # Fake CMake file to skip the boring and slow stuff
+                set(CMAKE_CXX_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
+                set(CMAKE_CXX_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
+                set(CMAKE_CXX_COMPILER_ID "GNU") # Pretend we have found GCC
+                set(CMAKE_COMPILER_IS_GNUCXX 1)
+                set(CMAKE_CXX_COMPILER_LOADED 1)
+                set(CMAKE_CXX_COMPILER_WORKS TRUE)
+                set(CMAKE_CXX_ABI_COMPILED TRUE)
+                set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
+                set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP)
+                set(CMAKE_SIZEOF_VOID_P "{}")
+            '''.format(cxx_comp, cxx_launcher, ctypes.sizeof(ctypes.c_voidp))))
 
         if fortran_comp and not fortran_comp_file.is_file():
-            fortran_comp_file.write_text('''# Fake CMake file to skip the boring and slow stuff
-set(CMAKE_Fortran_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
-set(CMAKE_Fortran_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
-set(CMAKE_Fortran_COMPILER_ID "GNU") # Pretend we have found GCC
-set(CMAKE_COMPILER_IS_GNUG77 1)
-set(CMAKE_Fortran_COMPILER_LOADED 1)
-set(CMAKE_Fortran_COMPILER_WORKS TRUE)
-set(CMAKE_Fortran_ABI_COMPILED TRUE)
-set(CMAKE_Fortran_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
-set(CMAKE_Fortran_SOURCE_FILE_EXTENSIONS f;F;fpp;FPP;f77;F77;f90;F90;for;For;FOR;f95;F95)
-set(CMAKE_SIZEOF_VOID_P "{}")
-'''.format(fortran_comp, fortran_launcher, ctypes.sizeof(ctypes.c_voidp)))
+            fortran_comp_file.write_text(textwrap.dedent('''\
+                # Fake CMake file to skip the boring and slow stuff
+                set(CMAKE_Fortran_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
+                set(CMAKE_Fortran_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
+                set(CMAKE_Fortran_COMPILER_ID "GNU") # Pretend we have found GCC
+                set(CMAKE_COMPILER_IS_GNUG77 1)
+                set(CMAKE_Fortran_COMPILER_LOADED 1)
+                set(CMAKE_Fortran_COMPILER_WORKS TRUE)
+                set(CMAKE_Fortran_ABI_COMPILED TRUE)
+                set(CMAKE_Fortran_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
+                set(CMAKE_Fortran_SOURCE_FILE_EXTENSIONS f;F;fpp;FPP;f77;F77;f90;F90;for;For;FOR;f95;F95)
+                set(CMAKE_SIZEOF_VOID_P "{}")
+            '''.format(fortran_comp, fortran_launcher, ctypes.sizeof(ctypes.c_voidp))))
 
         return self.call(args, build_dir, env)
 


Test patch: