[cmake-developers] Make CMAKE_SHARED_MODULE_PREFIX empty by default on UNIX ?

Alexander Neundorf neundorf at kde.org
Thu Dec 13 05:15:08 EST 2012


Hi,

in KDE we create a lot of dynamic plugins, and since KDE 1.x we create them 
without the "lib" prefix.
There was a request on the KDE buildsystem list to make this the default 
behaviour of cmake:
http://thread.gmane.org/gmane.comp.kde.devel.buildsystem/7570

A quick survey on my system showed that basically all other plugins I could 
find quickly also use an empty prefix, the only one I found which uses the 
"lib"-prefix for its plugins was CodeBlocks 
(http://article.gmane.org/gmane.comp.kde.devel.buildsystem/7573).

I think simply changing the default in cmake is not possible due to 
compatibility reasons. So I thought using a policy this might be possible (if 
the new policy is set, make CMAKE_SHARED_MODULE_PREFIX empty on UNIX, 
otherwise leave it as it is now).

I had a look how CMAKE_SHARED_MODULE_PREFIX is set in CMake.
This is this code in CMakeSystemSpecificInformation.cmake:

if(NOT CMAKE_MODULE_EXISTS)
  set(CMAKE_SHARED_MODULE_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}")
  set(CMAKE_SHARED_MODULE_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()


AFAIK, CMakeSystemSpecificInformation.cmake is executed very early during a 
cmake run, at least if there is no project() call in the CMakeLists.txt.
This makes it hard to use a policy for changing this behaviour, right ?
Because in this case, without project() call, 
CMakeSystemSpecificInformation.cmake is executed before any policies or 
required versions could be set.

Any other ideas how to do that in a simple way ?
Or other comments ?

Alex



More information about the cmake-developers mailing list