Simplify test case creation
[oonf.git] / cmake / create_test.cmake
1 function (oonf_create_test executable source libraries)
2     # create executable
3     ADD_EXECUTABLE(${executable} ${source})
4
5     add_dependencies(build_tests ${executable})
6
7     TARGET_LINK_LIBRARIES(${executable} ${libraries})
8     TARGET_LINK_LIBRARIES(${executable} static_cunit)
9
10     # link regex for windows and android
11     IF (WIN32 OR ANDROID)
12         TARGET_LINK_LIBRARIES(${executable} oonf_regex)
13     ENDIF(WIN32 OR ANDROID)
14
15     # link extra win32 libs
16     IF(WIN32)
17         SET_TARGET_PROPERTIES(${executable} PROPERTIES ENABLE_EXPORTS true)
18         TARGET_LINK_LIBRARIES(${executable} ws2_32 iphlpapi)
19     ENDIF(WIN32)
20
21     ADD_TEST(NAME ${executable} COMMAND ${executable})
22 endfunction (oonf_create_test)