[CMake] shared and static library
Xavier Delannoy
xavier.delannoy at netasq.com
Thu Feb 2 12:03:38 EST 2006
On Thu, 02 Feb 2006 16:38:52 +0000
Mike Talbot <mtalbot at abingdon.oilfield.slb.com> wrote:
> I think the short answer to your question is that you need separate
> build directories for shared and static (otherwise you may get name
> clashes, e.g. windows .lib files are produced for both shared and static
> builds).
I have tried this too. I have tried to put the Shared lib in the output directory 'Shared' and the Static lib in the output directory 'Static', with no success. Only the last type of lib which was build is present in the correct directory ;(
shortly, I want to reproduce this BSD Makefile with CMake:
DESTDIR = ${DESTDIRPREFIX}/usr
LIBDIR = /lib
LIB = mylib
SHLIB_NAME = libmylib.so
STLIB_NAME = libmylib.a
# don't build profiled library
DESTINC = /usr/include/libmylib
CFLAGS += -Werror -Wall -D_REENTRANT -D_THREAD_SAFE
CFLAGS += -I/usr/include -I${.CURDIR}/../.. -I${.CURDIR}/.. -I${.CURDIR}
.PATH: ${.CURDIR}/..
SRCS= file1.c file2.c file3.c
install-libs:
@echo ${BUILDDESTLIB}
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${SHLIB_NAME} ${BUILDDESTLIB}
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${STLIB_NAME} ${BUILDDESTLIB}
.include <bsd.lib.mk>
I think that's impossible with CMake, because TARGET_LINK_LIBRARIES have no option to link with the static or the shared lib.
CMake developpers, this will be very usefull to have :
ADD_LIBRARY(libname STATIC & SHARED libsrc) # build the two type and store them in the LIBRARY_OUTPUT_DIR
TARGET_LINK_LIBRARIES(target lib STATIC) # Link with the static lib
TARGET_LINK_LIBRARIES(target lib SHARED) # Link with the shared lib
best regards,
--
Xavier Delannoy
------------------------------------------------------------------------
More information about the CMake
mailing list