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

Using Magnum and SDL2 as git submodules #496

Closed
jonesmz opened this issue Feb 18, 2021 · 13 comments
Closed

Using Magnum and SDL2 as git submodules #496

jonesmz opened this issue Feb 18, 2021 · 13 comments

Comments

@jonesmz
Copy link

jonesmz commented Feb 18, 2021

Hi.

Some preliminaries:

This issue is reported against. I don't know why my project is using this specific commit, but it's working well for us until the next major release happens.

commit 553034da9e7616d03be5f5c10f78061f870ae28a (grafted, HEAD)
Author: Vladimír Vondruš <mosra@centrum.cz>
Date:   Sun Sep 13 16:12:09 2020 +0200

    Math: doc++

I can build SDL2 just fine out of the box, from the SDL2 repository mirror found here: https://github.com/SDL-mirror/SDL.git
No configuration changes needed. Just open Visual Studio and point it at the SDL2 cmake file.


I'm trying to use Magnum as a git submodule of my project, with the CMakeLists.txt from magnum included by my CMakeLists.txt using the cmake ADD_SUBDIRECTORY function.

SET(BUILD_PLUGINS_STATIC  ON CACHE BOOL "" FORCE)
SET(WITH_SDL2APPLICATION  ON CACHE BOOL "" FORCE)
SET(WITH_ANYIMAGEIMPORTER ON CACHE BOOL "" FORCE)
ADD_SUBDIRECTORY(corrade EXCLUDE_FROM_ALL)
ADD_SUBDIRECTORY(magnum EXCLUDE_FROM_ALL)

This works great!

Next, I want to also add SDL2 as a git submodule, and build SDL2 at the same time as Magnum and my project.

Adding

ADD_SUBDIRECTORY(SDL2)

This doesn't work. CMake complains with

