[CMake] Running tests
Olivier Tournaire
olitour at gmail.com
Sun Feb 17 21:51:52 EST 2008
Hi all,
Maybe it is a simple question, but I really have no answer. So, hope you
could help me.
Here is my directories tree :
|_ src __
| |_ geometrie
| |_ truc
|
|_ test __
|_ geometrie
|_ truc
In test, I have this CMakeLists.txt :
-------------------------------------------------------------------------------------------------
PROJECT (Unit_Tests)
ENABLE_TESTING()
SET ( ENABLETESTING ON )
# Necessite BOOST pour travailler
INCLUDE_DIRECTORIES( E:/librairies/boost_1_34_1 )
# Necessite CPPUNIT pour le framework de tests
INCLUDE_DIRECTORIES( E:/librairies/cppunit-1.12.0/include )
LINK_DIRECTORIES( E:/librairies/cppunit-1.12.0/lib )
# Inclusion des répertoires qui contiennent les tests à réaliser
ADD_SUBDIRECTORY( geometrie )
ADD_SUBDIRECTORY( truc )
-------------------------------------------------------------------------------------------------
Then, in test/geometrie, I have this CMakeLists.txt :
-------------------------------------------------------------------------------------------------
PROJECT (Droites_Test_Project)
SET(DROITES_SRC ../../src/geometrie/Droites.cpp
Main_Test_Droites.cpp
DroitesTest.cpp)
SET(DROITES_INCLUDE ../../src/geometrie/Droites.hpp
DroitesTest.hpp)
ADD_EXECUTABLE(Test_Droites ${DROITES_SRC} ${DROITES_INCLUDE})
TARGET_LINK_LIBRARIES(Test_Droites cppunit.lib )
IF( ENABLETESTING )
ADD_TEST(Droites_Test Test_Droites)
ELSE( ENABLETESTING )
ENDIF( ENABLETESTING )
-------------------------------------------------------------------------------------------------
Finally, in test/truc, I have this CMakeLists.txt :
-------------------------------------------------------------------------------------------------
PROJECT (Truc_Test_Projet)
SET(TRUC_SRC main.cpp)
ADD_EXECUTABLE(Test_Truc ${TRUC_SRC})
TARGET_LINK_LIBRARIES(Test_Truc)
IF( ENABLETESTING )
ADD_TEST( Truc_Test Test_Truc )
ELSE( ENABLETESTING )
ENDIF( ENABLETESTING )
-------------------------------------------------------------------------------------------------
When I run CMake on the CMakeLists.txt which is in the test folder, I
got a .sln with 4 projects : ALL_BUILD, RUN_TESTS, Test_Droites,
Test_Truc. I am able to create executable binaries from the both lasts
and then run RUN_TESTS which work.
However, I have no dependencies between Test_Droites, Test_Truc and
RUN_TESTS, which means I have to build all projects to test before
running RUN_TESTS. Is there a way to have only to build RUN_TESTS, in
order to build the projects to tests and then launch the "tester" ?
Hope I am enough clear ...
Regards,
Olivier
More information about the CMake
mailing list