Brad King wrote: > IMO that's too special-purpose. However, since it is so common to > add a library and then set properties on it, perhaps there should be > a syntax in add_library and add_executable to inline property settings. > > For example, we could add a keyword signature to declare SOURCES > and PROPERTIES in one call: > > add_library(myplugin STATIC > SOURCES foo.cpp > PROPERTIES QT_STATICPLUGIN "1" > )
Perhaps. What would a complete example look like where the user can choose the build type? cmake_minimum_required(VERSION 2.8) project(Something) set(my_lib_type SHARED CACHE STRING "Choose the type of libraries to build, options are: SHARED or STATIC.") set_property(CACHE my_lib_type PROPERTY STRINGS "SHARED" "STATIC") # Don't give plugins a 'lib' prefix set(CMAKE_SHARED_MODULE_PREFIX "") add_library(some_lib ${my_lib_type} foo.cpp) if (my_lib_type STREQUAL SHARED) add_library(some_plugin MODULE main.cpp) else() add_library(some_plugin STATIC SOURCES main.cpp PROPERTIES STATICPLUGIN 1 # If we need this anyway, we might as well move it upscope # and remove the CMAKE_SHARED_MODULE_PREFIX setting, replacing # it with # set_property(TARGET some_plugin PROPERTY PREFIX "") PREFIX "" ) endif() I don't know why CMAKE_SHARED_MODULE_PREFIX has 'SHARED' in the name, but it seems another gain from adding a STATIC_MODULE type would be control of things like the default PREFIX, using either a new CMAKE_MODULE_PREFIX or a new CMAKE_STATIC_MODULE_PREFIX. Also things like CXXFLAGS and LINKER_FLAGS for the type could be set easily (CMAKE_MODULE_LINKER_FLAGS, etc). Admittedly, that's still a relatively minor gain. Thanks, Steve. -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers