Aws-sdk-cpp: CMake changes line endings of core/VersionConfig.h

Created on 24 Jun 2019  ·  3Comments  ·  Source: aws/aws-sdk-cpp

Version 1.7.0 introduced a parameter to the configure_file() call in aws-cpp-sdk-core/CMakeLists.txt that forces the re-generated VersionConfig.h file to Unix line endings (LF). This was done in commit ffd81252bec92f3e0587e144b07c05f8aed28eb1 and the commit message gives no indication why this change was necessary.

The effect of this is that when building the SDK on a clean checkout with Windows line endings (eg. on a Windows machine that has git configured to core.autocrlf=true), the re-generated header file will be marked as modified by git because of the change in line endings. Granted, this is only a nuisance, but an unnecessary one.

I see three options here:

  • Have CMake generate the files with the correct (native) line endings. I assume that there was a reason for introducing the current behavior of forced Unix line endings, so this is probably not an option.
  • Have git always check out the file with Unix line endings, even on Windows machines with core.autocrlf=true. This can be achieved by adding a .gitattributes file that lists the VersionConfig.h as text eol=lf. That way, the header file will always be checked out with Unix line endings, so overwriting it from CMake will result in the exact same file again.
  • Write the generated header to the build tree instead of the source tree. That is, instead of having configure_file write to CMAKE_CURRENT_SOURCE_DIR, introduce a second include directory that lives under CMAKE_BINARY_DIR and write the generated file to that one. This is the idiomatic CMake solution, as it keeps generated build artifacts out of the source tree, but it slightly complicates handling of the generated files for include and install.
bug

Most helpful comment

Hi @ComicSansMS ,
thanks again for pointing this out, the fix has been committed and published in version 1.7.139

All 3 comments

That was an unforced error. We'll get it fixed. We can simply remove the optional NEWLINE_STYLE argument in core's CMakeLists.txt

Perfect, thanks a lot!

Hi @ComicSansMS ,
thanks again for pointing this out, the fix has been committed and published in version 1.7.139

Was this page helpful?
0 / 5 - 0 ratings