Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
746596e7a70c9d237982dde80a43faaad1f818c5
[simgrid.git] / buildtools / Cmake / UnitTesting.cmake
1 # To add a new tested file, simply add the original file in
2 # TEST_CFILES and generated file in TEST_UNITS. The rest is automatic.
3
4 set(TEST_CFILES
5   src/xbt/cunit.c
6   src/xbt/ex.c
7   src/xbt/dynar.c
8   src/xbt/dict.c
9   src/xbt/set.c
10   src/xbt/swag.c
11   src/xbt/xbt_str.c
12   src/xbt/xbt_strbuff.c
13   src/xbt/xbt_sha.c
14   src/xbt/config.c
15   src/xbt/xbt_synchro.c
16   src/xbt/parmap.c
17   )
18 set(TEST_UNITS
19   ${CMAKE_CURRENT_BINARY_DIR}/src/cunit_unit.c
20   ${CMAKE_CURRENT_BINARY_DIR}/src/ex_unit.c
21   ${CMAKE_CURRENT_BINARY_DIR}/src/dynar_unit.c
22   ${CMAKE_CURRENT_BINARY_DIR}/src/dict_unit.c
23   ${CMAKE_CURRENT_BINARY_DIR}/src/set_unit.c
24   ${CMAKE_CURRENT_BINARY_DIR}/src/swag_unit.c
25   ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_str_unit.c
26   ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_strbuff_unit.c
27   ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_sha_unit.c
28   ${CMAKE_CURRENT_BINARY_DIR}/src/config_unit.c
29   ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_synchro_unit.c
30   ${CMAKE_CURRENT_BINARY_DIR}/src/parmap_unit.c
31
32   ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_units_main.c
33   )
34
35 ADD_CUSTOM_COMMAND(
36   OUTPUT        ${TEST_UNITS}
37
38   DEPENDS       ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
39   ${TEST_CFILES}
40
41   COMMAND       ${CMAKE_COMMAND} -E remove -f ${TEST_UNITS}
42
43   COMMAND chmod +x ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
44
45   COMMAND ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl --root=src/ --outdir=${CMAKE_CURRENT_BINARY_DIR}/src/ ${TEST_CFILES}
46
47   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
48
49   COMMENT "Generating *_units files for testall..."
50   )
51
52 ### Ensure the build of testall
53
54 set_source_files_properties(${TEST_UNITS} PROPERTIES GENERATED true)
55
56 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/src/")
57 add_executable(testall ${TEST_UNITS})
58
59 ### Add definitions for compile
60 if(NOT WIN32)
61   target_link_libraries(testall gras m)
62 else()
63   target_link_libraries(testall gras)
64 endif()
65
66 add_dependencies(testall ${TEST_UNITS})