1 year ago

#73327

test-img

Raildex

Build and Link zlib fails because CMake renames files?

I have the following project structure:

project/
├─ CMakeLists.txt
├─ src/
├─ libraries/
│  ├─ directxtk/
│  │  ├─ CMakeLists.txt
│  ├─ zlib/
│  │  ├─ CMakeLists.txt

project/CMakeLists.txt is my main executable. I want to utilize zlib in it.

In this CMakeLists.txt, i have the following lines:

target_include_directories(Project PUBLIC ${EXTERNAL_HEADERS_DIR})
add_subdirectory("${LINK_LIBRARY_DIR}/zlib")
add_subdirectory("${LINK_LIBRARY_DIR}/directxtk")
target_link_libraries(Project LINK_PUBLIC zlib)
target_link_libraries(Project LINK_PUBLIC DirectXTK)

EXTERNAL_HEADERS_DIR and LINK_LIBRARY_DIR both point to Project/Libraries.

I include zlib the following way: #include <zlib/zlib.h>

When I try to build and run now, I receive the following compile error:

...\Project\Libraries\zlib/zlib.h(34): fatal error C1083: Cannot open include file: 'zconf.h': No such file or directory

apparently, CMake seems to rename zconf.h to zconf.h.included!? How can I properly build this whole thing?

Edit: I have copy&paste'd zlib/CMakeLists.txt from the public website of zlib

c++

cmake

zlib

0 Answers

Your Answer

Accepted video resources