[CMake] compiling for static/shared simultaneously?

Philip Lowman philip at yhbt.com
Mon Mar 19 11:58:21 EST 2007


I noticed when using ADD_LIBRARY to compile both static and shared 
simultaneously that CMake will compile the source code twice once with 
-fPIC (for shared build) and once without.

 From the point of view of Linux I've never had a problem using code 
compiled with -fPIC with a static link (except it's slightly bigger). 
Since compiling the code twice does slow down the build quite a bit, I 
guess I was just wondering how hard people think it would be to get 
ADD_LIBRARY(foo STATIC) to somehow reuse code already compiled by 
ADD_LIBRARY(foo SHARED).

Is this even possible to do within CMakeLists.txt files without making 
source code modifications?

-- 
Philip Lowman
Simulation Development Engineer, Modeling and Simulation Technology
General Dynamics Land Systems
http://www.gdls.com


More information about the CMake mailing list