zlib icon indicating copy to clipboard operation
zlib copied to clipboard

Use PROJECT_SOURCE_DIR for cmake include_directories

Open schultetwin1 opened this issue 5 years ago • 2 comments

The current usage of the CMAKE_SOURCE_DIR variable causes build breaks when compiling zlib in a subdirectory of the CMake tree. Instead of using CMAKE_SOURCE_DIR, we can use PROJECT_SOURCE_DIR to represent the root directory of where the ZLIB cmake project was declared.

Note, this removes the need to special case include directories for MSVC.

schultetwin1 avatar Feb 04 '20 04:02 schultetwin1

I would have used CMAKE_CURRENT_SOURCE_DIR instead of PROJECT_SOURCE_DIR but other than that I also recommend to merge this simple PR, because it fixes long standing build problems with the add_subdirectory case and does not break the "build-alone" case.

DenizThatMenace avatar Dec 07 '21 16:12 DenizThatMenace

Hi schultetwin1,

I came up with the changes in this pull request (plus the change Bagira80 suggested) independently. I just uploaded https://github.com/madler/zlib/pull/818. If you make the change Bagira80 suggested, I will abandon my pull request.

Thanks, Wan-Teh

wantehchang avatar May 25 '23 18:05 wantehchang