CMake: Howto test for compiler, before enable a language

一曲冷凌霜 提交于 2021-02-11 17:20:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!