1> CMake generation started for default configuration: 'x64-Debug (default)'.
1> Command line: "cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\commonextensions\microsoft\cmake\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\jonesmz\osp-magnum\out\install\x64-Debug (default)" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\commonextensions\microsoft\cmake\Ninja\ninja.exe" "C:\Users\jonesmz\osp-magnum" 2>&1"
1> Working directory: C:\Users\jonesmz\osp-magnum\out\build\x64-Debug (default)
1> [CMake] -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
1> [CMake] -- 
1> [CMake] -- SDL2 was configured with the following options:
1> [CMake] -- 
1> [CMake] -- Platform: Windows-10.0.19041
1> [CMake] -- 64-bit:   TRUE
1> [CMake] -- Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe
1> [CMake] -- 
1> [CMake] -- Subsystems:
1> [CMake] --   Atomic:	ON
1> [CMake] --   Audio:	ON
1> [CMake] --   Video:	ON
1> [CMake] --   Render:	ON
1> [CMake] --   Events:	ON
1> [CMake] --   Joystick:	ON
1> [CMake] --   Haptic:	ON
1> [CMake] --   Power:	ON
1> [CMake] --   Threads:	ON
1> [CMake] --   Timers:	ON
1> [CMake] --   File:	ON
1> [CMake] --   Loadso:	ON
1> [CMake] --   CPUinfo:	ON
1> [CMake] --   Filesystem:	ON
1> [CMake] --   Dlopen:	ON
1> [CMake] --   Sensor:	ON
1> [CMake] --   Locale:	ON
1> [CMake] -- 
1> [CMake] -- Options:
1> [CMake] --   3DNOW                  (Wanted: ON): OFF
1> [CMake] --   ALSA                   (Wanted: OFF): OFF
1> [CMake] --   ALSA_SHARED            (Wanted: OFF): OFF
1> [CMake] --   ALTIVEC                (Wanted: ON): OFF
1> [CMake] --   ARMNEON                (Wanted: OFF): OFF
1> [CMake] --   ARMSIMD                (Wanted: OFF): OFF
1> [CMake] --   ARTS                   (Wanted: OFF): OFF
1> [CMake] --   ARTS_SHARED            (Wanted: OFF): OFF
1> [CMake] --   ASSEMBLY               (Wanted: ON): OFF
1> [CMake] --   ASSERTIONS             (Wanted: auto): auto
1> [CMake] --   BACKGROUNDING_SIGNAL   (Wanted: OFF): OFF
1> [CMake] --   CLOCK_GETTIME          (Wanted: OFF): OFF
1> [CMake] --   DIRECTFB_SHARED        (Wanted: OFF): OFF
1> [CMake] --   DIRECTX                (Wanted: ON): ON
1> [CMake] --   DISKAUDIO              (Wanted: ON): ON
1> [CMake] --   DUMMYAUDIO             (Wanted: ON): ON
1> [CMake] --   ESD                    (Wanted: OFF): OFF
1> [CMake] --   ESD_SHARED             (Wanted: OFF): OFF
1> [CMake] --   FOREGROUNDING_SIGNAL   (Wanted: OFF): OFF
1> [CMake] --   FUSIONSOUND            (Wanted: OFF): OFF
1> [CMake] --   FUSIONSOUND_SHARED     (Wanted: OFF): OFF
1> [CMake] --   GCC_ATOMICS            (Wanted: OFF): OFF
1> [CMake] --   HIDAPI                 (Wanted: ON): ON
1> [CMake] --   JACK                   (Wanted: OFF): OFF
1> [CMake] --   JACK_SHARED            (Wanted: OFF): OFF
1> [CMake] --   JOYSTICK_VIRTUAL       (Wanted: ON): OFF
1> [CMake] --   KMSDRM_SHARED          (Wanted: OFF): OFF
1> [CMake] --   LIBC                   (Wanted: OFF): OFF
1> [CMake] --   LIBSAMPLERATE          (Wanted: OFF): OFF
1> [CMake] --   LIBSAMPLERATE_SHARED   (Wanted: OFF): OFF
1> [CMake] --   MMX                    (Wanted: ON): OFF
1> [CMake] --   NAS                    (Wanted: OFF): OFF
1> [CMake] --   NAS_SHARED             (Wanted: OFF): OFF
1> [CMake] --   OSS                    (Wanted: OFF): OFF
1> [CMake] --   PTHREADS               (Wanted: OFF): OFF
1> [CMake] --   PTHREADS_SEM           (Wanted: OFF): OFF
1> [CMake] --   PULSEAUDIO             (Wanted: OFF): OFF
1> [CMake] --   PULSEAUDIO_SHARED      (Wanted: OFF): OFF
1> [CMake] --   RENDER_D3D             (Wanted: ON): ON
1> [CMake] --   RENDER_METAL           (Wanted: OFF): OFF
1> [CMake] --   RPATH                  (Wanted: OFF): OFF
1> [CMake] --   SDL_DLOPEN             (Wanted: ON): OFF
1> [CMake] --   SDL_STATIC_PIC         (Wanted: OFF): OFF
1> [CMake] --   SDL_TEST               (Wanted: OFF): OFF
1> [CMake] --   SNDIO                  (Wanted: OFF): OFF
1> [CMake] --   SNDIO_SHARED           (Wanted: OFF): OFF
1> [CMake] --   SSE                    (Wanted: ON): ON
1> [CMake] --   SSE2                   (Wanted: ON): ON
1> [CMake] --   SSE3                   (Wanted: ON): ON
1> [CMake] --   SSEMATH                (Wanted: ON): OFF
1> [CMake] --   VIDEO_COCOA            (Wanted: OFF): OFF
1> [CMake] --   VIDEO_DIRECTFB         (Wanted: OFF): OFF
1> [CMake] --   VIDEO_DUMMY            (Wanted: ON): ON
1> [CMake] --   VIDEO_KMSDRM           (Wanted: OFF): OFF
1> [CMake] --   VIDEO_METAL            (Wanted: OFF): OFF
1> [CMake] --   VIDEO_OFFSCREEN        (Wanted: OFF): OFF
1> [CMake] --   VIDEO_OPENGL           (Wanted: ON): ON
1> [CMake] --   VIDEO_OPENGLES         (Wanted: ON): ON
1> [CMake] --   VIDEO_RPI              (Wanted: OFF): OFF
1> [CMake] --   VIDEO_VIVANTE          (Wanted: OFF): OFF
1> [CMake] --   VIDEO_VULKAN           (Wanted: ON): ON
1> [CMake] --   VIDEO_WAYLAND          (Wanted: OFF): OFF
1> [CMake] --   VIDEO_WAYLAND_QT_TOUCH (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11              (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XCURSOR      (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XINERAMA     (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XINPUT       (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XRANDR       (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XSCRNSAVER   (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XSHAPE       (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XVM          (Wanted: OFF): OFF
1> [CMake] --   WASAPI                 (Wanted: ON): OFF
1> [CMake] --   WAYLAND_SHARED         (Wanted: OFF): OFF
1> [CMake] --   X11_SHARED             (Wanted: OFF): OFF
1> [CMake] -- 
1> [CMake] --  CFLAGS:        /DWIN32 /D_WINDOWS /W3  "-IC:/Users/jonesmz/osp-magnum/3rdparty/SDL2/src/hidapi/hidapi"
1> [CMake] --  EXTRA_CFLAGS:  
1> [CMake] --  EXTRA_LDFLAGS: 
1> [CMake] --  EXTRA_LIBS:    user32;gdi32;winmm;imm32;ole32;oleaut32;version;uuid;advapi32;setupapi;shell32;dinput8
1> [CMake] -- 
1> [CMake] --  Build Shared Library: ON
1> [CMake] --  Build Static Library: ON
1> [CMake] --  Build Static Library with Position Independent Code: OFF
1> [CMake] -- 
1> [CMake] CMake Warning at 3rdparty/corrade/CMakeLists.txt:201 (message):
1> [CMake]   MSVC 2019 detected, automatically enabling MSVC2019_COMPATIBILITY.  Note
1> [CMake]   that some features may not be available with this compiler.
1> [CMake] 
1> [CMake] 
1> [CMake] -- Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR) 
1> [CMake] CMake Error at 3rdparty/magnum/src/Magnum/Platform/CMakeLists.txt:297 (message):
1> [CMake]   SDL2 library, required by Sdl2Application, was not found.  Set
1> [CMake]   WITH_SDL2APPLICATION to OFF to skip building it.
1> [CMake] 
1> [CMake] 
1> [CMake] -- Configuring incomplete, errors occurred!
1> [CMake] See also "C:/Users/jonesmz/osp-magnum/out/build/x64-Debug (default)/CMakeFiles/CMakeOutput.log".
1> [CMake] See also "C:/Users/jonesmz/osp-magnum/out/build/x64-Debug (default)/CMakeFiles/CMakeError.log".

It would be my expectation that Magnum's CMake files automatically detect SDL being built from the same CMake invocation.

Is this something that can be fixed in Magnum's CMake files? Or does my project need to change something?

@mosra
Copy link
Owner

mosra commented Feb 18, 2021

Hi! :)

Is this something that can be fixed in Magnum's CMake files?

Absolutely, similar thing is done for GLFW, Bullet, Assimp, SPIRV-Tools, glslang, ... Magnum has its own Find modules for these to transparently handle both external installations and subproject setups without having to do something extra in the end-user projects. The extra steps needed, if any, are then listed in the docs for each library / plugin.

For SDL I tried a few years ago and it wasn't really possible yet. Since then I was waiting for SDL to get the CMake improvements this needed (which was blocked by SDL not being in git, which is solved now)... and it seems that SDL can do that now. Great!

I have quite a big backlog of things to go through, but I'll be definitely looking into this when I have some time. Should be rather easy, so hopefully sometime early next week.

@jonesmz
Copy link
Author

jonesmz commented Feb 18, 2021

Thank you very much. I appreciate you being able and willing to help with this.

I'll check back next week to see if you need help with testing.

@jonesmz
Copy link
Author

jonesmz commented Feb 27, 2021

Hi, I took a look at the commit log, and it looks like you're still busy with your backlog.

Let me know if there's something I can help with, but otherwise I'll just wait until you have more time.

Thanks again!

@mosra mosra added this to the 2021.0a milestone Feb 27, 2021
@mosra
Copy link
Owner

mosra commented Feb 27, 2021

Okay, finally got to this -- in 2968e58 (the next branch, not master yet) is an updated Find module as well as a CMake snippet how to embed SDL in the most minimal way. I have to admit I'm rather unhappy in how excessive are SDL's buildsystem checks, it increases the CMake configure time by several seconds :( In that snippet I also tried to disable most of the parts that Magnum itself is not using. If you manage to disable even more (especially SDL_AUDIO), please share these options.

The snippet suggests a static SDL by default, but it should work with a dynamic variant as well, and in that case also copy the built DLL to the bin/ directory next to your app, same as it did when SDL was used externally. I'm not on Windows so (assuming you are) if you could verify this works, that'd be great.

If you confirm this is all working as expected, I'll merge that change to master. I still have some CI failures here and there but that shouldn't affect your case I hope.

@jonesmz
Copy link
Author

jonesmz commented Feb 27, 2021

Getting closer!

Using this branch here: https://github.com/jonesmz/osp-magnum/tree/sdl2

I downloaded the code on windows, then opened the project's cmake file with Visual Studio 2019.

PS C:\Users\jonesmz\source\repos\jonesmz\osp-magnum> git submodule update --init --recursive .
Submodule path '3rdparty/SDL2': checked out '5c829aac66a491b9d23b12f4c37bf896dc11f3a8'
Submodule path '3rdparty/corrade': checked out 'b329d0566e61dd0b2d7dd55f3931361a9593288d'
Submodule path '3rdparty/corrade/toolchains': checked out '6957ebbc9f18aa478fac2e99e6687c18410bab29'
Submodule path '3rdparty/entt': checked out '7a949dd32849e8230b15a5ff8ad1104c7f748c2a'
Submodule path '3rdparty/magnum': checked out '2968e58140fcb1f9e22a60fb34bbd3a076150a4b'
Submodule path '3rdparty/magnum/toolchains': checked out '6957ebbc9f18aa478fac2e99e6687c18410bab29'
Submodule path '3rdparty/magnum-plugins': checked out '2d7433614696132f9e06d50b23959b21f9cbe51b'
Submodule path '3rdparty/magnum-plugins/toolchains': checked out 'fe0e99114811d646617322667ec6abba018ddaed'
Submodule path '3rdparty/newton-dynamics': checked out '12d42e979bd0672adad49db1d9900bedc879f0f1'
Submodule path '3rdparty/toml11': checked out 'be0d4bd0a9c2b951c3ff94399b801e5dfca48585'
PS C:\Users\jonesmz\source\repos\jonesmz\osp-magnum>

The error seems to be:

1> [CMake] CMake Error at 3rdparty/magnum/modules/FindSDL2.cmake:70 (get_target_property):
1> [CMake]   get_target_property() called with non-existent target "glfw".
1> [CMake] Call Stack (most recent call first):
1> [CMake]   3rdparty/magnum/src/Magnum/Platform/CMakeLists.txt:295 (find_package)
1> [CMake] CMake Error at 3rdparty/magnum/modules/FindSDL2.cmake:71 (get_target_property):
1> [CMake]   get_target_property() called with non-existent target "glfw".
1> [CMake] Call Stack (most recent call first):

I don't have GLFW (or SDL2) installed in windows. I have only SDL2 as a submodule of my git repository

1> CMake generation started for default configuration: 'x64-Debug (default)'.
1> Command line: "cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\install\x64-Debug (default)" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum" 2>&1"
1> Working directory: C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\build\x64-Debug (default)
1> [CMake] -- The CXX compiler identification is MSVC 19.28.29337.0
1> [CMake] -- Detecting CXX compiler ABI info
1> [CMake] -- Detecting CXX compiler ABI info - done
1> [CMake] -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting CXX compile features
1> [CMake] -- Detecting CXX compile features - done
1> [CMake] -- The C compiler identification is MSVC 19.28.29337.0
1> [CMake] -- Detecting C compiler ABI info
1> [CMake] -- Detecting C compiler ABI info - done
1> [CMake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting C compile features
1> [CMake] -- Detecting C compile features - done
1> [CMake] -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
1> [CMake] -- Performing Test HAVE_WIN32_CC
1> [CMake] -- Performing Test HAVE_WIN32_CC - Success
1> [CMake] -- Performing Test HAVE_XINPUT_H
1> [CMake] -- Performing Test HAVE_XINPUT_H - Success
1> [CMake] -- Performing Test HAVE_XINPUT_GAMEPAD_EX
1> [CMake] -- Performing Test HAVE_XINPUT_GAMEPAD_EX - Failed
1> [CMake] -- Performing Test HAVE_XINPUT_STATE_EX
1> [CMake] -- Performing Test HAVE_XINPUT_STATE_EX - Failed
1> [CMake] -- Looking for d3d9.h
1> [CMake] -- Looking for d3d9.h - found
1> [CMake] -- Looking for d3d11_1.h
1> [CMake] -- Looking for d3d11_1.h - found
1> [CMake] -- Looking for ddraw.h
1> [CMake] -- Looking for ddraw.h - found
1> [CMake] -- Looking for dsound.h
1> [CMake] -- Looking for dsound.h - found
1> [CMake] -- Looking for dinput.h
1> [CMake] -- Looking for dinput.h - found
1> [CMake] -- Looking for dxgi.h
1> [CMake] -- Looking for dxgi.h - found
1> [CMake] -- Looking for mmdeviceapi.h
1> [CMake] -- Looking for mmdeviceapi.h - found
1> [CMake] -- Looking for audioclient.h
1> [CMake] -- Looking for audioclient.h - found
1> [CMake] -- Looking for sensorsapi.h
1> [CMake] -- Looking for sensorsapi.h - found
1> [CMake] -- 
1> [CMake] -- SDL2 was configured with the following options:
1> [CMake] -- 
1> [CMake] -- Platform: Windows-10.0.19041
1> [CMake] -- 64-bit:   TRUE
1> [CMake] -- Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe
1> [CMake] -- 
1> [CMake] -- Subsystems:
1> [CMake] --   Atomic:	ON
1> [CMake] --   Audio:	ON
1> [CMake] --   Video:	ON
1> [CMake] --   Render:	ON
1> [CMake] --   Events:	ON
1> [CMake] --   Joystick:	ON
1> [CMake] --   Haptic:	ON
1> [CMake] --   Power:	ON
1> [CMake] --   Threads:	ON
1> [CMake] --   Timers:	ON
1> [CMake] --   File:	ON
1> [CMake] --   Loadso:	ON
1> [CMake] --   CPUinfo:	ON
1> [CMake] --   Filesystem:	ON
1> [CMake] --   Dlopen:	ON
1> [CMake] --   Sensor:	ON
1> [CMake] --   Locale:	ON
1> [CMake] -- 
1> [CMake] -- Options:
1> [CMake] --   3DNOW                  (Wanted: ON): OFF
1> [CMake] --   ALSA                   (Wanted: OFF): OFF
1> [CMake] --   ALSA_SHARED            (Wanted: OFF): OFF
1> [CMake] --   ALTIVEC                (Wanted: ON): OFF
1> [CMake] --   ARMNEON                (Wanted: OFF): OFF
1> [CMake] --   ARMSIMD                (Wanted: OFF): OFF
1> [CMake] --   ARTS                   (Wanted: OFF): OFF
1> [CMake] --   ARTS_SHARED            (Wanted: OFF): OFF
1> [CMake] --   ASSEMBLY               (Wanted: ON): OFF
1> [CMake] --   ASSERTIONS             (Wanted: auto): auto
1> [CMake] --   BACKGROUNDING_SIGNAL   (Wanted: OFF): OFF
1> [CMake] --   CLOCK_GETTIME          (Wanted: OFF): OFF
1> [CMake] --   DIRECTFB_SHARED        (Wanted: OFF): OFF
1> [CMake] --   DIRECTX                (Wanted: ON): ON
1> [CMake] --   DISKAUDIO              (Wanted: ON): ON
1> [CMake] --   DUMMYAUDIO             (Wanted: ON): ON
1> [CMake] --   ESD                    (Wanted: OFF): OFF
1> [CMake] --   ESD_SHARED             (Wanted: OFF): OFF
1> [CMake] --   FOREGROUNDING_SIGNAL   (Wanted: OFF): OFF
1> [CMake] --   FUSIONSOUND            (Wanted: OFF): OFF
1> [CMake] --   FUSIONSOUND_SHARED     (Wanted: OFF): OFF
1> [CMake] --   GCC_ATOMICS            (Wanted: OFF): OFF
1> [CMake] --   HIDAPI                 (Wanted: ON): ON
1> [CMake] --   JACK                   (Wanted: OFF): OFF
1> [CMake] --   JACK_SHARED            (Wanted: OFF): OFF
1> [CMake] --   JOYSTICK_VIRTUAL       (Wanted: ON): OFF
1> [CMake] --   KMSDRM_SHARED          (Wanted: OFF): OFF
1> [CMake] --   LIBC                   (Wanted: OFF): OFF
1> [CMake] --   LIBSAMPLERATE          (Wanted: OFF): OFF
1> [CMake] --   LIBSAMPLERATE_SHARED   (Wanted: OFF): OFF
1> [CMake] --   MMX                    (Wanted: ON): OFF
1> [CMake] --   NAS                    (Wanted: OFF): OFF
1> [CMake] --   NAS_SHARED             (Wanted: OFF): OFF
1> [CMake] --   OSS                    (Wanted: OFF): OFF
1> [CMake] --   PTHREADS               (Wanted: OFF): OFF
1> [CMake] --   PTHREADS_SEM           (Wanted: OFF): OFF
1> [CMake] --   PULSEAUDIO             (Wanted: OFF): OFF
1> [CMake] --   PULSEAUDIO_SHARED      (Wanted: OFF): OFF
1> [CMake] --   RENDER_D3D             (Wanted: ON): ON
1> [CMake] --   RENDER_METAL           (Wanted: OFF): OFF
1> [CMake] --   RPATH                  (Wanted: OFF): OFF
1> [CMake] --   SDL_DLOPEN             (Wanted: ON): OFF
1> [CMake] --   SDL_STATIC_PIC         (Wanted: OFF): OFF
1> [CMake] --   SDL_TEST               (Wanted: OFF): OFF
1> [CMake] --   SNDIO                  (Wanted: OFF): OFF
1> [CMake] --   SNDIO_SHARED           (Wanted: OFF): OFF
1> [CMake] --   SSE                    (Wanted: ON): ON
1> [CMake] --   SSE2                   (Wanted: ON): ON
1> [CMake] --   SSE3                   (Wanted: ON): ON
1> [CMake] --   SSEMATH                (Wanted: ON): OFF
1> [CMake] --   VIDEO_COCOA            (Wanted: OFF): OFF
1> [CMake] --   VIDEO_DIRECTFB         (Wanted: OFF): OFF
1> [CMake] --   VIDEO_DUMMY            (Wanted: ON): ON
1> [CMake] --   VIDEO_KMSDRM           (Wanted: OFF): OFF
1> [CMake] --   VIDEO_METAL            (Wanted: OFF): OFF
1> [CMake] --   VIDEO_OFFSCREEN        (Wanted: OFF): OFF
1> [CMake] --   VIDEO_OPENGL           (Wanted: ON): ON
1> [CMake] --   VIDEO_OPENGLES         (Wanted: ON): ON
1> [CMake] --   VIDEO_RPI              (Wanted: OFF): OFF
1> [CMake] --   VIDEO_VIVANTE          (Wanted: OFF): OFF
1> [CMake] --   VIDEO_VULKAN           (Wanted: ON): ON
1> [CMake] --   VIDEO_WAYLAND          (Wanted: OFF): OFF
1> [CMake] --   VIDEO_WAYLAND_QT_TOUCH (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11              (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XCURSOR      (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XINERAMA     (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XINPUT       (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XRANDR       (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XSCRNSAVER   (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XSHAPE       (Wanted: OFF): OFF
1> [CMake] --   VIDEO_X11_XVM          (Wanted: OFF): OFF
1> [CMake] --   WASAPI                 (Wanted: ON): OFF
1> [CMake] --   WAYLAND_SHARED         (Wanted: OFF): OFF
1> [CMake] --   X11_SHARED             (Wanted: OFF): OFF
1> [CMake] -- 
1> [CMake] --  CFLAGS:        /DWIN32 /D_WINDOWS /W3  "-IC:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/SDL2/src/hidapi/hidapi"
1> [CMake] --  EXTRA_CFLAGS:  
1> [CMake] --  EXTRA_LDFLAGS: 
1> [CMake] --  EXTRA_LIBS:    user32;gdi32;winmm;imm32;ole32;oleaut32;version;uuid;advapi32;setupapi;shell32;dinput8
1> [CMake] -- 
1> [CMake] --  Build Shared Library: ON
1> [CMake] --  Build Static Library: ON
1> [CMake] --  Build Static Library with Position Independent Code: OFF
1> [CMake] -- 
1> [CMake] CMake Warning at 3rdparty/corrade/CMakeLists.txt:210 (message):
1> [CMake]   MSVC 2019 detected, automatically enabling MSVC2019_COMPATIBILITY.  Note
1> [CMake]   that some features may not be available with this compiler.
1> [CMake] 
1> [CMake] 
1> [CMake] -- LIB_SUFFIX variable is not defined. It will be autodetected now.
1> [CMake] -- You can set it manually with -DLIB_SUFFIX=<value> (64 for example)
1> [CMake] -- LIB_SUFFIX autodetected as '', libraries will be installed into C:/Users/jonesmz/Source/Repos/jonesmz/osp-magnum/out/install/x64-Debug (default)/lib
1> [CMake] -- Found Git: C:/cygwin64/bin/git.exe (found version "2.30.1") 
1> [CMake] -- Found Corrade: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/corrade/src  found components: Containers rc Utility 
1> [CMake] -- Found OpenGL: opengl32   
1> [CMake] -- Found SDL2: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/SDL2  
1> [CMake] CMake Error at 3rdparty/magnum/modules/FindSDL2.cmake:70 (get_target_property):
1> [CMake]   get_target_property() called with non-existent target "glfw".
1> [CMake] Call Stack (most recent call first):
1> [CMake]   3rdparty/magnum/src/Magnum/Platform/CMakeLists.txt:295 (find_package)
1> [CMake] CMake Error at 3rdparty/magnum/modules/FindSDL2.cmake:71 (get_target_property):
1> [CMake]   get_target_property() called with non-existent target "glfw".
1> [CMake] Call Stack (most recent call first):
1> [CMake]   3rdparty/magnum/src/Magnum/Platform/CMakeLists.txt:295 (find_package)
1> [CMake] -- Found Corrade: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/corrade/src  found components: Containers rc Utility Main TestSuite 
1> [CMake] -- Found Corrade: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/corrade/src  found components: Containers rc Utility PluginManager 
1> [CMake] -- Found Corrade: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/corrade/src  found components: Containers rc Utility 
1> [CMake] -- Found Magnum: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/magnum/src   
1> [CMake] -- Found Corrade: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/corrade/src  found components: Containers rc Utility PluginManager 
1> [CMake] -- Found Magnum: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/magnum/src  found components: Trade 
1> [CMake] -- Found Magnum: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/magnum/src  found components: Trade AnyImageImporter 
1> [CMake] -- Check size of void*
1> [CMake] -- Check size of void* - done
1> [CMake] link to static runtime libraries
1> [CMake] build 64 bit
1> [CMake] CMAKE_CXX_FLAGS_DEBUG is /MTd /Zi /W4 /Od
1> [CMake] CMAKE_CXX_FLAGS_RELWITHDEBINFO is /MT
1> [CMake] CMAKE_CXX_FLAGS_RELEASE is /MT /Zi /GS- /W4 /Ox /Oi /Ot /Ob2 /fp:fast
1> [CMake] dgCore
1> [CMake] newton
1> [CMake] dgPhysics
1> [CMake] dMath
1> [CMake] dScene
1> [CMake] dModel
1> [CMake] dNewton
1> [CMake] dVehicle
1> [CMake] dAnimation
1> [CMake] dContainers
1> [CMake] dCustomJoints
1> [CMake] tinyxml
1> [CMake] dgNewtonAvx
1> [CMake] dgNewtonReferenceGPU
1> [CMake] -- Found Corrade: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/corrade/src  found components: Main 
1> [CMake] -- Found Corrade: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/corrade/src  found components: Containers rc Utility PluginManager 
1> [CMake] -- Found Magnum: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/magnum/src  found components: GL Trade Shaders MeshTools Primitives Sdl2Application AnyImageImporter 
1> [CMake] -- Found Magnum: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/magnum/src  found components: Trade AnyImageImporter 
1> [CMake] -- Found MagnumPlugins: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/3rdparty/magnum-plugins/src  found components: TinyGltfImporter StbImageImporter 
1> [CMake] -- Looking for C++ include pthread.h
1> [CMake] -- Looking for C++ include pthread.h - not found
1> [CMake] -- Found Threads: TRUE  
1> [CMake] -- Configuring incomplete, errors occurred!
1> [CMake] See also "C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/out/build/x64-Debug (default)/CMakeFiles/CMakeOutput.log".
1> [CMake] See also "C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/out/build/x64-Debug (default)/CMakeFiles/CMakeError.log".
1> 'cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\install\x64-Debug (default)" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum" 2>&1"' execution failed with error: ''cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\install\x64-Debug (default)" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum" 2>&1"' returned with exit code: 1'.

Here's CMakeError.log

Performing C SOURCE FILE Test HAVE_XINPUT_GAMEPAD_EX failed with the following output:
Change Dir: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/out/build/x64-Debug (default)/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_1b68f && [1/2] Building C object CMakeFiles\cmTC_1b68f.dir\src.c.obj

FAILED: CMakeFiles/cmTC_1b68f.dir/src.c.obj 

C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo   /DWIN32 /D_WINDOWS /W3 -DHAVE_XINPUT_GAMEPAD_EX /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\cmTC_1b68f.dir\src.c.obj /FdCMakeFiles\cmTC_1b68f.dir\ /FS -c src.c

src.c(4): error C2061: syntax error: identifier 'x1'
src.c(4): error C2059: syntax error: ';'
ninja: build stopped: subcommand failed.



Source file was:

        #include <windows.h>
        #include <xinput.h>
        XINPUT_GAMEPAD_EX x1;
        int main(int argc, char **argv) { }
Performing C SOURCE FILE Test HAVE_XINPUT_STATE_EX failed with the following output:
Change Dir: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/out/build/x64-Debug (default)/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_0d752 && [1/2] Building C object CMakeFiles\cmTC_0d752.dir\src.c.obj

FAILED: CMakeFiles/cmTC_0d752.dir/src.c.obj 

C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo   /DWIN32 /D_WINDOWS /W3 -DHAVE_XINPUT_STATE_EX /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\cmTC_0d752.dir\src.c.obj /FdCMakeFiles\cmTC_0d752.dir\ /FS -c src.c

src.c(4): error C2061: syntax error: identifier 's1'
src.c(4): error C2059: syntax error: ';'
ninja: build stopped: subcommand failed.



Source file was:

        #include <windows.h>
        #include <xinput.h>
        XINPUT_STATE_EX s1;
        int main(int argc, char **argv) { }
Determining if the include file pthread.h exists failed with the following output:
Change Dir: C:/Users/jonesmz/source/repos/jonesmz/osp-magnum/out/build/x64-Debug (default)/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_a7785 && [1/2] Building CXX object CMakeFiles\cmTC_a7785.dir\CheckIncludeFile.cxx.obj

FAILED: CMakeFiles/cmTC_a7785.dir/CheckIncludeFile.cxx.obj 

C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo /TP   /DWIN32 /D_WINDOWS /W3 /GR /EHsc  /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\cmTC_a7785.dir\CheckIncludeFile.cxx.obj /FdCMakeFiles\cmTC_a7785.dir\ /FS -c CheckIncludeFile.cxx

CheckIncludeFile.cxx(1): fatal error C1083: Cannot open include file: 'pthread.h': No such file or directory
ninja: build stopped: subcommand failed.

@jonesmz
Copy link
Author

jonesmz commented Feb 27, 2021

Ahah!

My reading comprehension failed me.

I see that you have recommended settings for SDL2.

I've taken your settings suggestions, and now things are much happier :-)

Got some linker errors to try to figure out. I'll report back if I can't convince it to cooperate.

C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\build\x64-Debug (default)\SDL2d.lib(SDL_dynapi.c.obj) : error LNK2019: unresolved external symbol SDL_RegisterApp_REAL referenced in function initialize_jumptable
C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\build\x64-Debug (default)\SDL2d.lib(SDL_dynapi.c.obj) : error LNK2019: unresolved external symbol SDL_UnregisterApp_REAL referenced in function initialize_jumptable
C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\build\x64-Debug (default)\SDL2d.lib(SDL_dynapi.c.obj) : error LNK2019: unresolved external symbol SDL_Direct3D9GetAdapterIndex_REAL referenced in function initialize_jumptable
C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\build\x64-Debug (default)\SDL2d.lib(SDL_dynapi.c.obj) : error LNK2019: unresolved external symbol SDL_DXGIGetOutputInfo_REAL referenced in function initialize_jumptable
C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\build\x64-Debug (default)\SDL2d.lib(SDL_dynapi.c.obj) : error LNK2019: unresolved external symbol SDL_SetWindowsMessageHook_REAL referenced in function initialize_jumptable
C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\build\x64-Debug (default)\SDL2d.lib(SDL_dinputjoystick.c.obj) : error LNK2001: unresolved external symbol SDL_HelperWindow
C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\build\x64-Debug (default)\bin\osp-magnum.exe : fatal error LNK1120: 6 unresolved externals
  ninja: build stopped: subcommand failed.

@jonesmz
Copy link
Author

jonesmz commented Feb 27, 2021

Hrmm, so I'm able to make the GLFW errors go away if i update my SDL2 repo to the latest from the official github repo (now that they've migrated).

It looks like maybe it's an issue with the detection of the pre-alias code from SDL2 in your .cmake file.

Still getting the linker errors, looking into that now.

Also getting a new warning: C:\Users\jonesmz\Source\Repos\jonesmz\osp-magnum\out\build\x64-Debug (default)\LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

@jonesmz
Copy link
Author

jonesmz commented Feb 27, 2021

Got it link with these settings:



# This is the most minimal set of features which still make Sdl2Application
# work. If you need something from these, remove the setting. The SDL_AUDIO
# option (and SDL_DLOPEN) should not be needed either as Magnum doesn't use it,
# but if it's disabled it causes linker errors. Needs further investigation.
SET(SDL_ATOMIC     OFF CACHE BOOL "" FORCE)
SET(SDL_CPUINFO    OFF CACHE BOOL "" FORCE)
SET(SDL_EVENTS     OFF CACHE BOOL "" FORCE)
SET(SDL_FILE       OFF CACHE BOOL "" FORCE)
SET(SDL_FILESYSTEM OFF CACHE BOOL "" FORCE)
SET(SDL_HAPTIC     OFF CACHE BOOL "" FORCE)
SET(SDL_LOCALE     OFF CACHE BOOL "" FORCE)
SET(SDL_POWER      OFF CACHE BOOL "" FORCE)
SET(SDL_RENDER     OFF CACHE BOOL "" FORCE)
SET(SDL_SENSOR     OFF CACHE BOOL "" FORCE)
SET(SDL_THREADS    OFF CACHE BOOL "" FORCE)
SET(SDL_TIMERS     OFF CACHE BOOL "" FORCE)
SET(SDL_DLOPEN     OFF CACHE BOOL "" FORCE)
SET(SDL_AUDIO      OFF CACHE BOOL "" FORCE)

SET(SDL_JOYSTICK     ON  CACHE BOOL "" FORCE)
SET(JOYSTICK_VIRTUAL ON  CACHE BOOL "" FORCE)

SET(SDL_LOADSO     ON  CACHE BOOL "" FORCE)
SET(SDL_VIDEO      ON  CACHE BOOL "" FORCE)
SET(VIDEO_VULKAN   OFF CACHE BOOL "" FORCE)
SET(VIDEO_DUMMY    OFF CACHE BOOL "" FORCE)
SET(VIDEO_OPENGL   OFF CACHE BOOL "" FORCE)
SET(VIDEO_OPENGLES OFF CACHE BOOL "" FORCE)


# This assumes you want to have SDL as a static library. If not, set SDL_STATIC
# to OFF instead.
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
set(SDL_STATIC ON  CACHE BOOL "" FORCE)

ADD_SUBDIRECTORY(SDL2 EXCLUDE_FROM_ALL)

@mosra
Copy link
Owner

mosra commented Mar 1, 2021

Okay, I'm stupid, copypasted the DLL detection code from FindGLFW and forgot to change the target name so it's still asking for glfw there 😅 Fixing that.

Hrmm, so I'm able to make the GLFW errors go away if i update my SDL2 repo to the latest from the official github repo (now that they've migrated).

Probably rather related to SDL_SHARED being turned off now, not to the repo update I think. Locally I tested with 2.0.14 and current master, didn't try with older versions.

SDL_VIDEO should be enabled as you have it, yes, but I'm not sure about the VIDEO_* options. These are definitely needed for the GL context setup. Does the app run that way? What happens if you leave them at on?

@mosra
Copy link
Owner

mosra commented Mar 1, 2021

The accidental glfw target should be fixed with c7b640c 62628be (force-pushed to next, again). Can I ask you to try again, both with SDL_SHARED set to OFF and to ON? Thanks!

If it works, I'll merge to master.

@mosra
Copy link
Owner

mosra commented Mar 8, 2021

Commit 62628be is now in master as I expect this to work, however I will keep the issue open until I have a final confirmation from you that everything is indeed working as expected.

Thanks in advance.

@jonesmz
Copy link
Author

jonesmz commented Mar 10, 2021

Apologies for the delay.

I'm able to build without any compiler or linker errors with both shared and static SDL2 configuration.

This issue can be closed whenever you want.

Thank you!

@mosra
Copy link
Owner

mosra commented Mar 10, 2021

Wonderful, thanks for the confirmation 🎉

@mosra mosra closed this as completed Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants