[PATCH] sdl2-config.cmake: don't leak prefix, exec_prefix, libdir

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] sdl2-config.cmake: don't leak prefix, exec_prefix, libdir

Bugzilla from mezin.alexander@gmail.com
sdl2-config.cmake set prefix, exec_prefix, libdir in the scope where
find_package() was called. Even worse, it overwrote these variables if
they were defined.

Example:

    set(prefix "testprefix")
    find_package(sdl2 REQUIRED)
    message(STATUS "prefix: ${prefix}")

Output before:

    prefix: /usr/local

Output after:

    prefix: testprefix
---
 sdl2-config.cmake.in | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/sdl2-config.cmake.in b/sdl2-config.cmake.in
index 03efbe1..cb0821b 100644
--- a/sdl2-config.cmake.in
+++ b/sdl2-config.cmake.in
@@ -1,11 +1,22 @@
 # sdl2 cmake project-config input for ./configure scripts

-set(prefix "@prefix@")
-set(exec_prefix "@exec_prefix@")
-set(libdir "@libdir@")
-set(SDL2_PREFIX "@prefix@")
-set(SDL2_EXEC_PREFIX "@prefix@")
-set(SDL2_LIBDIR "@libdir@")
-set(SDL2_INCLUDE_DIRS "@includedir@/SDL2")
-set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} @SDL_RLD_FLAGS@ @SDL_LIBS@")
-string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
+function(_sdl2_define_config)
+  set(prefix "@prefix@")
+  set(exec_prefix "@exec_prefix@")
+  set(libdir "@libdir@")
+
+  set(SDL2_PREFIX "@prefix@")
+  set(SDL2_EXEC_PREFIX "@prefix@")
+  set(SDL2_LIBDIR "@libdir@")
+  set(SDL2_INCLUDE_DIRS "@includedir@/SDL2")
+  set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} @SDL_RLD_FLAGS@ @SDL_LIBS@")
+  string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
+
+  set(SDL2_PREFIX "${SDL2_PREFIX}" PARENT_SCOPE)
+  set(SDL2_EXEC_PREFIX "${SDL2_EXEC_PREFIX}" PARENT_SCOPE)
+  set(SDL2_LIBDIR "${SDL2_LIBDIR}" PARENT_SCOPE)
+  set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIRS}" PARENT_SCOPE)
+  set(SDL2_LIBRARIES "${SDL2_LIBRARIES}" PARENT_SCOPE)
+endfunction()
+
+_sdl2_define_config()
--
2.10.1 (Apple Git-78)
_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Loading...