Bonjour a tous,
Mon problème est plus ou moins résumé dans le titre, mais je vais le détailler. Je suis novice dans le développement d'une chaîne de compilation avec cmake et je bloque sur le point suivant:
je souhaite appeler une fonction qui possède un paramètre depuis un command add_custom_target, et le soucis et bien c'est que la fonction ne semble pas appelée...
Voici mon CMakeLists.txt il fonctionne bien modulo le dernier add_custom_target (build + exécution de l’exécutable):
Code CMakeLists : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 cmake_minimum_required(VERSION 3.7.2) project(tests) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) include(run_plus) set(TEST_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set(TEST_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc) set(TESTS_SRCS ${TEST_SRC_DIR}/main.cpp ) add_executable(tests.exe ${TESTS_SRCS}) target_include_directories(tests.exe PUBLIC ${TEST_INC_DIR} /tools/exec/CppUnit/cppunit-1.12.0/include ) #find_library(libcppunit cppunit) find_library(libcppunit cppunit PATHS /tools/exec/CppUnit/cppunit-1.12.0/lib) if(NOT libcppunit) message(FATAL_ERROR "cppunit library not found") endif() target_link_libraries(tests.exe ${libcppunit} ) #--coverage target_compile_options(tests.exe PUBLIC -fprofile-arcs -ftest-coverage) #run tests add_custom_target(run_tests command ${CMAKE_CURRENT_BINARY_DIR}/tests.exe ) add_dependencies(run_tests tests.exe) add_custom_target(run_tests_plus command ${CMAKE_COMMAND} run_plus -D TARGET_NAME=tests.exe -P /home/bibi/projects/cmake/run_plus.cmake ) add_dependencies(run_tests_plus run_tests)
voici le script run_plus.cmake
Code CMakeLists : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 function(run_plusTARGET_NAME) get_target_property(TARGET_SRC_FILES ${TARGET_NAME} SOURCES) message(FATAL_ERROR "${SOURCES}") endfunction(run_gcov)
J'ai essayé un peu toutes les commandes proposées sur les différentes sites internet et là je sèche...
- command ${CMAKE_COMMAND} run_plus -D TARGET_NAME=tests.exe
- command ${CMAKE_COMMAND} -D TARGET_NAME=tests.exe -P /home/bibi/projects/cmake/run_plus.cmake
- command ${CMAKE_COMMAND} run_plus -D TARGET_NAME=tests.exe -P /home/bibi/projects/cmake/run_plus.cmake
Je ne suis peut-être pas obligé de passer par un add_custom_target, mais il faut forcement que cela s’exécute après la target run_tests car celle-ci génère les fichiers à post-traiter par la suite pas la fonction run_plus.
Merci par avance![]()
Partager