Skip to content
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

CMake: including current src directory into include path #218

Open
LebedevRI opened this issue Feb 7, 2017 · 3 comments
Open

CMake: including current src directory into include path #218

LebedevRI opened this issue Feb 7, 2017 · 3 comments

Comments

@LebedevRI
Copy link

Hi.

Line 86 of cmakelists is:

include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})

However, it does not do what it is actually supposed to do.
CMAKE_SOURCE_DIR is "The path to the top level of the source tree."
While clearly, you want the path to the current src dir, i.e. CMAKE_CURRENT_SOURCE_DIR, like it happens in MSVC case.

The difference is, this way, if zlib is used in another project via add_subdirectory(), it actually uses it's own zlib.h, not the system one:

$ cmake --build ./ -- -j1
[1/84] Building C object zlib/zlib-build/CMakeFiles/minigzip.dir/test/minigzip.o
FAILED: zlib/zlib-build/CMakeFiles/minigzip.dir/test/minigzip.o 
/usr/bin/cc  -DDEBUG -DHAVE_JPEG -D_LARGEFILE64_SOURCE=1 -Izlib/zlib-build -I../ -w -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-common -U_FORTIFY_SOURCE -fsanitize=address -fstack-protector-strong -fPIE   -march=native -g3 -ggdb3 -Werror -MD -MT zlib/zlib-build/CMakeFiles/minigzip.dir/test/minigzip.o -MF zlib/zlib-build/CMakeFiles/minigzip.dir/test/minigzip.o.d -o zlib/zlib-build/CMakeFiles/minigzip.dir/test/minigzip.o   -c /home/lebedevri/rawspeed/build/zlib/zlib-src/test/minigzip.c
In file included from /home/lebedevri/rawspeed/build/zlib/zlib-src/test/minigzip.c:18:0:
/usr/include/zlib.h:30:1: error: expected identifier or ‘(’ before numeric constant
 212121
 ^~~~~~
In file included from /usr/include/zlib.h:34:0,
                 from /home/lebedevri/rawspeed/build/zlib/zlib-src/test/minigzip.c:18:
/usr/include/zconf.h:377:12: error: unknown type name ‘Byte’
    typedef Byte  FAR Bytef;
            ^~~~
ninja: build stopped: subcommand failed.

(i added 212121 to /usr/include/zlib.h to illustrate the point.)

@azelk
Copy link

azelk commented Nov 25, 2019

Why is it still not fixed?

@LebedevRI
Copy link
Author

Looks like this repo is in now-permanent hiatus.
Would be great if an official successor be named, instead of clash-of-forks..

@MilhouseVH
Copy link

As time goes on and nothing changes it increasingly looks like this repo is dead, and a fork is the only option.

More eyes on https://github.com/zlib-ng/zlib-ng would help make the move to the new fork a no-brainer. I've just started testing it and there are a few minor build issues but it's pretty much a drop-in replacement for zlib (if you use the --zlib-compat option).

sezero pushed a commit to libsdl-org/SDL_image that referenced this issue Jul 11, 2021
- set ZLIB_INCLUDE_DIR from target properties rather than hardcoding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants