[CMake] portable way for specifying whether everything or selective libs should be linked statically or as shared objects?
Bill Hoffman
bill.hoffman at kitware.com
Tue Apr 3 13:41:08 EDT 2012
On 4/2/2012 9:57 PM, Bill Hoffman wrote:
> Well, you could implement it... :)
>
> This is an interesting interface:
> target_link_libraries(foo STATIC lib1 lib2 SHARED lib3 lib4)
>
> I would suggest that you move to the discussion to the cmake-developers
> list.
>
I had another thought on this. Usually it is good enough to build all
of your applications libraries static, and CMake does handle this. If
you use the BUILD_SHARED_LIBS variable in your project you can get it to
build all the libraries as either static or shared based on the value of
this variable.
For example:
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
add_library(foo foo.c)
add_executable(bar bar.c)
target_link_libraries(bar foo)
IF BUILD_SHARED_LIBS = OFF then you get static foo, if it is ON, then
you get a shared foo. The system libraries are another issue... :)
-Bill
More information about the CMake
mailing list