Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Definitively remove old variable PROJECT_DIRECTORY for CMAKE_HOME_DIRECTORY.
[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 )
17 set(TEST_UNITS
18         ${CMAKE_CURRENT_BINARY_DIR}/src/cunit_unit.c
19         ${CMAKE_CURRENT_BINARY_DIR}/src/ex_unit.c
20         ${CMAKE_CURRENT_BINARY_DIR}/src/dynar_unit.c
21         ${CMAKE_CURRENT_BINARY_DIR}/src/dict_unit.c
22         ${CMAKE_CURRENT_BINARY_DIR}/src/set_unit.c
23         ${CMAKE_CURRENT_BINARY_DIR}/src/swag_unit.c
24         ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_str_unit.c
25         ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_strbuff_unit.c
26         ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_sha_unit.c
27         ${CMAKE_CURRENT_BINARY_DIR}/src/config_unit.c
28         ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_synchro_unit.c
29         
30         ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_units_main.c
31 )
32
33
34
35 if(PERL_EXECUTABLE)
36         
37         ADD_CUSTOM_COMMAND(
38                 OUTPUT  ${TEST_UNITS}
39                         
40                 DEPENDS ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
41                         ${TEST_CFILES}
42         
43                 COMMAND ${CMAKE_COMMAND} -E remove -f ${TEST_UNITS}
44         
45                 COMMAND chmod +x ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
46         
47                 COMMAND ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl --root=src/ --outdir=${CMAKE_CURRENT_BINARY_DIR}/src/ ${TEST_CFILES}
48         
49                 WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
50         
51                 COMMENT "Generating *_units files for testall..."
52         )
53         
54         
55 else(PERL_EXECUTABLE)
56         ADD_CUSTOM_COMMAND(
57         OUTPUT  ${TEST_UNITS}
58                         
59         DEPENDS ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
60                 ${TEST_CFILES}
61                         
62         COMMAND ${CMAKE_COMMAND} message WARNING "Unit files need to be regenerated, but no Perl installed")
63 endif(PERL_EXECUTABLE)
64
65
66
67
68 ### Ensure the build of testall
69
70 set_source_files_properties(${TEST_UNITS} PROPERTIES GENERATED true)
71
72 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/src/")
73 add_executable(testall ${TEST_UNITS})
74
75 ### Add definitions for compile
76 if(NOT WIN32)
77     target_link_libraries(testall gras m)
78 else(NOT WIN32)
79     target_link_libraries(testall gras)
80 endif(NOT WIN32)
81         
82 add_dependencies(testall $(TEST_UNITS))