biicode

What does BII_IMPLICIT_RULES_ENABLED do when switched on or off in CMakeLists.txt?


I was wondering about the BII_IMPLICIT_RULES_ENABLED flag which I had switched off in one of my CMakeLists.txt files, in order to get an OpenGL related block to compile on a Mac, following a suggestion from biicode. This setting is still there and everything works perfectly, but I would like to find out more about it. Could someone explain what it does exactly?

Thanks!


Solution

  • BII_IMPLICIT_RULES_ENABLED activates the addition of system libs to the target that has included certain headers. For example, if your code contains an:

    #include "math.h"
    

    And you are in *nix systems, then the library "m" (libm) will be added to your target via TARGET_LINK_LIBRARIES. You can see the headers that are processed in your cmake/biicode.cmake file, in the HANDLE_SYSTEM_DEPS

    My recommendation: Put it to False whenever possible, and handle the required system libs yourself, exactly what you have done. It is something that will be deprecated soon, or at least set to False by default to new projects. This option sometimes causes troubles, if something fails or there is a bug in biicode.cmake, e.g. in the past it tried to add libm to targets also in windows. It will be gradually deprecated and probably substituted by some CMake macros hosted (as in http://www.biicode.com/biicode/cmake) that could be used by users if they decide to, but not automatically as it is done now.