forked from salsita/winunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
winunit.cmake
37 lines (25 loc) · 1.34 KB
/
winunit.cmake
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
# this script is used to create a unit test library
set(winunit_include "${CMAKE_CURRENT_LIST_DIR}/Include")
if(CMAKE_CL_64)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_LIST_DIR}/WinUnit64.exe" winunit_exe)
else(CMAKE_CL_64)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_LIST_DIR}/WinUnit32.exe" winunit_exe)
endif(CMAKE_CL_64)
macro(add_winunit_test libname)
file(GLOB test_files *.cpp *.h)
add_library(${libname}-test SHARED ${test_files})
add_definitions("-D_CRT_SECURE_NO_WARNINGS -D_UNICODE")
include_directories("${winunit_include}")
target_link_libraries(${libname}-test ${libname})
set_property(TARGET ${libname}-test PROPERTY RUNTIME_OUTPUT_DIRECTORY_RELEASE ${outdir_bin_release})
set_property(TARGET ${libname}-test PROPERTY RUNTIME_OUTPUT_DIRECTORY_DEBUG ${outdir_bin_debug})
set_property(TARGET ${libname}-test PROPERTY LIBRARY_OUTPUT_DIRECTORY_RELEASE ${outdir_bin_release})
set_property(TARGET ${libname}-test PROPERTY LIBRARY_OUTPUT_DIRECTORY_DEBUG ${outdir_bin_debug})
set_property(TARGET ${libname}-test PROPERTY ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${outdir_lib_release})
set_property(TARGET ${libname}-test PROPERTY ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${outdir_lib_debug})
add_custom_command(
TARGET ${libname}-test
POST_BUILD
COMMAND ${winunit_exe} \"$(TargetPath)\"
)
endmacro(add_winunit_test libname)