How to check header files and library functions in CMake like it is done in Autotools?

前端 未结 1 1084
既然无缘
既然无缘 2021-01-08 00:03

I\'m currently converting a small C project from autotools to CMake.

In the old configure.in I checked every header and library function for existence u

相关标签:
1条回答
  • 2021-01-08 00:41

    You can easily port that directly with CHECK_FUNCTION_EXISTS, CHECK_INCLUDE_FILE, CHECK_TYPE_SIZE, etc. Also see CMake_HowToDoPlatformChecks for some advice.


    Configuring in this style adds portability (ie you can check for ucontext.h and setjmp.h and use the one present, modifying your code with #ifdef HAVE_UCONTEXT or #ifdef HAVE_SETJMP).

    Moreover, when you distribute your application, you wish to avoid having compile error (for users) and thus with a good build system, you can handle most of architecture differences before distributing your app.

    It is easier for non-programmer to understand that if "check for gtk+ header - failed", they have to install gtk, rather than having a buch of compile error lines that say the same thing, but not readable for most of them :)

    0 讨论(0)
提交回复
热议问题