问题
In my project some code can be optional compiled in a different language (nasm & fortran), but it's also fine to compile the project without having these compiler installed. E.g. on Windows.
I would like to check if the the compiler are installed, before enabling the languages with enable_language
enable_language(ASM_NASM)
enable_language(Fortran)
If I use enable_language
without an additional check, CMake stops with an error message.
(At the moment I check for if (MSVC)
as workaround.)
Btw. I have a similar problem with the check for Qt. The check don't stop with an error, but generate a lot of noisy warnings.
回答1:
So use check_language to check if a language can be enabled.
来源:https://stackoverflow.com/questions/60320941/cmake-howto-test-for-compiler-before-enable-a-language