[CMake] faking convenience libraries
Brandon J. Van Every
bvanevery at gmail.com
Fri Jan 19 13:27:58 EST 2007
We need to compile the same underlying code 7 times for 7 different
libraries. 3 of the resulting libs are dynamic and 4 are static. We
would use "convenience libraries" to do this, if it were portable and
available in CMake. We understand that "ar" in particular can't include
static libraries in other static libraries. How can we reduce the
number of times we have to compile this code, without getting into a lot
of hairy details? Currently we do like the following:
####################################################################
# PCRE LIBRARY #
####################################################################
# The PCRE code is used several times by the various Chicken libraries.
It is tempting to create a
# PCRE library to be used by other Chicken libraries. However, CMake
doesn't support so-called
# "Convenience Libraries." Static libraries can't include other static
libraries as a component, at least
# not in a portable manner. In particular, "ar" can't handle this. So
we take the path of least
# resistance and just explicitly include the source files in all the
libraries we build.
#
# TODO: see if there's a way to reduce the number of times we must
compile the PCRE code.
SET(PCRE_SOURCES
chartables.c
config.h
pcre.h
pcre_compile.c
pcre_config.c
pcre_dfa_exec.c
pcre_exec.c
pcre_fullinfo.c
pcre_get.c
pcre_globals.c
pcre_internal.h
pcre_maketables.c
pcre_ord2utf8.c
pcre_printint.c
pcre_refcount.c
pcre_study.c
pcre_tables.c
pcre_try_flipped.c
pcre_ucp_findchar.c
pcre_valid_utf8.c
pcre_version.c
pcre_xclass.c
)
ADD_PREFIX(${Chicken_SOURCE_DIR}/pcre/ PCRE_SOURCES)
SET(STATIC_FLAGS "${STATIC_FLAGS} -DPCRE_STATIC")
[...]
ADD_LIBRARY(libchicken SHARED ${CHICKEN_LIB_SOURCES} ${PCRE_SOURCES})
[and so forth]
Cheers,
Brandon Van Every
More information about the CMake
mailing list