BUILD_SHARED_LIBS option is declared conditionally on whether BUILD_SHARED_LIBS is defined itself. This is problematic as multiple invocations of a build runner such as ninja will cause builds to use different options. The first build will run as if BUILD_SHARED_LIBS is not defined (i.e. OFF option), the second time cmake will notice that BUILD_SHARED_LIBS was defined after all and now run build with BUILD_SHARED_LIBS set to ON. This is confusing and error prone.
To fix the problem, a top-level BUILD_SHARED_LIBS option has been added and BUILD_SHARED_LIBS option in applications subdirectory was changed to become active only if the project is standalone.
BUILD_SHARED_LIBS option is declared conditionally on whether BUILD_SHARED_LIBS is defined itself. This is problematic as multiple invocations of a build runner such as ninja will cause builds to use different options. The first build will run as if BUILD_SHARED_LIBS is not defined (i.e. OFF option), the second time cmake will notice that BUILD_SHARED_LIBS was defined after all and now run build with BUILD_SHARED_LIBS set to ON. This is confusing and error prone.
To fix the problem, a top-level BUILD_SHARED_LIBS option has been added and BUILD_SHARED_LIBS option in applications subdirectory was changed to become active only if the project is standalone.