| 1 |
#Copyright (c) Microsoft. All rights reserved. |
| 2 |
#Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 |
|
| 4 |
function(umockc_windows_unittests_add_dll whatIsBuilding) |
| 5 |
link_directories(${whatIsBuilding}_dll $ENV{VCInstallDir}UnitTest/lib) |
| 6 |
|
| 7 |
add_library(${whatIsBuilding}_dll SHARED |
| 8 |
${${whatIsBuilding}_test_files} |
| 9 |
${${whatIsBuilding}_h_files} |
| 10 |
${${whatIsBuilding}_c_files} |
| 11 |
) |
| 12 |
|
| 13 |
set_target_properties(${whatIsBuilding}_dll |
| 14 |
PROPERTIES |
| 15 |
FOLDER "tests/umockc_tests") |
| 16 |
|
| 17 |
target_include_directories(${whatIsBuilding}_dll PUBLIC ${sharedutil_include_directories} $ENV{VCInstallDir}UnitTest/include) |
| 18 |
target_compile_definitions(${whatIsBuilding}_dll PUBLIC -DCPP_UNITTEST) |
| 19 |
SET_SOURCE_FILES_PROPERTIES( ${${whatIsBuilding}_test_files} PROPERTIES LANGUAGE CXX ) |
| 20 |
target_link_libraries(${whatIsBuilding}_dll ctest testrunnerswitcher ${ARGN}) |
| 21 |
endfunction() |
| 22 |
|
| 23 |
function(umockc_windows_unittests_add_lib whatIsBuilding) |
| 24 |
link_directories(${whatIsBuilding}_lib $ENV{VCInstallDir}UnitTest/lib) |
| 25 |
|
| 26 |
add_library(${whatIsBuilding}_lib STATIC |
| 27 |
${${whatIsBuilding}_test_files} |
| 28 |
${${whatIsBuilding}_h_files} |
| 29 |
${${whatIsBuilding}_c_files} |
| 30 |
) |
| 31 |
|
| 32 |
set_target_properties(${whatIsBuilding}_lib |
| 33 |
PROPERTIES |
| 34 |
FOLDER "tests/umockc_tests") |
| 35 |
|
| 36 |
target_include_directories(${whatIsBuilding}_lib PUBLIC ${sharedutil_include_directories}) |
| 37 |
target_compile_definitions(${whatIsBuilding}_lib PUBLIC -DUSE_CTEST) |
| 38 |
target_link_libraries(${whatIsBuilding}_lib ctest testrunnerswitcher ${ARGN}) |
| 39 |
endfunction() |
| 40 |
|
| 41 |
function(umockc_windows_unittests_add_exe whatIsBuilding) |
| 42 |
add_executable(${whatIsBuilding}_exe |
| 43 |
${${whatIsBuilding}_test_files} |
| 44 |
${${whatIsBuilding}_h_files} |
| 45 |
${${whatIsBuilding}_c_files} |
| 46 |
${CMAKE_CURRENT_LIST_DIR}/main.c |
| 47 |
) |
| 48 |
set_target_properties(${whatIsBuilding}_exe |
| 49 |
PROPERTIES |
| 50 |
FOLDER "tests/umockc_tests") |
| 51 |
|
| 52 |
target_compile_definitions(${whatIsBuilding}_exe PUBLIC -DUSE_CTEST) |
| 53 |
target_include_directories(${whatIsBuilding}_exe PUBLIC ${sharedutil_include_directories}) |
| 54 |
target_link_libraries(${whatIsBuilding}_exe ctest testrunnerswitcher ${ARGN}) |
| 55 |
add_test(NAME ${whatIsBuilding} COMMAND ${whatIsBuilding}_exe) |
| 56 |
endfunction() |
| 57 |
|
| 58 |
function(umockc_build_test_artifacts whatIsBuilding use_gballoc) |
| 59 |
|
| 60 |
#the first argument is what is building |
| 61 |
#the second argument is whether the tests should be build with gballoc #defines or not |
| 62 |
#the following arguments are a list of libraries to link with |
| 63 |
|
| 64 |
if(${use_gballoc}) |
| 65 |
add_definitions(-DGB_MEASURE_MEMORY_FOR_THIS -DGB_DEBUG_ALLOC) |
| 66 |
else() |
| 67 |
endif() |
| 68 |
|
| 69 |
#setting #defines |
| 70 |
if(WIN32) |
| 71 |
add_definitions(-D_CRT_SECURE_NO_WARNINGS) |
| 72 |
else() |
| 73 |
endif() |
| 74 |
|
| 75 |
#setting includes |
| 76 |
set(sharedutil_include_directories ${MICROMOCK_INC_FOLDER} ${TESTRUNNERSWITCHER_INC_FOLDER} ${CTEST_INC_FOLDER} ${SAL_INC_FOLDER} ${SHARED_UTIL_INC_FOLDER} ${SHARED_UTIL_SRC_FOLDER}) |
| 77 |
if(WIN32) |
| 78 |
else() |
| 79 |
include_directories(${sharedutil_include_directories}) |
| 80 |
endif() |
| 81 |
|
| 82 |
#setting output type |
| 83 |
if(WIN32) |
| 84 |
if( |
| 85 |
(("${whatIsBuilding}" MATCHES ".*ut.*") AND ${run_unittests}) OR |
| 86 |
(("${whatIsBuilding}" MATCHES ".*int.*") AND ${run_int_tests}) |
| 87 |
) |
| 88 |
umockc_windows_unittests_add_exe(${whatIsBuilding} ${ARGN}) |
| 89 |
if (${use_cppunittest}) |
| 90 |
umockc_windows_unittests_add_dll(${whatIsBuilding} ${ARGN}) |
| 91 |
endif() |
| 92 |
endif() |
| 93 |
else() |
| 94 |
if( |
| 95 |
(("${whatIsBuilding}" MATCHES ".*ut.*") AND ${run_unittests}) OR |
| 96 |
(("${whatIsBuilding}" MATCHES ".*int.*") AND ${run_int_tests}) |
| 97 |
) |
| 98 |
umockc_windows_unittests_add_exe(${whatIsBuilding} ${ARGN}) |
| 99 |
endif() |
| 100 |
endif() |
| 101 |
endfunction() |