[CMake] 'make test' doesn't build cppunit test executable
apervukh at minet.uni-jena.de
apervukh at minet.uni-jena.de
Mon Mar 26 06:54:22 EST 2007
Hi all!
I'm trying to integrate cppunit tests using cmake in our ims library and
cannot solve the problem how to build tests executables only by demand,
i.e. by calling 'make test'. I'm quite new to cmake and don't know if this
is possible at all, but I suppose it should be possible :-)
I have found some related issues, i.e. this thread,
http://www.cmake.org/pipermail/cmake/2007-March/013242.html, but that
didn't help much.
I followed the steps to enable testing as described in cmake tutorial (or
here is another link I followed
http://techbase.kde.org/index.php?title=Development/Tutorials/Unittests&printable=yes#Tutorial_6:_Integrating_with_CMake)
namely:
1. enable testing in main CMakeLists.txt
2. add test in tests/CMakeLists.txt, here is it:
# sets test sources
set(IMSLIB_TESTS
tests.cpp
alphabettest.cpp
elementtest.cpp)
add_executable(imslib-tests ${IMSLIB_TESTS})
target_link_libraries(imslib-tests ${CPPUNIT_LIBRARIES} ims)
add_test(imslib-tests ${CMAKE_CURRENT_SOURCE_DIR}/imslib-tests)
If this is all what I do, then running 'make test' gives error
...
1/ 1 Testing imslib-tests Unable to find executable:
/home/imslib/tests/imslib-tests
...
so executable is not even built.
If I add tests directory to project subdirectories (in main
CMakeLists.txt) via
add_subdirectory(tests)
then obviously already calling 'make' tries to build executable. In this
case building and calling tests succeed, but I don't want to build tests
already by calling 'make', instead give users the opportunity to build
them by demand.
I also tried to add tests directory via add_subdirectory(tests
EXLCUDE_FROM_ALL) but that again didn't build test by calling 'make test'.
It looks like running 'make test' doesn't see the dependency that the
library should be first built and then run, not just run.
Do I oversee something?
Thank you in advance!
Anton
More information about the CMake
mailing list