summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake
blob: 27842f98e005ee663b881768a7635cfbc4b57d44 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
set(pch_header "CMakeFiles/tgt.dir/cmake_pch.hxx")
set(pch_source [=[CMakeFiles\\tgt.dir\\cmake_pch.cxx]=])

if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/${pch_header}")
  set(RunCMake_TEST_FAILED "Generated PCH header ${pch_header} does not exist.")
  return()
endif()
if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/${pch_source}")
  set(RunCMake_TEST_FAILED "Generated PCH header ${pch_source} does not exist.")
  return()
endif()

set(tgt_project "${RunCMake_TEST_BINARY_DIR}/tgt.vcxproj")
if (NOT EXISTS "${tgt_project}")
  set(RunCMake_TEST_FAILED "Generated project file ${tgt_project} doesn't exist.")
  return()
endif()

file(STRINGS ${tgt_project} tgt_projects_strings)

foreach(line IN LISTS tgt_projects_strings)
  if (line MATCHES "<PrecompiledHeader.*>Use</PrecompiledHeader>")
    set(have_pch_use ON)
  endif()

  if (line MATCHES "<PrecompiledHeader.*>Create</PrecompiledHeader>")
    set(have_pch_create ON)
  endif()

  if (line MATCHES "<PrecompiledHeaderFile.*>.*${pch_header}</PrecompiledHeaderFile>")
    set(have_pch_header ON)
  endif()

  if (line MATCHES "<ForcedIncludeFiles.*>.*${pch_header}</ForcedIncludeFiles>")
    set(have_force_pch_header ON)
  endif()

  if (line MATCHES "<ClCompile Include=.*${pch_source}\">")
    set(have_pch_source_compile ON)
  endif()
endforeach()

if (NOT have_pch_use)
  set(RunCMake_TEST_FAILED "Generated project should have the <PrecompiledHeader>Use</PrecompiledHeader> block.")
  return()
endif()

if (NOT have_pch_create)
  set(RunCMake_TEST_FAILED "Generated project should have the <PrecompiledHeader>Create</PrecompiledHeader> block.")
  return()
endif()

if (NOT have_pch_header)
  set(RunCMake_TEST_FAILED "Generated project should have the <PrecompiledHeaderFile>${pch_header}</PrecompiledHeaderFile> block.")
  return()
endif()

if (NOT have_force_pch_header)
  set(RunCMake_TEST_FAILED "Generated project should have the <ForcedIncludeFiles>${pch_header}</ForcedIncludeFiles> block.")
  return()
endif()

if (NOT have_pch_source_compile)
  set(RunCMake_TEST_FAILED "Generated project should have the <ClCompile Include=\"${pch_source}\"> block.")
  return()
endif()