Inconsistency between building of static and shared libraries.
For the first build of RobWork, static libraries are built. If cmake is run again, shared libraries are built (causing a recompilation of the entire project). Previously I have experienced a similar issue in RobWorkSim where the config.cmake.template overrules options from the second run of cmake and onwards.
The RW_INIT_PROJECT macro will load the config.cmake.template file, which specifies:
After this, the RW_OPTIONS macro is called, and sets shared libraries to OFF initially:
option(PROJECT_SHARED_LIBS "Build shared libraries." OFF)
I think that this is what happens:
- For the first run: the variable is set to ON and afterwards overwritten by the option statement, which sets it to OFF adds an entry to the CMake cache.
- For the second run: the variable is OFF initially, but is overwritten by the set statement. The option statement has no effect, as it is a value read from the cache.
In RobWorkMacros.cmake the default option can just be set to ON. This will, however, not change the fact that config.cmake.template will always overrule the CMakeCache. This is ugly in my opinion.
It is unfortunate that default parameters can be specified multiple places. Especially when these are often inconsistent. Maybe the .template file should not even be used.