Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,235
    • Issues 3,235
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 14
    • Merge Requests 14
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #19198

Closed
Open
Opened Apr 24, 2019 by Akos Denke@deeagle001

configure_file() and file(GENERATE) line ending changes on windows

Dear CMake developers,

I am using a build pattern, where I configure my files in CMake (configure_file()), then calling file(GENERATE) on them to evaluate generator expressions. The original file is being overwritten. My goal is to have LF line ending on every platform, as our third-party tool picky on that. It would be enough to keep the original line ending.

I am trying to do this in Windows, and I got a weird behavior.

If the configure_file() call does not define NEWLINE_STYLE parameter, then the line ending of the output file is not defined by the documentation. If I investigated well, then the CMake will pick the line ending of the underlying platform (Windows-CRLF, Unix-LF). As the CMake has no documentation for this case, some would expect that the line ending remains as it was in the input file, as no changing behavior was described. If we accept this behavior, then the control above the line ending can be handled by the user CMake code by specifying the NEWLINE_STYLE in every case.

But in the case of file(GENERATE) where the input file is provided, the line ending changes to the platform line ending, totally inhibiting the input's line endings. (Again, as there is no documented behavior about line ending changes, I would expect that the line ending remains as it is.) The bigger problem is, that there is no NEWLINE_STYLE parameter or equivalent for the case when the input is a file. As far as I know, there is no workaround other than dropping the support of generator expression evaluation and exclude the file.

Edited Dec 09, 2019 by Akos Denke
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: cmake/cmake#19198