Dear CMake developers,
I extended the find module for SDL_net by version support (see the attached
patch). If you are interested, I am willing to write similar patches for the
other SDL_.* modules or one for SDL_gfx (see issue 0012004).
The find module has a problem: It does not define SDL_net_FOUND, but
SDLNET_FOUND. Therefore, FeatureSummary does not work as expected. Shall I
open a bug report for this?
Kind regards
Benjamin
--- /usr/share/cmake-2.8/Modules/FindSDL_net.cmake 2012-08-09 20:15:19.0 +0200
+++ /usr/share/cmake-2.8/Modules/FindSDL_net.cmake 2012-08-29 12:29:56.0 +0200
@@ -3,6 +3,7 @@
# SDLNET_LIBRARY, the name of the library to link against
# SDLNET_FOUND, if false, do not try to link against
# SDLNET_INCLUDE_DIR, where to find the headers
+# SDLNET_VERSION_STRING - human-readable string containing the version of SDL_net
#
# $SDLDIR is an environment variable that would
# correspond to the ./configure --prefix=$SDLDIR
@@ -63,7 +64,24 @@
/opt
)
+IF(SDLNET_INCLUDE_DIR AND EXISTS "${SDLNET_INCLUDE_DIR}/SDL_net.h")
+ FILE(STRINGS "${SDLNET_INCLUDE_DIR}/SDL_net.h" SDLNET_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+[0-9]+$")
+ FILE(STRINGS "${SDLNET_INCLUDE_DIR}/SDL_net.h" SDLNET_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+[0-9]+$")
+ FILE(STRINGS "${SDLNET_INCLUDE_DIR}/SDL_net.h" SDLNET_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+[0-9]+$")
+ STRING(REGEX REPLACE "^#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDLNET_VERSION_MAJOR "${SDLNET_VERSION_MAJOR_LINE}")
+ STRING(REGEX REPLACE "^#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDLNET_VERSION_MINOR "${SDLNET_VERSION_MINOR_LINE}")
+ STRING(REGEX REPLACE "^#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDLNET_VERSION_PATCH "${SDLNET_VERSION_PATCH_LINE}")
+ SET(SDLNET_VERSION_STRING ${SDLNET_VERSION_MAJOR}.${SDLNET_VERSION_MINOR}.${SDLNET_VERSION_PATCH})
+ UNSET(SDLNET_VERSION_MAJOR_LINE)
+ UNSET(SDLNET_VERSION_MINOR_LINE)
+ UNSET(SDLNET_VERSION_PATCH_LINE)
+ UNSET(SDLNET_VERSION_MAJOR)
+ UNSET(SDLNET_VERSION_MINOR)
+ UNSET(SDLNET_VERSION_PATCH)
+ENDIF()
+
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDLNET
- REQUIRED_VARS SDLNET_LIBRARY SDLNET_INCLUDE_DIR)
+ REQUIRED_VARS SDLNET_LIBRARY SDLNET_INCLUDE_DIR
+ VERSION_VAR SDLNET_VERSION_STRING)
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers