Add CMake configuration files, meant for VC-devel/SDL2.framework#5721
Add CMake configuration files, meant for VC-devel/SDL2.framework#5721madebr merged 12 commits intolibsdl-org:mainfrom
Conversation
|
How about a new standalone cmake directory for each platform? Then everything in the appropriate directory will get copied into the release development package. Does that make sense? |
Is there a reason not to have it? |
Alternatively we could put them in the subdirectories for the associated projects, e.g. But would that confuse people, thinking that the files were needed or used for building SDL? |
|
These files are distribution-only files, so perhaps put them in |
Added complexity. |
|
By keeping it KISS, I was able to add |
a342ca7 to
61582a7
Compare
|
Can somebody with an Apple test the SDL2 framework CMake files? The I've attached a little Download link: CMakeLists.txt The cmake script needs to be run as: The search procedure of |
I've, once again, moved the files. |
Testing this now: |
|
If I make SDL2test optional, I get: |
|
Building fails to find SDL.h, possibly because SDL2_INCLUDE_DIRS isn't used anywhere? |
|
The Visual Studio support files worked great. |
If I change these lines in sdl2-config.cmake: #set(SDL2_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../Headers")
#set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR}")
#set(SDL2_LIBRARY "${CMAKE_CURRENT_LIST_DIR}/../../SDL2")
FIND_PATH(SDL2_INCLUDE_DIR SDL.h)
set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR}")
FIND_LIBRARY(SDL2_LIBRARY SDL2)Then CMakeCache.txt gets these variables: But the build still fails because SDL2_INCLUDE_DIR isn't used anywhere. |
Yeah, I forgot to use
We don't want to use cache variables in a cmake configuration file. In find modules (e.g. |
There's a difference between FIND_LIBRARY(SDL2_LIBRARY SDL2) and explicitly linking to the SDL2 dynamic library. The former adds SDL2 as a framework and the latter as a dylib. On Apple platforms we want to link to the framework, not the dylib inside it. |
|
Thanks, I think I understand frameworks a bit better now. Google searches learned me that I need to pass the folder containing the |
|
That's working much better! I had to fix the include path, and then it worked great. I also removed the other variables, since we need the Framework setup on Apple platforms. I did that as a separate commit though, in case we really need them and you want to drop it. |
|
It makes sense to remove the (now unused) variables. |
|
Should we add some documentation to pkg-support on how to use the new CMake support? |
|
Perhaps add a short example to its Something along the lines of:
My native language is not English, so you might want to rephrase things. |
|
hey, I don't understand much of the MacOS Framework stuff, but just to check, if I make my game executable target using set_target_properties(mygame PROPERTIES MACOSX_BUNDLE TRUE ...), where in Just checking because I am really used to |
This is just the CMake support bundled with the official release framework. We're not changing SDL if you're building it yourself. |
We build the SDL framework for macOS, iOS, and tvOS, including 32-bit and 64-bit architectures. Since this file will actually be included in the framework you're linking, it should be fine to use.
This PR adds 2 files that are specifically written for the Visual Studio development release.
(=the
SDL2-devel-2.x.y-VC.zipfiles)These files are meant to be put in the root folder (
SDL2-2.x.y).RFC for #5713, for distribution along the Visual Studio devel files.
It also has component support.
It supports the components:
SDL2,SDL2mainandSDL2test.For simplicity, these are the latter part of the
SDL2::SDL2,SDL2::SDL2mainandSDL2::SDL2testtargets.Description
Visual Studio development releases ship with no CMake configuration files.
Because of this, all CMake based consumers need to write (or steal) a
FindSDL2.cmakemodule.By shipping a SDL2 configuration module along binary releases,
consumers don't need a
FindSDL2.cmakeanymore (if we ship one for all configurations).They can then simply add
-DSDL2_dir=path/to/extracted/SDL2-2.x.yor-DCMAKE_PREFIX_PATH=path/to/extracted/SDL2-2.x.yto the cmake invocation. Or set theSDL2_DIRenvironment variable.As an example, consider the following cmake build script:
It fails when executing CMake as:
The message is:
Replacing the non-existing version
2.0.30with e.g.2.0.15will let CMake pick the first matching version. In my case2.0.14:Existing Issue(s)
This PR addresses the Visual Studio +Macos aspect of #5713.
Questions/More work needed
cmake/vcdista good location to store these files? These files are not meant to be used by SDL2's cmake build system.As long as this location is not added to
CMAKE_MODULE_PATH, I don't see an issue.COMPONENTsupport?COMPONENTsupport would be useful because the Visual Studio (and macos) don't ship a static library.By e.g. adding
STATIC,SHARED,TESTandMAINcomponents we can easily catch the absence of theSDL2::SDL2-statictarget.update: added
COMPONENTsupport.