[CMake] strange build problems
Klaas Gadeyne
klaas.gadeyne at fmtc.be
Thu Apr 5 08:59:39 EDT 2007
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
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?
Klaas
More information about the CMake
mailing list