Include zconf.h in example binary in order to fix CMake's add_subdirectory()#132
Include zconf.h in example binary in order to fix CMake's add_subdirectory()#132Qix- wants to merge 1 commit intomadler:masterfrom
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 |
|
See #1027 . |
Alright so this probably isn't the best way to fix this.
When including
zlibfrom a parent project using CMake'sadd_subdirectory()function, the build fails - but only intest/example.c.It whines about
z_constand not being able to find it. Turns out, for some reason,zconf.hisn'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.hshould 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.