Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix win installer
[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   )
16 set(TEST_UNITS
17   ${CMAKE_CURRENT_BINARY_DIR}/src/cunit_unit.c
18   ${CMAKE_CURRENT_BINARY_DIR}/src/ex_unit.c
19   ${CMAKE_CURRENT_BINARY_DIR}/src/dynar_unit.c
20   ${CMAKE_CURRENT_BINARY_DIR}/src/dict_unit.c
21   ${CMAKE_CURRENT_BINARY_DIR}/src/set_unit.c
22   ${CMAKE_CURRENT_BINARY_DIR}/src/swag_unit.c
23   ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_str_unit.c
24   ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_strbuff_unit.c
25   ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_sha_unit.c
26   ${CMAKE_CURRENT_BINARY_DIR}/src/config_unit.c
27
28   ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_units_main.c
29   )
30
31 ADD_CUSTOM_COMMAND(
32   OUTPUT        ${TEST_UNITS}
33
34   DEPENDS       ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
35   ${TEST_CFILES}
36
37   COMMAND       ${CMAKE_COMMAND} -E remove -f ${TEST_UNITS}
38
39   COMMAND chmod +x ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
40
41   COMMAND ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl --root=src/ --outdir=${CMAKE_CURRENT_BINARY_DIR}/src/ ${TEST_CFILES}
42
43   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
44
45   COMMENT "Generating *_units files for testall..."
46   )
47
48 ### Ensure the build of testall
49
50 set_source_files_properties(${TEST_UNITS} PROPERTIES GENERATED true)
51
52 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/src/")
53 add_executable(testall ${TEST_UNITS})
54
55 ### Add definitions for compile
56 if(NOT WIN32)
57   target_link_libraries(testall simgrid m)
58 else()
59   target_link_libraries(testall simgrid)
60 endif()
61
62 add_dependencies(testall ${TEST_UNITS})