| 1 |
cmake_policy(SET CMP0140 NEW) |
| 2 |
function(UseDebugLibraries_check tgt udl_expect_debug udl_expect_release) |
| 3 |
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj") |
| 4 |
if(NOT EXISTS "${vcProjectFile}") |
| 5 |
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.") |
| 6 |
return() |
| 7 |
endif() |
| 8 |
|
| 9 |
set(have_udl_debug 0) |
| 10 |
set(have_udl_release 0) |
| 11 |
set(inConfig "") |
| 12 |
|
| 13 |
file(STRINGS "${vcProjectFile}" lines) |
| 14 |
foreach(line IN LISTS lines) |
| 15 |
if(line MATCHES [[^ *<PropertyGroup Condition="'\$\(Configuration\)\|\$\(Platform\)'=='([^"|]+)\|[^"]+" Label="Configuration">.*$]]) |
| 16 |
string(TOLOWER "${CMAKE_MATCH_1}" inConfig) |
| 17 |
elseif(inConfig) |
| 18 |
if(line MATCHES "^ *</PropertyGroup>.*$") |
| 19 |
set(inConfig "") |
| 20 |
elseif(line MATCHES "^ *<UseDebugLibraries>([^<>]+)</UseDebugLibraries>") |
| 21 |
set(udl_actual "${CMAKE_MATCH_1}") |
| 22 |
set(have_udl_${inConfig} 1) |
| 23 |
if (NOT "${udl_expect_${inConfig}}" STREQUAL "") |
| 24 |
if(NOT "${udl_actual}" STREQUAL "${udl_expect_${inConfig}}") |
| 25 |
string(APPEND RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has ${inConfig} UseDebugLibraries '${udl_actual}', not '${udl_expect_${inConfig}}'.\n") |
| 26 |
endif() |
| 27 |
else() |
| 28 |
string(APPEND RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has ${inConfig} UseDebugLibraries '${udl_actual}', but should not have one.\n") |
| 29 |
endif() |
| 30 |
unset(udl_actual) |
| 31 |
endif() |
| 32 |
endif() |
| 33 |
endforeach() |
| 34 |
|
| 35 |
if(NOT have_udl_debug AND NOT "${udl_expect_debug}" STREQUAL "") |
| 36 |
string(APPEND RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a debug UseDebugLibraries field, but should have one.\n") |
| 37 |
endif() |
| 38 |
if(NOT have_udl_release AND NOT "${udl_expect_release}" STREQUAL "") |
| 39 |
string(APPEND RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a release UseDebugLibraries field, but should have one.\n") |
| 40 |
endif() |
| 41 |
return(PROPAGATE RunCMake_TEST_FAILED) |
| 42 |
endfunction() |