UnityBuildPre2017-check.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c")
  2. if(NOT EXISTS "${unitybuild_c0}")
  3. set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c0} does not exist.")
  4. return()
  5. endif()
  6. set(tgt_project "${RunCMake_TEST_BINARY_DIR}/tgt.vcxproj")
  7. if (NOT EXISTS "${tgt_project}")
  8. set(RunCMake_TEST_FAILED "Generated project file ${tgt_project} doesn't exist.")
  9. return()
  10. endif()
  11. file(STRINGS ${tgt_project} tgt_projects_strings)
  12. foreach(line IN LISTS tgt_projects_strings)
  13. if (line MATCHES "<ClCompile Include=.*/>")
  14. set(unity_source_line ${line})
  15. endif()
  16. if (line MATCHES "<ClCompile Include=\"[^\"]*\">")
  17. string(REGEX MATCH "<ClCompile Include=\"([^\"]*)\">" source_file ${line})
  18. list(APPEND sources_list ${source_file})
  19. endif()
  20. if (line MATCHES "<ExcludedFromBuild.*</ExcludedFromBuild>")
  21. list(APPEND excluded_sources_list ${source_file})
  22. endif()
  23. endforeach()
  24. string(REPLACE "\\" "/" unity_source_line ${unity_source_line})
  25. string(FIND "${unity_source_line}" "CMakeFiles/tgt.dir/Unity/unity_0_c.c" unity_source_file_position)
  26. if (unity_source_file_position EQUAL "-1")
  27. set(RunCMake_TEST_FAILED "Generated project should include the generated unity source file.")
  28. return()
  29. endif()
  30. list(LENGTH sources_list number_of_sources)
  31. if(NOT number_of_sources EQUAL 8)
  32. set(RunCMake_TEST_FAILED "Generated project doesn't include the expect number of files.")
  33. return()
  34. endif()
  35. # Exclusions for Debug|Release|MinSizeRel|RelWithDebInfo
  36. list(LENGTH excluded_sources_list number_of_excluded_sources)
  37. if(NOT number_of_excluded_sources EQUAL 32)
  38. set(RunCMake_TEST_FAILED "Generated project doesn't exclude the source files for all configurations.")
  39. return()
  40. endif()