libsdl-org / SDL_image

Image decoding for many popular formats for Simple Directmedia Layer.
zlib License
572 stars 189 forks source link

Cmake Error : Could NOT find ZLIB #253

Closed AbhayJoshi-Dev closed 2 years ago

AbhayJoshi-Dev commented 2 years ago

I have added SDL_image as a submodule in my project

CMakeLists.txt

cmake_minimum_required(VERSION 3.21.2)

project(TestProject)

set(DEPS_DIR ${CMAKE_SOURCE_DIR}/build/external)

add_subdirectory(external/SDL)

add_subdirectory(external/SDL_image)

set(IMGUI_SOURCE_FILES
external/imgui/imgui.cpp
external/imgui/imgui_demo.cpp
external/imgui/imgui_draw.cpp
external/imgui/imgui_impl_sdlrenderer.cpp
external/imgui/imgui_impl_sdl.cpp
external/imgui/imgui_tables.cpp
external/imgui/imgui_widgets.cpp)

set(IMGUI_HEADER_FILES
external/imgui/imconfig.h
external/imgui/imgui.h
external/imgui/imgui_internal.h
external/imgui/imstb_rectpack.h
external/imgui/imstb_textedit.h
external/imgui/imstb_truetype.h
external/imgui/imgui_impl_sdlrenderer.h
external/imgui/imgui_impl_sdl.h)

add_library(imgui STATIC ${IMGUI_SOURCE_FILES} ${IMGUI_HEADER_FILES})
target_include_directories(imgui PUBLIC external/SDL/include/)

