On Thu, 5 Apr 2007, Alan W. Irwin wrote:
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?

Sorry, I forgot to type these, indeed they are surrounded by "`"
This was [*] the statement:

 SET (XNPOSIX_USER_LDFLAGS "`${XENOMAI_INSTALL_PATH}/bin/xeno-config 
--posix-ldflags`")

[...]
[...]
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.

Unfortunately, this was not the case, the line continuation problem is
due to emacs (which I use for typing emails) in auto-fill-mode (I must have 
forgotten to turn it of when pasting the dynamic command)
I'll have a second try pasting the command now disabling autofill...

/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/al/ethercat_slave_handler.o" "CMakeFiles/eml-dynamic.dir/al/ethercat_AL.o" "CMakeFiles/eml-dynamic.dir/al/ethercat_router.o" 
"CMakeFiles/eml-dynamic.dir/al/ethercat_slave_conf.o" "CMakeFiles/eml-dynamic.dir/al/ethercat_mbx.o" "CMakeFiles/eml-dynamic.dir/al/ethercat_FSM.o" 
"CMakeFiles/eml-dynamic.dir/al/ethercat_master.o" "CMakeFiles/eml-dynamic.dir/dll/ethercat_slave_memory.o" "CMakeFiles/eml-dynamic.dir/dll/ethercat_telegram.o" 
"CMakeFiles/eml-dynamic.dir/dll/ethercat_dll.o" "CMakeFiles/eml-dynamic.dir/dll/ethercat_device_addressed_telegram.o" "CMakeFiles/eml-dynamic.dir/dll/ethercat_frame.o" 
"CMakeFiles/eml-dynamic.dir/dll/ethercat_logical_addressed_telegram.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

So that appears not to be the problem.

Thanks for your suggestion (and see [*] for a possible solution, although I 
don't understand yet why the above fails)!

Klaas

[*] Meanwhile, I found a way around the problem by using the EXEC_PROGRAM 
statement

[EMAIL PROTECTED]:~/SVN/eml-trunk #
  svn diff -r 24 CMakeLists.txt
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt      (revision 24)
+++ CMakeLists.txt      (working copy)
@@ -32,9 +32,8 @@
        LINK_DIRECTORIES(${XENOMAI_INSTALL_PATH}/lib)

        SET (XNPOSIX_USER_CFLAGS "`${XENOMAI_INSTALL_PATH}/bin/xeno-config 
--posix-cflags`")
-       SET (XNPOSIX_USER_LDFLAGS "`${XENOMAI_INSTALL_PATH}/bin/xeno-config 
--posix-ldflags`")
+       EXEC_PROGRAM ("${XENOMAI_INSTALL_PATH}/bin/xeno-config --posix-ldflags"
+         OUTPUT_VARIABLE XNPOSIX_USER_LDFLAGS)
 ENDIF (BUILD_FOR_RTNET)

 # Make sure the compiler can find include files from our library.
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to