NewLineStyle-ValidArg.cmake 669 B

1234567891011121314151617181920212223242526272829
  1. set(file_name ${CMAKE_CURRENT_BINARY_DIR}/NewLineStyle.txt)
  2. function(test_eol style in out)
  3. if (style)
  4. set(newline_stle NEWLINE_STYLE ${style})
  5. endif()
  6. file(CONFIGURE
  7. OUTPUT ${file_name}
  8. CONTENT "@in@"
  9. ${newline_stle}
  10. )
  11. file(READ ${file_name} new HEX)
  12. if(NOT "${new}" STREQUAL "${out}")
  13. message(FATAL_ERROR "No ${style} line endings")
  14. endif()
  15. endfunction()
  16. test_eol(DOS "a" "610d0a")
  17. test_eol(WIN32 "b" "620d0a")
  18. test_eol(CRLF "c" "630d0a")
  19. test_eol(UNIX "d" "640a")
  20. test_eol(LF "e" "650a")
  21. if (WIN32)
  22. test_eol("" "a\nb" "610d0a62")
  23. elseif(UNIX)
  24. test_eol("" "a\nb" "610a62")
  25. endif()