file(GLOB TP_SOURCE_FILES src/*.cpp)
file(GLOB TP_HEADER_FILES include/*.h)

add_executable(TestProject ${TP_SOURCE_FILES} ${TP_HEADER_FILES})

target_include_directories(TestProject PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/
                                            ${CMAKE_CURRENT_SOURCE_DIR}/external/SDL/include/
                                            ${CMAKE_CURRENT_SOURCE_DIR}/external/SDL_image/
                                            ${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/)

target_link_libraries(TestProject PRIVATE imgui SDL2 SDL2main SDL2_image)

ERROR:

C:\Users\abhis\Desktop\test\test3\build>cmake ..
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
-- The C compiler identification is MSVC 19.31.31104.0
-- The CXX compiler identification is MSVC 19.31.31104.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Looking for immintrin.h
-- Looking for immintrin.h - found
-- Performing Test HAVE_WIN32_CC
-- Performing Test HAVE_WIN32_CC - Success
-- Looking for d3d9.h
-- Looking for d3d9.h - found
-- Looking for d3d11_1.h
-- Looking for d3d11_1.h - found
-- Looking for ddraw.h
-- Looking for ddraw.h - found
-- Looking for dsound.h
-- Looking for dsound.h - found
-- Looking for dinput.h
-- Looking for dinput.h - found
-- Looking for dxgi.h
-- Looking for dxgi.h - found
-- Performing Test HAVE_XINPUT_H
-- Performing Test HAVE_XINPUT_H - Success
-- Performing Test HAVE_XINPUT_GAMEPAD_EX
-- Performing Test HAVE_XINPUT_GAMEPAD_EX - Failed
-- Performing Test HAVE_XINPUT_STATE_EX
-- Performing Test HAVE_XINPUT_STATE_EX - Failed
-- Performing Test HAVE_WINDOWS_GAMING_INPUT_H
-- Performing Test HAVE_WINDOWS_GAMING_INPUT_H - Success
-- Looking for tpcshrd.h
-- Looking for tpcshrd.h - found
-- Looking for roapi.h
-- Looking for roapi.h - found
-- Looking for mmdeviceapi.h
-- Looking for mmdeviceapi.h - found
-- Looking for audioclient.h
-- Looking for audioclient.h - found
-- Looking for sensorsapi.h
-- Looking for sensorsapi.h - found
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.33.0.windows.2")
--
-- SDL2 was configured with the following options:
--
-- Platform: Windows-10.0.19043
-- 64-bit:   TRUE
-- Compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe
-- Revision:
--
-- Subsystems:
--   Atomic:    ON
--   Audio:     ON
--   Video:     ON
--   Render:    ON
--   Events:    ON
--   Joystick:  ON
--   Haptic:    ON
--   Hidapi:    ON
--   Power:     ON
--   Threads:   ON
--   Timers:    ON
--   File:      ON
--   Loadso:    ON
--   CPUinfo:   ON
--   Filesystem:        ON
--   Sensor:    ON
--   Locale:    ON
--   Misc:      ON
--
-- Options:
--   SDL2_DISABLE_INSTALL        (Wanted: OFF): OFF
--   SDL2_DISABLE_SDL2MAIN       (Wanted: OFF): OFF
--   SDL2_DISABLE_UNINSTALL      (Wanted: OFF): OFF
--   SDL_3DNOW                   (Wanted: ON): OFF
--   SDL_ALSA                    (Wanted: OFF): OFF
--   SDL_ALSA_SHARED             (Wanted: OFF): OFF
--   SDL_ALTIVEC                 (Wanted: ON): OFF
--   SDL_ARMNEON                 (Wanted: OFF): OFF
--   SDL_ARMSIMD                 (Wanted: OFF): OFF
--   SDL_ARTS                    (Wanted: OFF): OFF
--   SDL_ARTS_SHARED             (Wanted: OFF): OFF
--   SDL_ASAN                    (Wanted: OFF): OFF
--   SDL_ASSEMBLY                (Wanted: ON): OFF
--   SDL_ASSERTIONS              (Wanted: auto): auto
--   SDL_BACKGROUNDING_SIGNAL    (Wanted: OFF): OFF
--   SDL_CLOCK_GETTIME           (Wanted: OFF): OFF
--   SDL_COCOA                   (Wanted: OFF): OFF
--   SDL_DIRECTFB                (Wanted: OFF): OFF
--   SDL_DIRECTFB_SHARED         (Wanted: OFF): OFF
--   SDL_DIRECTX                 (Wanted: ON): ON
--   SDL_DISKAUDIO               (Wanted: ON): ON
--   SDL_DUMMYAUDIO              (Wanted: ON): ON
--   SDL_DUMMYVIDEO              (Wanted: ON): ON
--   SDL_ESD                     (Wanted: OFF): OFF
--   SDL_ESD_SHARED              (Wanted: OFF): OFF
--   SDL_FOREGROUNDING_SIGNAL    (Wanted: OFF): OFF
--   SDL_FUSIONSOUND             (Wanted: OFF): OFF
--   SDL_FUSIONSOUND_SHARED      (Wanted: OFF): OFF
--   SDL_GCC_ATOMICS             (Wanted: OFF): OFF
--   SDL_HIDAPI_JOYSTICK         (Wanted: ON): ON
--   SDL_INSTALL_TESTS           (Wanted: OFF): OFF
--   SDL_JACK                    (Wanted: OFF): OFF
--   SDL_JACK_SHARED             (Wanted: OFF): OFF
--   SDL_KMSDRM                  (Wanted: OFF): OFF
--   SDL_KMSDRM_SHARED           (Wanted: OFF): OFF
--   SDL_LIBC                    (Wanted: OFF): OFF
--   SDL_LIBSAMPLERATE           (Wanted: OFF): OFF
--   SDL_LIBSAMPLERATE_SHARED    (Wanted: OFF): OFF
--   SDL_METAL                   (Wanted: OFF): OFF
--   SDL_MMX                     (Wanted: ON): OFF
--   SDL_NAS                     (Wanted: OFF): OFF
--   SDL_NAS_SHARED              (Wanted: OFF): OFF
--   SDL_OFFSCREEN               (Wanted: OFF): OFF
--   SDL_OPENGL                  (Wanted: ON): ON
--   SDL_OPENGLES                (Wanted: ON): ON
--   SDL_OSS                     (Wanted: OFF): OFF
--   SDL_PIPEWIRE                (Wanted: OFF): OFF
--   SDL_PIPEWIRE_SHARED         (Wanted: OFF): OFF
--   SDL_PTHREADS                (Wanted: OFF): OFF
--   SDL_PTHREADS_SEM            (Wanted: OFF): OFF
--   SDL_PULSEAUDIO              (Wanted: OFF): OFF
--   SDL_PULSEAUDIO_SHARED       (Wanted: OFF): OFF
--   SDL_RENDER_D3D              (Wanted: ON): ON
--   SDL_RENDER_METAL            (Wanted: OFF): OFF
--   SDL_RPATH                   (Wanted: OFF): OFF
--   SDL_RPI                     (Wanted: OFF): OFF
--   SDL_SNDIO                   (Wanted: OFF): OFF
--   SDL_SNDIO_SHARED            (Wanted: OFF): OFF
--   SDL_SSE                     (Wanted: ON): ON
--   SDL_SSE2                    (Wanted: ON): ON
--   SDL_SSE3                    (Wanted: ON): ON
--   SDL_SSEMATH                 (Wanted: ON): OFF
--   SDL_STATIC_PIC              (Wanted: OFF): OFF
--   SDL_TEST                    (Wanted: OFF): OFF
--   SDL_VIRTUAL_JOYSTICK        (Wanted: ON): ON
--   SDL_VIVANTE                 (Wanted: OFF): OFF
--   SDL_VULKAN                  (Wanted: ON): ON
--   SDL_WASAPI                  (Wanted: ON): ON
--   SDL_WAYLAND                 (Wanted: OFF): OFF
--   SDL_WAYLAND_LIBDECOR        (Wanted: OFF): OFF
--   SDL_WAYLAND_LIBDECOR_SHARED (Wanted: OFF): OFF
--   SDL_WAYLAND_QT_TOUCH        (Wanted: OFF): OFF
--   SDL_WAYLAND_SHARED          (Wanted: OFF): OFF
--   SDL_X11                     (Wanted: OFF): OFF
--   SDL_X11_SHARED              (Wanted: OFF): OFF
--   SDL_X11_XCURSOR             (Wanted: OFF): OFF
--   SDL_X11_XDBE                (Wanted: OFF): OFF
--   SDL_X11_XFIXES              (Wanted: OFF): OFF
--   SDL_X11_XINPUT              (Wanted: OFF): OFF
--   SDL_X11_XRANDR              (Wanted: OFF): OFF
--   SDL_X11_XSCRNSAVER          (Wanted: OFF): OFF
--   SDL_X11_XSHAPE              (Wanted: OFF): OFF
--   SDL_XINPUT                  (Wanted: ON): ON
--
--  CFLAGS:        /DWIN32 /D_WINDOWS
--  EXTRA_CFLAGS:
--  EXTRA_LDFLAGS:
--  EXTRA_LIBS:    user32;gdi32;winmm;imm32;ole32;oleaut32;version;uuid;advapi32;setupapi;shell32;dinput8
--
--  Build Shared Library: ON
--  Build Static Library: ON
--  Build Static Library with Position Independent Code: OFF
--
-- Configuring SDL2_image 2.5.0
-- SDL2_image: Using system zlib
CMake Error at C:/Program Files/CMake/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.21/Modules/FindZLIB.cmake:120 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  external/SDL_image/CMakeLists.txt:309 (find_package)

-- Configuring incomplete, errors occurred!
See also "C:/Users/abhis/Desktop/test/test3/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/abhis/Desktop/test/test3/build/CMakeFiles/CMakeError.log".

C:\Users\abhis\Desktop\test\test3\build>

it is using system zlib but i want it to use vendored zlib What should i do? Am i doing something wrong?

sezero commented 2 years ago

@madebr: Please have a look.

slouken commented 2 years ago

Try this: cd external\SDL_image\external git clone https://github.com/libsdl-org/zlib.git -b v1.2.12-SDL

madebr commented 2 years ago

I think it's an oversight of my part. I didn't test it exhaustively on MSVC.

madebr commented 2 years ago

@AbhayJoshi-Dev

254 should fix it. If it isn't, I would like to hear about it.

You can test it by running:

git fetch origin pull/254/head:pr254
git checkout pr254

in the SDL_image subfolder.

edit: it's in the main branch now

AbhayJoshi-Dev commented 2 years ago

Its working fine now Thank You @madebr @slouken @sezero :)

sezero commented 2 years ago

OK, closing.