2.1.7.1.2 : Le CMakeLists.txt du test
Le fichier CMakeLists.txt permettra de compiler notre test unitaire et de le lancer avec la commande make test
Pour créer notre programme test_accord_shadok, il suffit d'appeler la fonction test_accord_shadok :
1 |
add_executable(test_accord_shadok main.cpp)
|
Ensuite, il faut dire à CMake qu'il dépend de la bibliothèque accord_shadok que nous avons créé précédemment :
1 |
target_link_libraries(test_accord_shadok accord_shadok)
|
Enfin nous pouvons créer notre test unitaire, qui appellera notre programme test_accord_shadok sur un make test :
1 2 3 |
add_test(NAME TestAccordShadok COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_accord_shadok WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
Le fichier CMakeLists.txt complet :
1 2 3 4 5 |
add_executable(test_accord_shadok main.cpp) target_link_libraries(test_accord_shadok accord_shadok) add_test(NAME TestAccordShadok COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_accord_shadok WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
Vous pouvez le télécharger ici.