-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include zconf.h in example binary in order to fix CMake's add_subdirectory() #132
base: master
Are you sure you want to change the base?
Conversation
Yes, you are correct, this is definitely not the fix. I don't see how zconf.h would not be included without some sort of error at the include statement. |
That's what I was wondering. As well, including The weird thing, indeed, is that it's including something from somewhere and not erroring out at build time regarding the include. You can test this yourself by cloning zlib into a directory somewhere, and in a different directory creating a add_subdirectory("/path/to/zlib") and then building it. For instance, here's the output using Makefiles:
|
add_subdirectory() should have two parameters... second parameter specifies directory where sub-cmake creates all output files, including zconf.h, it is also used to construct include path when compiling. I tested with simple CMakeLists.txt:
|
My two cents: I also tried zlib from a parent project using The quick way to solve it was to change I think the proper solution is to add the following line to zlib's
At least that fixed it for me. |
@Qix- So basically, you need to do:
I also do
for obivious reasons, e.g. #218 before doing |
Alright so this probably isn't the best way to fix this.
When including
zlib
from a parent project using CMake'sadd_subdirectory()
function, the build fails - but only intest/example.c
.It whines about
z_const
and not being able to find it. Turns out, for some reason,zconf.h
isn't being included. This PR fixes that.The other option is to have someone more familiar with the library figure out why this is happening in the first place. If I'm understanding the header hierarchy correctly,
zconf.h
should be included withzlib.h
- but that doesn't seem to be the case withtest/example.c
.Alternatively, we could also add an option to disable building the examples.
I'm at least submitting the PR so if someone else runs across the issue prior to it being fixed they'll know what to do.