[CMake] strange build problems

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu Apr 5 12:26:40 EDT 2007


On 2007-04-05 14:59+0200 Klaas Gadeyne wrote:

> Hi,
>
> I'm trying to build a library.  I have created 2 options, in order to
> allow static or dynamic linking in a CMakeLists.txt file .
>
> # Settings for building a dynamic library (.so/.dll)
>  OPTION(BUILD_DYNAMIC "Build EML as a dynamic library (Default)." ON)
>  IF( BUILD_DYNAMIC)
>    ADD_LIBRARY(eml-dynamic SHARED ${eml_SRCS})
>    SET_TARGET_PROPERTIES(eml-dynamic
>      PROPERTIES OUTPUT_NAME eml LINK_FLAGS "${XNPOSIX_USER_LDFLAGS}"
>      CLEAN_DIRECT_OUTPUT 1)
>    INSTALL_TARGETS(/lib eml-dynamic)
>  ENDIF (BUILD_DYNAMIC)
>
>  # Settings for building a static library (.a)
>  OPTION(BUILD_STATIC "Build EML as a static library." OFF)
>  IF ( BUILD_STATIC )
>    ADD_LIBRARY(eml-static STATIC ${eml_SRCS})
>    SET_TARGET_PROPERTIES(eml-static
>      PROPERTIES OUTPUT_NAME eml LINK_FLAGS "${XNPOSIX_USER_LDFLAGS}"
>      CLEAN_DIRECT_OUTPUT 1)
>    INSTALL_TARGETS(/lib eml-static)
>  ENDIF ( BUILD_STATIC )
>
>
> The ${XNPOSIX_USER_LDFLAGS} variable actually expands to a shell
> command
>
> /root/install/xenomai-trunk-2.4.33-ipipe-1.2-08//bin/xeno-config 
> --posix-ldflags

Is that really true, or is that command surrounded by "`" symbols?

>
> Executing it results in
> # /root/install/xenomai-trunk-2.4.33-ipipe-1.2-08//bin/xeno-config 
> --posix-ldflags
> -Wl,@/root/install/xenomai-trunk-2.4.33-ipipe-1.2-08/lib/posix.wrappers
> -L/root/install/xenomai-trunk-2.4.33-ipipe-1.2-08/lib -lpthread_rt -lpthread 
> -lrt -rdynamic
>
> Trying to build the static library works out just fine,  it results in
> [...]
> cd /root/SVN/eml-trunk/buildclean/tests/rtnet && /usr/bin/g++-3.4
> -fPIC `/root/install/xenomai-trunk-2.4.33-ipipe-1.2-08//bin/xen\
> o-config --posix-ldflags` "CMakeFiles/eval_test.dir/eval_test.o"
> "CMakeFiles/eval_test.dir/process_data.o"   -o eval_test -rdynamic -L\
> /root/install/xenomai-trunk-2.4.33-ipipe-1.2-08/lib
> -L/root/SVN/eml-trunk/buildclean/src -leml -lnative
> -Wl,-rpath,/root/install/xenom\
> ai-trunk-2.4.33-ipipe-1.2-08/lib:/root/SVN/eml-trunk/buildclean/src
>
> However, when trying to compile the dynamic version and invoking make,
> I get a build error:
>
> [...]
> cd /root/SVN/eml-trunk/buildclean/src && /usr/bin/cmake -E
> cmake_link_script CMakeFiles/eml-dynamic.dir/link.txt --verbose=1
> /usr/bin/g++-3.4  -fPIC
> `/root/install/xenomai-trunk-2.4.33-ipipe-1.2-08//bin/xeno-config
> --posix-ldflags` -shared -Wl,-soname,libeml.so -o libeml.so
> "CMakeFiles/eml-dynamic.dir/al/ethercat_process_data.o" [...]
> "CMakeFiles/eml-dynamic.dir/arch/RTnet/ethercat_xenomai_drv.o"
> -L/root/install/xenomai-trunk-2.4.33-ipipe-1.2-08/lib
> g++-3.4:
> `/root/install/xenomai-trunk-2.4.33-ipipe-1.2-08//bin/xeno-config: No
> such file or directory
>
> Instead of _evaluating_ the xeno-config command, g++ is apparently looking 
> for a file with the name
> `/root/install/xenomai-trunk-2.4.33-ipipe-1.2-08//bin/xeno-config
> which it obviously doesn't find.
>
> Cutting and pasting the above command to the command line works out
> fine and a second make then succeeds.
>
> Can anyone guess what I did wrong here?

I am not sure, but one thing I noticed is that your static build did the
line continuation correctly, i.e.,

...ipipe-1.2-08//bin/xen\

while your dynamic build did not

...1.2-08//bin/xeno-config

(note, no trailing "\" to continue to the next line).  So your starting "`"
for the dynamic library build had no trailing matching "`" which lead to the
peculiar error message.

So assuming that ${XNPOSIX_USER_LDFLAGS} is a shell command surrounded by
"`" (so that the command will be executed and its results used for linking
flags), then I think the question boils down to why is the line continuation
screwed up (apparently by CMake) for the dynamic library case?  This might
well be some obscure CMake bug, but I am not sufficiently familiar with
the CMake internals to know for sure.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list