[cmake-developers] RFC - new module for multilib configuration
Faraz Shahbazker
Faraz.Shahbazker at imgtec.com
Wed Apr 23 03:33:56 EDT 2014
Hi all,
I've been working on a generic cmake stub that allows libraries to be
built with multiple configuration options a.k.a. multilib support in the
style of GCC, on behalf of my employer. This feature allows a user to
build multiple versions of the same library from the same source base
but compiled with different options and ABIs. Automake provides a
similar feature via macros in multilib.am.
May not seem very useful for desktops, but its pertinent for
embedded/cross development. Typical ARM/MIPS toolchains supply a dozen
multilib configurations, at least. I'd restrict the module to work with
GNU CC, but it seems to play along just fine with LLVM Clang compiler,
which has a gcc-compatible command-line.
Please review the attached module. Pasting an example in-line to
hopefully pique someone's interest.
Regards,
Faraz Shahbazker
Imagination Technologies
###########
# Example Usage
###########
set(sources_math sin.c cos.s floor.c ...)
include(MultiLibConfig)
# Initializer
multilib_build_setup()
if (MULTILIB_TOP)
<Do everything you'd want to do only once, like installing headers,
top-level checks, etcetra>
else () # MULTILIB_TOP
## This block is automagically repeated for each multilib configuration
# Creates target, sets compiler flags & a handle for the user to
override target properties later.
# Signature is same as add_library()
multilib_add_library(m STATIC ${sources_math})
# Use the target handle `MULTILIB_TARGET_m' for customization
set_target_properties(${MULTILIB_TARGET_m} PROPERTIES OUTPUT_NAME mymath)
# Install, once again using the current target handle
install(TARGETS ${MULTILIB_TARGET_m} ARCHIVE DESTINATION
lib/${MULTILIB_DIR})
endif () # MULTILIB_TOP
## Configure with
## cmake -DMULTILIB_SELECT="ALL" <srcdir>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MultiLibConfig.cmake
Type: text/x-cmake
Size: 8228 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20140423/7a632150/attachment.bin>
More information about the cmake-developers
mailing list