Discussion:
[PATCH] sdl2-config.cmake: don't leak prefix, exec_prefix, libdir
(too old to reply)
Aleksandr Mezin
2017-02-13 00:27:59 UTC
Permalink
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)

Loading...