[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2334: Add some CMake fu to find the right OpenSSL libs, based on t (in vidalia/trunk: . cmake src/util)
Author: edmanm
Date: 2008-01-28 21:33:38 -0500 (Mon, 28 Jan 2008)
New Revision: 2334
Added:
vidalia/trunk/cmake/
vidalia/trunk/cmake/FindOpenSSL.cmake
Modified:
vidalia/trunk/CMakeLists.txt
vidalia/trunk/src/util/CMakeLists.txt
Log:
Add some CMake fu to find the right OpenSSL libs, based on the
FindOpenSSL.cmake module from the CMake distribution. We still need
some more CMake fu to poke at the chosen Qt build to see if OpenSSL
libs are needed or not, but this should work in the common case.
Modified: vidalia/trunk/CMakeLists.txt
===================================================================
--- vidalia/trunk/CMakeLists.txt 2008-01-28 11:17:37 UTC (rev 2333)
+++ vidalia/trunk/CMakeLists.txt 2008-01-29 02:33:38 UTC (rev 2334)
@@ -67,12 +67,17 @@
## Check for QSslSocket
check_include_file_cxx("qsslsocket.h" HAVE_QSSLSOCKET_H)
-if(HAVE_QSSLSOCKET_H)
+if (HAVE_QSSLSOCKET_H)
check_symbol_exists(QT_NO_OPENSSL "QtGlobal" QT_NO_SSL_SUPPORT)
- if(NOT QT_NO_SSL_SUPPORT)
+ if (NOT QT_NO_SSL_SUPPORT)
option(USE_QSSLSOCKET "Use Qt's QSslSocket for GeoIP lookups." ON)
endif(NOT QT_NO_SSL_SUPPORT)
endif(HAVE_QSSLSOCKET_H)
+if (USE_QSSLSOCKET)
+ if (MSVC OR UNIX)
+ include(${CMAKE_SOURCE_DIR}/cmake/FindOpenSSL.cmake)
+ endif(MSVC OR UNIX)
+endif(USE_QSSLSOCKET)
## Write out a configuration file
configure_file(
@@ -86,11 +91,3 @@
add_subdirectory(doc)
add_subdirectory(pkg)
-## The 'confclean' target removes cached CMake configuration information
-if (WIN32)
- set(RM_CMD del)
-else (WIN32)
- set(RM_CMD rm)
-endif(WIN32)
-add_custom_target(confclean ${RM_CMD} CMakeCache.txt)
-
Added: vidalia/trunk/cmake/FindOpenSSL.cmake
===================================================================
--- vidalia/trunk/cmake/FindOpenSSL.cmake (rev 0)
+++ vidalia/trunk/cmake/FindOpenSSL.cmake 2008-01-29 02:33:38 UTC (rev 2334)
@@ -0,0 +1,127 @@
+# $Id: CMakeLists.txt 2327 2008-01-27 15:51:39Z edmanm $
+#
+# Vidalia is distributed under the following license:
+#
+# Copyright (C) 2006-2007, Matt Edman, Justin Hipple
+# Copyright (C) 2008, Matt Edman
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+#
+# This file incorporates work covered by the following copyright and
+# permission notice:
+#
+# Copyright (c) 2006, Alexander Neundorf, <neundorf@xxxxxxx>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# * Neither the names of the copyright owners nor the names of its
+# contributors may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+# Tries to find the required OpenSSL libraries. Once done this will define
+# the variable OPENSSL_LIBRARIES.
+
+message(STATUS "Looking for OpenSSL libraries")
+if (MSVC)
+ # /MD and /MDd are the standard values - if somone wants to use
+ # others, the libnames have to change here too
+ # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
+
+ find_library(OPENSSL_LIBSSL_DEBUG
+ NAMES ssleay32MDd ssl ssleay32
+ PATHS ${OPENSSL_LIBRARY_DIR}
+ )
+ find_library(OPENSSL_LIBSSL_RELEASE
+ NAMES ssleay32MD ssl ssleay32
+ PATHS ${OPENSSL_LIBRARY_DIR}
+ )
+ find_library(OPENSSL_LIBCRYPTO_DEBUG
+ NAMES libeay32MDd crypto libeay32
+ PATHS ${OPENSSL_LIBRARY_DIR}
+ )
+ find_library(OPENSSL_LIBCRYPTO_RELEASE
+ NAMES libeay32MD crypto libeay32
+ PATHS ${OPENSSL_LIBRARY_DIR}
+ )
+
+ if (MSVC_IDE)
+ if (NOT OPENSSL_LIBSSL_DEBUG OR NOT OPENSSL_LIBSSL_RELEASE)
+ message(FATAL_ERROR
+ "Could not find the debug and release version of libssl.")
+ endif(NOT OPENSSL_LIBSSL_DEBUG OR NOT OPENSSL_LIBSSL_RELEASE)
+ if (NOT OPENSSL_LIBCRYPTO_DEBUG OR NOT OPENSSL_LIBCRYPTO_RELEASE)
+ message(FATAL_ERROR
+ "Could not find the debug and release version of libcrypto.")
+ endif(NOT OPENSSL_LIBCRYPTO_DEBUG OR NOT OPENSSL_LIBCRYPTO_RELEASE)
+
+ set(OPENSSL_LIBSSL
+ optimized ${OPENSSL_LIBSSL_RELEASE}
+ debug ${OPENSSL_LIBSSL_DEBUG})
+ set(OPENSSL_LIBCRYPTO
+ optimized ${OPENSSL_LIBCRYPTO_RELEASE}
+ debug ${OPENSSL_LIBCRYPTO_DEBUG})
+ else(MSVC_IDE)
+ string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
+ if (CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
+ set(OPENSSL_LIBSSL ${OPENSSL_LIBSSL_DEBUG})
+ set(OPENSSL_LIBCRYPTO ${OPENSSL_LIBCRYPTO_DEBUG})
+ else(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
+ set(OPENSSL_LIBSSL ${OPENSSL_LIBSSL_RELEASE})
+ set(OPENSSL_LIBCRYPTO ${OPENSSL_LIBCRYPTO_RELEASE})
+ endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
+ endif(MSVC_IDE)
+ mark_as_advanced(OPENSSL_LIBSSL_DEBUG OPENSSL_LIBCRYPTO_DEBUG
+ OPENSSL_LIBSSL_RELEASE OPENSSL_LIBCRYPTO_RELEASE)
+else(MSVC)
+ find_library(OPENSSL_LIBSSL NAMES ssl ssleay32)
+ find_library(OPENSSL_LIBCRYPTO NAMES crypto libeay32)
+endif(MSVC)
+
+
+if (OPENSSL_LIBSSL AND OPENSSL_LIBCRYPTO)
+ set(OPENSSL_LIBRARIES ${OPENSSL_LIBSSL} ${OPENSSL_LIBCRYPTO})
+ mark_as_advanced(OPENSSL_LIBSSL OPENSSL_LIBCRYPTO)
+ mark_as_advanced(OPENSSL_LIBRARIES)
+ message(STATUS "Looking for OpenSSL libraries - found")
+else (OPENSSL_LIBSSL AND OPENSSL_LIBCRYPTO)
+ if (NOT OPENSSL_LIBSSL)
+ message(FATAL_ERROR "Could not find libssl.")
+ else (NOT OPENSSL_LIBSSL)
+ message(FATAL_ERROR "Could not find libcrypto.")
+ endif (NOT OPENSSL_LIBSSL)
+endif(OPENSSL_LIBSSL AND OPENSSL_LIBCRYPTO)
+
Modified: vidalia/trunk/src/util/CMakeLists.txt
===================================================================
--- vidalia/trunk/src/util/CMakeLists.txt 2008-01-28 11:17:37 UTC (rev 2333)
+++ vidalia/trunk/src/util/CMakeLists.txt 2008-01-29 02:33:38 UTC (rev 2334)
@@ -51,14 +51,7 @@
add_library(util STATIC ${util_SRCS})
target_link_libraries(util ${QT_LIBRARIES})
-if(USE_QSSLSOCKET)
- target_link_libraries(util)
- if(UNIX)
- ## XXX: This is not quite right, since we still may need to link in
- ## OpenSSL libs on Windows as well, depending on how Qt was built.
- ## It suffices for the default Qt install on Windows though, until we
- ## gets some more complex CMake fu in.
- target_link_libraries(util crypto ssl)
- endif(UNIX)
-endif(USE_QSSLSOCKET)
+if(USE_QSSLSOCKET AND OPENSSL_LIBRARIES)
+ target_link_libraries(util ${OPENSSL_LIBRARIES})
+endif(USE_QSSLSOCKET AND OPENSSL_LIBRARIES)