[CMake] shared and static library
Darko Miletic
darko at uvcms.com
Thu Feb 2 12:03:17 EST 2006
Xavier Delannoy wrote:
> this doesn't work, or maybe I do something wrong.
>
> When I do this:
> cd static_lib_dir && cmake . && make
> cd shared_lib_dir && cmake . && make
>
> In my LIBRARY_OUTPUT_PATH I have only have the last type of lib which
was build (in this case the shared type).
>
> Any suggestion ?
>
You misunderstood me. Both shared and static library must be suprojects
of global cmake project. So image is like this:
<root_source_dir> (here goes project root script)
|
|--<srcdir> (source files and sources.txt)
|
|--<static_lib_dir> (script for static lib goes here)
|
|--<shared_lib_dir> (script for shared lib goes here)
|
|--<build_dir> (you will build here)
root CMakeLists.txt script:
PROJECT(MyLib)
SUBDIRS(static_lib_dir)
SUBDIRS(shared_lib_dir)
static_lib CMakeLists.txt script:
INCLUDE(MyLib_SOURCE_DIR/srcdir/sources.txt)
ADD_LIBRARY(MyLibName STATIC ${SRCS})
shared_lib CMakeLists.txt script:
INCLUDE(MyLib_SOURCE_DIR/srcdir/sources.txt)
ADD_LIBRARY(MyLibName SHARED ${SRCS})
srcdir sources.txt :
SET (SRCS
../srcdir/a.cpp
../srcdir/b.cpp
../srcdir/c.cpp
../srcdir/d.cpp
...
../srcdir/x.cpp
)
Now go to build dir and execute this:
cmake -G<your generator> ../.
make
As a result you will have both libraries built at one time
More information about the CMake
mailing list