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

macOS unable to find target SDL2::SDL2 #309

Closed
VladBolotov opened this Issue Feb 3, 2019 · 4 comments

Comments

2 participants
@VladBolotov
Copy link

VladBolotov commented Feb 3, 2019

Hello. I was trying to compile “Primitives example” on macOS. Magnum was installed from brew.

brew install mosra/magnum/corrade --HEAD
brew install mosra/magnum/magnum –HEAD
brew install morsa/magnum/magnum-plugins --HEAD

And I am getting this CMake error:

CMake Error at CMakeLists.txt:47 (add_executable):
  Target "magnum-primitives" links to target "SDL2::SDL2" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

brew list:

assimp		cminpack	freetype	glib		icu4c		libmodplug	libvorbis	octomap		python@2	sdl2_image	vtk
boost		corrade		gcc		glm		isl		libmpc		little-cms2	openssl		qhull		sdl2_mixer	webp
boost-python	devil		gdbm		gmp		jasper		libogg		magnum		pcre		qt		sdl2_ttf	xz
bullet		eigen		gettext		graphite2	jpeg		libpng		magnum-plugins	pixman		readline	sip
cairo		flann		glew		harfbuzz	libffi		libtiff		mpfr		pyqt		sdl2		sqlite
cmake		fontconfig	glfw		hdf5		libmikmod	libusb		netcdf		python		sdl2_gfx	szip


brew info magnum
mosra/magnum/magnum: stable 2018.10, HEAD
C++11/C++14 graphics middleware for games and data visualization
https://magnum.graphics
/usr/local/Cellar/magnum/HEAD-11f6835 (358 files, 7.0MB) *
  Built from source on 2019-02-03 at 22:33:38
From: https://github.com/mosra/homebrew-magnum/blob/master/Formula/magnum.rb
==> Dependencies
Required: cmake ✔, corrade ✔, sdl2 ✔, glfw ✔
==> Options
--HEAD
	Install HEAD version

@mosra mosra added this to the 2019.01 milestone Feb 4, 2019

@mosra mosra added this to TODO in Project management via automation Feb 4, 2019

@mosra mosra self-assigned this Feb 4, 2019

@mosra

This comment has been minimized.

Copy link
Owner

mosra commented Feb 4, 2019

Hello! Your avatar is very hypnotic. :)

How are you building the example? This error happens probably because the magnum's FindSDL2.cmake is not found and the builtin CMake SDL finding routine is not doing the right thing. If you follow the project structure in the Getting Started Guide, it should work, you can also clone the whole magnum-examples repository and build that.

I just realized the example documentation is quite lacking in this regard, I'm going to update it.

@mosra

This comment has been minimized.

Copy link
Owner

mosra commented Feb 4, 2019

@mosra mosra closed this Feb 4, 2019

Project management automation moved this from TODO to Done Feb 4, 2019

@VladBolotov

This comment has been minimized.

Copy link
Author

VladBolotov commented Feb 5, 2019

> Your avatar is _very_ hypnotic. :)
Yes, sometimes I am looking at it for a minutes. ;)

I made it work. Many thanks for your advices.

And... Just some feedback.

Looks like only FindSDL2 was missing. Its works without any other modules like i.e. FindCorrade, FindMagnumExtras. All examples are working (macOS) with such structure:

root/
    CMakeLists.txt
    modules/
	FindSDL2.cmake
    sources/
	Main.cpp
	CMakeLists.txt

I was able to compile same program under Windows (VCPKG) without modules at all.

> How are you building the example?

  • brew install all stuff…
  • CMD+C/V to New CLion project
  • Got SDL error.
  • Tried to fix it with some additional CMake instructions around SDL2.
  • Created an issue.
@mosra

This comment has been minimized.

Copy link
Owner

mosra commented Feb 5, 2019

Looks like only FindSDL2 was missing

Yes, you're right. the FindCorrade and FindMagnum modules are installed so CMake is able to pick them up. The FindSDL2 module isn't because it's for a third-party library and if I would install it too, it might cause random conflicts with potentially different FindSDL2 modules of other projects. I'm still looking for a better solution for this, but the only other option I see right now is to travel back in time and add this module to upstream CMake for all versions back to 3.1. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment