Cannot find SDL2
I decided to do some spring cleaning within my git/svn/hg followed projects today and finally tackle a long-time issue I had with your code. It seems that your cmake script cannot properly locate sdl2 even if I have it on my system. I'm using g++ 8.1.0 and cmake 3.11.1 as shipped by Arch Linux.
Here is the cmake log, notice the empty string for the SDL2 part (it should have been locating /usr/lib/libSDL2.so and /usr/include/SDL2).
$ mkdir build/; cd build/; cmake -DCMAKE_BUILD_TYPE=Release -DGPL=ON ../
-- Using system zlib, includes found at /usr/include
-- Using system libbz2, includes found at /usr/include
-- Using system libjpeg, includes found at /usr/include
-- Using SDL2: ,
-- Using SDL2_mixer: /usr/lib/libSDL2_mixer.so, /usr/include/SDL2
-- Using SDL2_net: /usr/lib/libSDL2_net.so, /usr/include/SDL2
CMake Error at LocateSDL2.cmake:106 (list):
list sub-command REMOVE_AT requires list to be present.
Call Stack (most recent call first):
LocateSDL2.cmake:123 (sdl_modernize)
CMakeLists.txt:160 (include)
-- Configuring incomplete, errors occurred!
See also "/home/vloup/applications/wolf3d/ecwolf/build/CMakeFiles/CMakeOutput.log".
See also "/home/vloup/applications/wolf3d/ecwolf/build/CMakeFiles/CMakeError.log".
But it turns out that if I do comment line 58 from LocateSDL2.cmake
(find_package(SDL2 QUIET)
), everything builds just fine.
Have a nice sunday!
Comments (11)
-
-
reporter You've spotted something fishy, it seems I do not have such sdl2-config.cmake file (exactly named as you have written) on my system, at least not regarding the 64bits package. I found such a file, but only for the 32bits build, which is not what we are looking for. Arch provides SDL2 version 2.0.8 right now.
I can give you a list of all files that the package installs, but it is close to a vanilla release:
$ pacman -Ql sdl2 sdl2 /usr/ sdl2 /usr/bin/ sdl2 /usr/bin/sdl2-config sdl2 /usr/include/ sdl2 /usr/include/SDL2/ sdl2 /usr/include/SDL2/SDL.h sdl2 /usr/include/SDL2/SDL_assert.h sdl2 /usr/include/SDL2/SDL_atomic.h sdl2 /usr/include/SDL2/SDL_audio.h sdl2 /usr/include/SDL2/SDL_bits.h sdl2 /usr/include/SDL2/SDL_blendmode.h sdl2 /usr/include/SDL2/SDL_clipboard.h sdl2 /usr/include/SDL2/SDL_config.h sdl2 /usr/include/SDL2/SDL_config_android.h sdl2 /usr/include/SDL2/SDL_config_iphoneos.h sdl2 /usr/include/SDL2/SDL_config_macosx.h sdl2 /usr/include/SDL2/SDL_config_minimal.h sdl2 /usr/include/SDL2/SDL_config_pandora.h sdl2 /usr/include/SDL2/SDL_config_psp.h sdl2 /usr/include/SDL2/SDL_config_windows.h sdl2 /usr/include/SDL2/SDL_config_winrt.h sdl2 /usr/include/SDL2/SDL_config_wiz.h sdl2 /usr/include/SDL2/SDL_copying.h sdl2 /usr/include/SDL2/SDL_cpuinfo.h sdl2 /usr/include/SDL2/SDL_egl.h sdl2 /usr/include/SDL2/SDL_endian.h sdl2 /usr/include/SDL2/SDL_error.h sdl2 /usr/include/SDL2/SDL_events.h sdl2 /usr/include/SDL2/SDL_filesystem.h sdl2 /usr/include/SDL2/SDL_gamecontroller.h sdl2 /usr/include/SDL2/SDL_gesture.h sdl2 /usr/include/SDL2/SDL_haptic.h sdl2 /usr/include/SDL2/SDL_hints.h sdl2 /usr/include/SDL2/SDL_joystick.h sdl2 /usr/include/SDL2/SDL_keyboard.h sdl2 /usr/include/SDL2/SDL_keycode.h sdl2 /usr/include/SDL2/SDL_loadso.h sdl2 /usr/include/SDL2/SDL_log.h sdl2 /usr/include/SDL2/SDL_main.h sdl2 /usr/include/SDL2/SDL_messagebox.h sdl2 /usr/include/SDL2/SDL_mouse.h sdl2 /usr/include/SDL2/SDL_mutex.h sdl2 /usr/include/SDL2/SDL_name.h sdl2 /usr/include/SDL2/SDL_opengl.h sdl2 /usr/include/SDL2/SDL_opengl_glext.h sdl2 /usr/include/SDL2/SDL_opengles.h sdl2 /usr/include/SDL2/SDL_opengles2.h sdl2 /usr/include/SDL2/SDL_opengles2_gl2.h sdl2 /usr/include/SDL2/SDL_opengles2_gl2ext.h sdl2 /usr/include/SDL2/SDL_opengles2_gl2platform.h sdl2 /usr/include/SDL2/SDL_opengles2_khrplatform.h sdl2 /usr/include/SDL2/SDL_pixels.h sdl2 /usr/include/SDL2/SDL_platform.h sdl2 /usr/include/SDL2/SDL_power.h sdl2 /usr/include/SDL2/SDL_quit.h sdl2 /usr/include/SDL2/SDL_rect.h sdl2 /usr/include/SDL2/SDL_render.h sdl2 /usr/include/SDL2/SDL_revision.h sdl2 /usr/include/SDL2/SDL_rwops.h sdl2 /usr/include/SDL2/SDL_scancode.h sdl2 /usr/include/SDL2/SDL_shape.h sdl2 /usr/include/SDL2/SDL_stdinc.h sdl2 /usr/include/SDL2/SDL_surface.h sdl2 /usr/include/SDL2/SDL_system.h sdl2 /usr/include/SDL2/SDL_syswm.h sdl2 /usr/include/SDL2/SDL_test.h sdl2 /usr/include/SDL2/SDL_test_assert.h sdl2 /usr/include/SDL2/SDL_test_common.h sdl2 /usr/include/SDL2/SDL_test_compare.h sdl2 /usr/include/SDL2/SDL_test_crc32.h sdl2 /usr/include/SDL2/SDL_test_font.h sdl2 /usr/include/SDL2/SDL_test_fuzzer.h sdl2 /usr/include/SDL2/SDL_test_harness.h sdl2 /usr/include/SDL2/SDL_test_images.h sdl2 /usr/include/SDL2/SDL_test_log.h sdl2 /usr/include/SDL2/SDL_test_md5.h sdl2 /usr/include/SDL2/SDL_test_memory.h sdl2 /usr/include/SDL2/SDL_test_random.h sdl2 /usr/include/SDL2/SDL_thread.h sdl2 /usr/include/SDL2/SDL_timer.h sdl2 /usr/include/SDL2/SDL_touch.h sdl2 /usr/include/SDL2/SDL_types.h sdl2 /usr/include/SDL2/SDL_version.h sdl2 /usr/include/SDL2/SDL_video.h sdl2 /usr/include/SDL2/SDL_vulkan.h sdl2 /usr/include/SDL2/begin_code.h sdl2 /usr/include/SDL2/close_code.h sdl2 /usr/lib/ sdl2 /usr/lib/cmake/ sdl2 /usr/lib/cmake/SDL2/ sdl2 /usr/lib/cmake/SDL2/SDL2Config.cmake sdl2 /usr/lib/cmake/SDL2/SDL2ConfigVersion.cmake sdl2 /usr/lib/cmake/SDL2/SDL2Targets-noconfig.cmake sdl2 /usr/lib/cmake/SDL2/SDL2Targets.cmake sdl2 /usr/lib/libSDL2-2.0.so sdl2 /usr/lib/libSDL2-2.0.so.0 sdl2 /usr/lib/libSDL2-2.0.so.0.8.0 sdl2 /usr/lib/libSDL2.so sdl2 /usr/lib/libSDL2main.a sdl2 /usr/lib/pkgconfig/ sdl2 /usr/lib/pkgconfig/sdl2.pc sdl2 /usr/share/ sdl2 /usr/share/aclocal/ sdl2 /usr/share/aclocal/sdl2.m4 sdl2 /usr/share/licenses/ sdl2 /usr/share/licenses/sdl2/ sdl2 /usr/share/licenses/sdl2/LICENSE
There are 4 files that may be used by cmake, I've sent them there:
-
SDL2Config.cmake: https://ncry.pt/p/BNNn#y9DV8UokBV9ss7MXnnkwowikZe0ZsA4hJHh0BaKrELU
-
SDL2ConfigVersion.cmake: https://ncry.pt/p/CNNn#SKEzUoRJdaYnfOyTkvGMdQc4gUg8P61hXQ9POCBg3tU
-
SDL2Targets-noconfig.cmake: https://ncry.pt/p/DNNn#2tt-bIT8OBa51IBjvDvVoEhFkbtEOGNBD9JIdQkN4Ug
-
SDL2Targets.cmake: https://ncry.pt/p/ENNn#pisYnUA2-GrX60vBpODTTgWhIeCKfVWAQDjl3gvq6RM
I looked through the source code of the package, they use cmake to build the library: https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/sdl2
-
-
Those are indeed the files I'm looking for. Didn't notice that SDL2 has modern CMake target exports in 2.0.6 or later (although Ubuntu doesn't provide them). Shouldn't be hard to take care of this.
-
- attached moderntargets.patch
Can you try this patch?
-
reporter No cigar. I'm sorry that I am a sucker for debugging cmake or any building tool problems.
$ mkdir build/; cd build/; cmake -DCMAKE_BUILD_TYPE=Release -DGPL=ON ../ -- The C compiler identification is GNU 8.1.0 -- The CXX compiler identification is GNU 8.1.0 -- Check for working C compiler: /usr/lib/ccache/bin/cc -- Check for working C compiler: /usr/lib/ccache/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/lib/ccache/bin/c++ -- Check for working CXX compiler: /usr/lib/ccache/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Using system zlib, includes found at /usr/include -- Using system libbz2, includes found at /usr/include -- Using system libjpeg, includes found at /usr/include -- Using system SDL2 CMake Error at LocateSDL2.cmake:74 (add_library): add_library cannot create ALIAS target "SDL::SDL" because target "SDL2::SDL2" is imported but not globally visible. Call Stack (most recent call first): CMakeLists.txt:160 (include) -- Using SDL2_mixer: /usr/lib/libSDL2_mixer.so, /usr/include/SDL2 -- Using SDL2_net: /usr/lib/libSDL2_net.so, /usr/include/SDL2 CMake Error at LocateSDL2.cmake:121 (list): list sub-command REMOVE_AT requires list to be present. Call Stack (most recent call first): LocateSDL2.cmake:138 (sdl_modernize) CMakeLists.txt:160 (include) -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") -- Looking for stricmp -- Looking for stricmp - not found -- Looking for strnicmp -- Looking for strnicmp - not found -- Looking for atoll -- Looking for atoll - found -- Performing Test HAS_VA_COPY -- Performing Test HAS_VA_COPY - Success -- Checking for module 'gtk+-2.0' -- Found gtk+-2.0, version 2.24.32 -- Configuring incomplete, errors occurred! See also "/home/vloup/applications/wolf3d/ecwolf/build/CMakeFiles/CMakeOutput.log". See also "/home/vloup/applications/wolf3d/ecwolf/build/CMakeFiles/CMakeError.log".
-
- attached moderntargets2.patch
Drat! Well I guess I can change my targets to match, so how about this patch.
-
reporter With only the second patch (I couldn't use both since they are in conflict), it still kinda fails:
$ cmake -DCMAKE_BUILD_TYPE=Release -DGPL=ON -Wdev ../ -- The C compiler identification is GNU 8.1.0 -- The CXX compiler identification is GNU 8.1.0 -- Check for working C compiler: /usr/lib/ccache/bin/cc -- Check for working C compiler: /usr/lib/ccache/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/lib/ccache/bin/c++ -- Check for working CXX compiler: /usr/lib/ccache/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Using system zlib, includes found at /usr/include -- Using system libbz2, includes found at /usr/include -- Using system libjpeg, includes found at /usr/include -- Using system SDL2 -- Using SDL2_mixer: /usr/lib/libSDL2_mixer.so, /usr/include/SDL2 -- Using SDL2_net: /usr/lib/libSDL2_net.so, /usr/include/SDL2 -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") -- Looking for stricmp -- Looking for stricmp - not found -- Looking for strnicmp -- Looking for strnicmp - not found -- Looking for atoll -- Looking for atoll - found -- Performing Test HAS_VA_COPY -- Performing Test HAS_VA_COPY - Success -- Checking for module 'gtk+-2.0' -- Found gtk+-2.0, version 2.24.32 -- Configuring done CMake Warning (dev) at src/CMakeLists.txt:303 (add_executable): Policy CMP0028 is not set: Double colon in target name means ALIAS or IMPORTED target. Run "cmake --help-policy CMP0028" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Target "ecwolf" links to target "SDL::SDL_mixer" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at src/CMakeLists.txt:303 (add_executable): Policy CMP0028 is not set: Double colon in target name means ALIAS or IMPORTED target. Run "cmake --help-policy CMP0028" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Target "ecwolf" links to target "SDL::SDL_net" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at src/CMakeLists.txt:303 (add_executable): Policy CMP0028 is not set: Double colon in target name means ALIAS or IMPORTED target. Run "cmake --help-policy CMP0028" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Target "ecwolf" links to target "SDL::SDL" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at src/CMakeLists.txt:303 (add_executable): Policy CMP0028 is not set: Double colon in target name means ALIAS or IMPORTED target. Run "cmake --help-policy CMP0028" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Target "ecwolf" links to target "SDL::SDL_mixer" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at src/CMakeLists.txt:303 (add_executable): Policy CMP0028 is not set: Double colon in target name means ALIAS or IMPORTED target. Run "cmake --help-policy CMP0028" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Target "ecwolf" links to target "SDL::SDL_net" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at src/CMakeLists.txt:303 (add_executable): Policy CMP0028 is not set: Double colon in target name means ALIAS or IMPORTED target. Run "cmake --help-policy CMP0028" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Target "ecwolf" links to target "SDL::SDL" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? This warning is for project developers. Use -Wno-dev to suppress it. -- Generating done -- Build files have been written to: /home/vloup/applications/wolf3d/ecwolf/build $ make Scanning dependencies of target lzma [ 1%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/7zArcIn.c.o [ 1%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/7zBuf.c.o [ 2%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/7zCrc.c.o [ 2%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/7zCrcOpt.c.o [ 3%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/7zDec.c.o [ 4%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/7zStream.c.o [ 4%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/Bcj2.c.o [ 5%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/Bra.c.o [ 5%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/Bra86.c.o [ 6%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/BraIA64.c.o [ 7%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/CpuArch.c.o [ 7%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/Delta.c.o [ 8%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/LzFind.c.o [ 8%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/Lzma2Dec.c.o [ 9%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/LzmaDec.c.o [ 10%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/LzmaEnc.c.o [ 10%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/Ppmd7.c.o [ 11%] Building C object deps/lzma/CMakeFiles/lzma.dir/C/Ppmd7Dec.c.o [ 11%] Linking C static library liblzma.a [ 11%] Built target lzma Scanning dependencies of target zipdir [ 12%] Building C object tools/zipdir/CMakeFiles/zipdir.dir/zipdir.c.o [ 13%] Linking C executable zipdir [ 13%] Built target zipdir Scanning dependencies of target updaterevision [ 14%] Building C object tools/updaterevision/CMakeFiles/updaterevision.dir/updaterevision.c.o [ 14%] Linking C executable updaterevision [ 14%] Built target updaterevision Scanning dependencies of target revision_check /home/vloup/applications/wolf3d/ecwolf/build/src/hginfo.h updated to commit 180520-2103 (1.3.3-57-1a1fa246d595). [ 14%] Built target revision_check Scanning dependencies of target arithchk [ 14%] Building C object deps/gdtoa/CMakeFiles/arithchk.dir/arithchk.c.o [ 15%] Linking C executable arithchk [ 15%] Built target arithchk [ 16%] Generating arith.h Scanning dependencies of target qnan [ 17%] Building C object deps/gdtoa/CMakeFiles/qnan.dir/qnan.c.o [ 17%] Linking C executable qnan [ 17%] Built target qnan [ 18%] Generating gd_qnan.h Scanning dependencies of target gdtoa [ 18%] Building C object deps/gdtoa/CMakeFiles/gdtoa.dir/dmisc.c.o [ 19%] Building C object deps/gdtoa/CMakeFiles/gdtoa.dir/dtoa.c.o [ 20%] Building C object deps/gdtoa/CMakeFiles/gdtoa.dir/misc.c.o [ 20%] Linking C static library libgdtoa.a [ 20%] Built target gdtoa Scanning dependencies of target ecwolf [ 20%] Building CXX object src/CMakeFiles/ecwolf.dir/dosbox/dbopl.cpp.o In file included from /home/vloup/applications/wolf3d/ecwolf/src/id_sd.h:11, from /home/vloup/applications/wolf3d/ecwolf/src/dosbox/dbopl.h:24, from /home/vloup/applications/wolf3d/ecwolf/src/dosbox/dbopl.cpp:49: /home/vloup/applications/wolf3d/ecwolf/src/wl_def.h:19:10: fatal error: SDL.h: No such file or directory #include <SDL.h> ^~~~~~~ compilation terminated. make[2]: *** [src/CMakeFiles/ecwolf.dir/build.make:63: src/CMakeFiles/ecwolf.dir/dosbox/dbopl.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:445: src/CMakeFiles/ecwolf.dir/all] Error 2 make: *** [Makefile:152: all] Error 2
But, it seems it goes away if i replace all
#include "SDL.h"
to#include "SDL2/SDL.h"
. Definitely, this is not a proper fix. -
Guess I should have specified the second patch was a do over so exclusive.
Looks like the patch didn't fully apply though. There's a change to src/CMakeLists.txt in there that appears to be missing based on the warnings CMake is putting out.
-
reporter Oh, my bad. I did run
patch < moderntargets2.patch
instead ofpatch -p1 < moderntargets2.patch
, hence why it failed. I can now confirm everything builds just fine, and that the game starts properly. I guess, if it works on your side as well, you can push it to the repo.Thanks for all the help and feel free to close the issue when merging your code.
-
- changed status to resolved
- Depending on how the distro builds SDL2 it might actually come with modern CMake targets, so use them if they exist. (Resolves issue
#249)
→ <<cset 7f1297e4e36a>>
-
- changed version to 1.3.99999 (Git)
- Log in to comment
Can you post your sdl2-config.cmake? It should be located somewhere is /usr/lib. On Ubuntu for example it's "/usr/lib/x86_64-linux-gnu/cmake/SDL2/sdl2-config.cmake".