| Summary: | Configure generated sdl2-config.cmake should contain version | ||
|---|---|---|---|
| Product: | SDL | Reporter: | alexander.grund |
| Component: | build | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | CC: | icculus, josh+sdl |
| Version: | 2.0.10 | Keywords: | target-2.0.12 |
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
Patch with autogen
Patch without autogen changes |
||
|
Description
alexander.grund
2020-02-07 15:43:39 UTC
This should be fixed by https://hg.libsdl.org/SDL/rev/d62544e5fa7a but let me know if I messed this up, please! --ryan. Created attachment 4223 [details] Patch with autogen Thanks ryan, that was what I meant but I was wrong in how it should look like. Apparently you need a separate version file, see the full description at https://cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html I took a shot at this myself and additionally created the targets that would be created by the CMake scripts. The resulting files on my system look like this: sdl2-config.cmake: # sdl2 cmake project-config input for ./configure scripts set(prefix "/tmp/sdl2") set(exec_prefix "${prefix}") set(libdir "${exec_prefix}/lib") set(SDL2_PREFIX "/tmp/sdl2") set(SDL2_EXEC_PREFIX "/tmp/sdl2") set(SDL2_LIBDIR "${exec_prefix}/lib") set(SDL2_INCLUDE_DIRS "${prefix}/include/SDL2") set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} -Wl,-rpath,${libdir} -Wl,--enable-new-dtags -lSDL2") string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES) if(NOT TARGET SDL2::SDL2) # Remove -lSDL2 as that is handled by CMake, note the space at the end so it does not replace e.g. -lSDL2main # This may require "libdir" beeing set (from above) string(REPLACE "-lSDL2 " "" SDL2_EXTRA_LINK_FLAGS "-Wl,-rpath,${libdir} -Wl,--enable-new-dtags -lSDL2 ") string(STRIP "${SDL2_EXTRA_LINK_FLAGS}" SDL2_EXTRA_LINK_FLAGS) string(REPLACE "-lSDL2 " "" SDL2_EXTRA_LINK_FLAGS_STATIC "-Wl,-rpath,${libdir} -Wl,--enable-new-dtags -lSDL2 -Wl,--no-undefined -lm -ldl -lpthread -lrt ") string(STRIP "${SDL2_EXTRA_LINK_FLAGS_STATIC}" SDL2_EXTRA_LINK_FLAGS_STATIC) add_library(SDL2::SDL2 SHARED IMPORTED) set_target_properties(SDL2::SDL2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${prefix}/include/SDL2" IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${exec_prefix}/lib/libSDL2.so" INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS}") add_library(SDL2::SDL2-static STATIC IMPORTED) set_target_properties(SDL2::SDL2-static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${prefix}/include/SDL2" IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${exec_prefix}/lib/libSDL2.a" INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS_STATIC}") add_library(SDL2::SDL2main STATIC IMPORTED) set_target_properties(SDL2::SDL2main PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${exec_prefix}/lib/libSDL2main.a") endif() sdl2-config-version.cmake: set(PACKAGE_VERSION "2.0.10") if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) set(PACKAGE_VERSION_COMPATIBLE FALSE) else() set(PACKAGE_VERSION_COMPATIBLE TRUE) if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) set(PACKAGE_VERSION_EXACT TRUE) endif() endif() Created attachment 4224 [details]
Patch without autogen changes
Note that the patch(es) were created on top of 2.0.10. Your changes from https://hg.libsdl.org/SDL/rev/d62544e5fa7a may need to be reverted first (not required after this patch as CMake will set SDL2_VERSION and SDL2_VERSION_* variables) This patch is now https://hg.libsdl.org/SDL/rev/ef2d5382a887, thanks! --ryan. Seems the addition of sdl2-config-version.cmake.in is missing. I suggest to test-build with autotools and compare the 2 generated files in the installation folder with my example in https://bugzilla.libsdl.org/show_bug.cgi?id=4970#c2 I just wanted to confirm that what's in the latest snapshot is correct? http://www.libsdl.org/tmp/SDL-2.0.zip Thanks! Yes I successfully verified SDL-2.0.11-13563 is working with a CMake project. Thanks! Great, thanks! (In reply to Ryan C. Gordon from comment #5) > This patch is now https://hg.libsdl.org/SDL/rev/ef2d5382a887, thanks! This results in an incorrect library suffix being used on macOS (originally reported in https://github.com/macports/macports-ports/pull/6581). Would you like me to open a new bug for this issue? Sorry for the wrong suffix. Best would be to use CMAKE_SHARED_LIBRARY_SUFFIX and CMAKE_STATIC_LIBRARY_SUFFIX. But it needs double-checking with the code generating the library names. As I don't know autotools well enough, I'll leave this to someone else. But my bet would be that using CMAKE_*_LIBRARY_SUFFIX solves the problem already. Ryan, this is a regression, can you look at this ASAP? Actually, Joshua, can you open a new bug for the regression? Thanks! (In reply to Sam Lantinga from comment #13) > Actually, Joshua, can you open a new bug for the regression? Done: bug 5039. FWIW: This is NOT a regression as only the new feature (the target) is affected. The old Variables which existed before are untouched But yes should be changed ASAP |