Skip to content

CMake build would delete the source file zconf.h #781

Open
@fredgan

Description

Hi, @madler
The CMake build would rename zconf.h to zconf.h.included.

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    zconf.h

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        build/
        zconf.h.included

Mostly this would not be a quesion. But sometimes, some build rules or system would require that source file should not be changed after the build.

The git blame shows that the rename part zconf.h in CMakeLists.txt is changed 10 years ago. Perhaps this part can be optimized.

 69 if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
 70     # If we're doing an out of source build and the user has a zconf.h
 71     # in their source tree...
 72     if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
 73         message(STATUS "Renaming")
 74         message(STATUS "    ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
 75         message(STATUS "to 'zconf.h.included' because this file is included with zlib")
 76         message(STATUS "but CMake generates it automatically in the build directory.")
 77         file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
 78   endif()
 79 endif()

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions