(Reposting after my first post didn't get through because I hadn't
subscribed to the list first. Apologies if this gets duplicated.)
There's a suggestion in Modules/readme.txt and this post:
http://www.cmake.org/pipermail/cmake/2010-February/035085.html
that the FindXXX.cmake files should offer XXX_RUNTIME_LIBRARIES and
XXX_RUNTIME_LIBRARY_DIRS variables to let you know where the DLLs for a
library are, so I've added that feature for ZLIB, LibXml2, and LibXslt.
Patches below.
It should be noted that these variables will become more useful if we
get a couple changes in CMake:
XXX_RUNTIME_LIBRARY_DIRS is best used to set the PATH before debugging,
and currently on Windows the only way to do that is with a really
awkward workaround:
http://stackoverflow.com/questions/1005901/how-to-set-path-environment-variable-using-cmake-and-visual-studio-to-run-test
Or you can do what I'm doing and copy them into the appropriate build
folders at gen-time, which is obviously problematic if you ever update
your libs.
This would be a lot easier to use if we ever get this feature:
http://www.kwwidgets.org/Bug/view.php?id=8884
As far as XXX_RUNTIME_LIBRARIES, that's best used in INSTALL(FILES), and
it works pretty well for these three libraries, but it won't work as
well for libraries that include separate DLLs for optimized and debug
builds (like Boost or Qt). For that to work, INSTALL(FILES) will need a
way of specifying 'optimized', 'release', and 'general' keywords like
TARGET_LINK_LIBRARIES. In the meantime, it's probably best for these
variables to only include the release DLLs, which is why I left the
debug DLLs out of FindZLIB.cmake.
Also, I only did this for .dll files and not .so files. There's no
reason we couldn't, but it would be only marginally useful on
non-Windows platforms, since it's not typical to ship copies of shared
libraries on other platforms.
Cheers,
-Rick-
--- D:/Projects/StringWrangler/cmake/Modules/FindLibXml2.cmake Tue Feb 15
15:27:24 2011
+++
C:/Users/Skorpion/AppData/Local/Temp/FindLibXml2.cmak-revBASE.svn001.tmp.cmake
Thu May 19 04:07:39 2011
@@ -6,6 +6,8 @@
# LIBXML2_LIBRARIES - The libraries needed to use LibXml2
# LIBXML2_DEFINITIONS - Compiler switches required for using LibXml2
# LIBXML2_XMLLINT_EXECUTABLE - The XML checking tool xmllint coming with
LibXml2
+# LIBXML2_RUNTIME_LIBRARIES - The runtime libraries needed to use LibXml2
+# LIBXML2_RUNTIME_LIBRARY_DIRS - The runtime library dir
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
@@ -44,10 +46,16 @@
# for backwards compat. with KDE 4.0.x:
SET(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}")
+FIND_FILE(LIBXML2_RUNTIME_LIBRARIES NAMES libxml2.dll
+ PATH_SUFFIXES bin
+ )
+
+GET_FILENAME_COMPONENT(LIBXML2_RUNTIME_LIBRARY_DIRS
"${LIBXML2_RUNTIME_LIBRARIES}" PATH)
+
# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES
LIBXML2_INCLUDE_DIR)
-MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES
LIBXML2_XMLLINT_EXECUTABLE)
+MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES
LIBXML2_XMLLINT_EXECUTABLE LIBXML2_RUNTIME_LIBRARIES
LIBXML2_RUNTIME_LIBRARY_DIRS)
--- D:/Projects/StringWrangler/cmake/Modules/FindLibXslt.cmake Tue Feb 15
15:27:24 2011
+++
C:/Users/Skorpion/AppData/Local/Temp/FindLibXslt.cmake-revBASE.svn000.tmp.cmake
Thu May 19 04:08:17 2011
@@ -5,6 +5,8 @@
# LIBXSLT_INCLUDE_DIR - the LibXslt include directory
# LIBXSLT_LIBRARIES - Link these to LibXslt
# LIBXSLT_DEFINITIONS - Compiler switches required for using LibXslt
+# LIBXSLT_RUNTIME_LIBRARIES - The runtime libraries needed to use LibXslt
+# LIBXSLT_RUNTIME_LIBRARY_DIRS - The runtime library dir
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
@@ -38,10 +40,16 @@
${PC_LIBXSLT_LIBRARY_DIRS}
)
+FIND_FILE(LIBXSLT_RUNTIME_LIBRARIES NAMES libxslt.dll
+ PATH_SUFFIXES bin
+ )
+
+GET_FILENAME_COMPONENT(LIBXSLT_RUNTIME_LIBRARY_DIRS
"${LIBXSLT_RUNTIME_LIBRARIES}" PATH)
+
# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXslt DEFAULT_MSG LIBXSLT_LIBRARIES
LIBXSLT_INCLUDE_DIR)
-MARK_AS_ADVANCED(LIBXSLT_INCLUDE_DIR LIBXSLT_LIBRARIES)
+MARK_AS_ADVANCED(LIBXSLT_INCLUDE_DIR LIBXSLT_LIBRARIES
LIBXSLT_RUNTIME_LIBRARIES LIBXSLT_RUNTIME_LIBRARY_DIRS)
--- D:/Projects/StringWrangler/cmake/Modules/FindZLIB.cmake Tue Feb 15
15:27:24 2011
+++ C:/Users/Skorpion/AppData/Local/Temp/FindZLIB.cmak-revBASE.svn001.tmp.cmake
Thu May 19 04:32:07 2011
@@ -2,9 +2,11 @@
# Find the native ZLIB includes and library.
# Once done this will define
#
-# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
-# ZLIB_LIBRARIES - List of libraries when using zlib.
-# ZLIB_FOUND - True if zlib found.
+# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
+# ZLIB_LIBRARIES - List of libraries when using zlib.
+# ZLIB_RUNTIME_LIBRARIES - The runtime libraries needed to use zlib.
+# ZLIB_RUNTIME_LIBRARY_DIRS - The runtime library dir.
+# ZLIB_FOUND - True if zlib found.
#
# ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
# ZLIB_VERSION_MAJOR - The major version of zlib
@@ -42,8 +44,23 @@
PATHS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/lib"
)
-MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
+SET(ZLIB_RUNTIME_NAMES z.dll zlib.dll zdll.dll zlib1.dll)
+FIND_FILE(ZLIB_RUNTIME_LIBRARY
+ NAMES
+ ${ZLIB_RUNTIME_NAMES}
+ PATHS
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/bin"
+)
+FIND_PATH(ZLIB_RUNTIME_LIBRARY_DIR
+ NAMES
+ ${ZLIB_RUNTIME_NAMES}
+ PATHS
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/bin"
+)
+
+MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR ZLIB_RUNTIME_LIBRARY
ZLIB_RUNTIME_LIBRARY_DIR)
+
IF(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
FILE(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define
ZLIB_VERSION \"[^\"]*\"$")
@@ -73,5 +90,7 @@
IF(ZLIB_FOUND)
SET(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
SET(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
+ SET(ZLIB_RUNTIME_LIBRARIES ${ZLIB_RUNTIME_LIBRARY})
+ SET(ZLIB_RUNTIME_LIBRARY_DIRS ${ZLIB_RUNTIME_LIBRARY_DIR})
ENDIF()
_______________________________________________
cmake-developers mailing list
[email protected]
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers