Add QCA2 checks to build system
authorunc0rr
Wed, 25 Feb 2009 17:36:02 +0000
changeset 1843 16cdd1745b73
parent 1842 96a4757dfeb8
child 1844 81abed9d4c11
Add QCA2 checks to build system
CMakeLists.txt
QTfrontend/CMakeLists.txt
cmake_modules/FindLibraryWithDebug.cmake
cmake_modules/FindQCA2.cmake
hedgewars.kdevelop
--- a/CMakeLists.txt	Wed Feb 25 17:18:12 2009 +0000
+++ b/CMakeLists.txt	Wed Feb 25 17:36:02 2009 +0000
@@ -6,6 +6,7 @@
 	cmake_policy(SET CMP0003 NEW)
 endif(COMMAND cmake_policy)
 
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules)
 
 set(CPACK_PACKAGE_VERSION_MAJOR "0")
 set(CPACK_PACKAGE_VERSION_MINOR "9")
--- a/QTfrontend/CMakeLists.txt	Wed Feb 25 17:18:12 2009 +0000
+++ b/QTfrontend/CMakeLists.txt	Wed Feb 25 17:36:02 2009 +0000
@@ -11,6 +11,9 @@
 find_package(Qt4 REQUIRED)
 include(${QT_USE_FILE})
 
+find_package(QCA2 REQUIRED)
+include_directories(${QCA2_INCLUDE_DIR})
+
 # Configure for SDL
 find_package(SDL REQUIRED)
 find_package(SDL_mixer REQUIRED)
@@ -152,6 +155,7 @@
 	
 set(HW_LINK_LIBS 
 	${QT_LIBRARIES}
+	${QCA2_LIBRARIES}
 	${SDL_LIBRARY}
 	${SDLMIXER_LIBRARY}
 	)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake_modules/FindLibraryWithDebug.cmake	Wed Feb 25 17:36:02 2009 +0000
@@ -0,0 +1,113 @@
+#
+#  FIND_LIBRARY_WITH_DEBUG
+#  -> enhanced FIND_LIBRARY to allow the search for an
+#     optional debug library with a WIN32_DEBUG_POSTFIX similar
+#     to CMAKE_DEBUG_POSTFIX when creating a shared lib
+#     it has to be the second and third argument
+
+# Copyright (c) 2007, Christian Ehrlicher, <ch.ehrlicher@gmx.de>
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+MACRO(FIND_LIBRARY_WITH_DEBUG var_name win32_dbg_postfix_name dgb_postfix libname)
+
+  IF(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX")
+
+     # no WIN32_DEBUG_POSTFIX -> simply pass all arguments to FIND_LIBRARY
+     FIND_LIBRARY(${var_name}
+                  ${win32_dbg_postfix_name}
+                  ${dgb_postfix}
+                  ${libname}
+                  ${ARGN}
+     )
+
+  ELSE(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX")
+
+    IF(NOT WIN32)
+      # on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX
+
+      FIND_LIBRARY(${var_name} ${libname} ${ARGN})
+
+    ELSE(NOT WIN32)
+
+      # 1. get all possible libnames
+      SET(args ${ARGN})
+      SET(newargs "")
+      SET(libnames_release "")
+      SET(libnames_debug "")
+
+      LIST(LENGTH args listCount)
+
+      IF("${libname}" STREQUAL "NAMES")
+        SET(append_rest 0)
+        LIST(APPEND args " ")
+
+        FOREACH(i RANGE ${listCount})
+          LIST(GET args ${i} val)
+
+          IF(append_rest)
+            LIST(APPEND newargs ${val})
+          ELSE(append_rest)
+            IF("${val}" STREQUAL "PATHS")
+              LIST(APPEND newargs ${val})
+              SET(append_rest 1)
+            ELSE("${val}" STREQUAL "PATHS")
+              LIST(APPEND libnames_release "${val}")
+              LIST(APPEND libnames_debug   "${val}${dgb_postfix}")
+            ENDIF("${val}" STREQUAL "PATHS")
+          ENDIF(append_rest)
+
+        ENDFOREACH(i)
+
+      ELSE("${libname}" STREQUAL "NAMES")
+
+        # just one name
+        LIST(APPEND libnames_release "${libname}")
+        LIST(APPEND libnames_debug   "${libname}${dgb_postfix}")
+
+        SET(newargs ${args})
+
+      ENDIF("${libname}" STREQUAL "NAMES")
+
+      # search the release lib
+      FIND_LIBRARY(${var_name}_RELEASE
+                   NAMES ${libnames_release}
+                   ${newargs}
+      )
+
+      # search the debug lib
+      FIND_LIBRARY(${var_name}_DEBUG
+                   NAMES ${libnames_debug}
+                   ${newargs}
+      )
+
+      IF(${var_name}_RELEASE AND ${var_name}_DEBUG)
+
+        # both libs found
+        SET(${var_name} optimized ${${var_name}_RELEASE}
+                        debug     ${${var_name}_DEBUG})
+
+      ELSE(${var_name}_RELEASE AND ${var_name}_DEBUG)
+
+        IF(${var_name}_RELEASE)
+
+          # only release found
+          SET(${var_name} ${${var_name}_RELEASE})
+
+        ELSE(${var_name}_RELEASE)
+
+          # only debug (or nothing) found
+          SET(${var_name} ${${var_name}_DEBUG})
+
+        ENDIF(${var_name}_RELEASE)
+       
+      ENDIF(${var_name}_RELEASE AND ${var_name}_DEBUG)
+
+      MARK_AS_ADVANCED(${var_name}_RELEASE)
+      MARK_AS_ADVANCED(${var_name}_DEBUG)
+
+    ENDIF(NOT WIN32)
+
+  ENDIF(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX")
+
+ENDMACRO(FIND_LIBRARY_WITH_DEBUG)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake_modules/FindQCA2.cmake	Wed Feb 25 17:36:02 2009 +0000
@@ -0,0 +1,48 @@
+# - Try to find QCA2 (Qt Cryptography Architecture 2)
+# Once done this will define
+#
+#  QCA2_FOUND - system has QCA2
+#  QCA2_INCLUDE_DIR - the QCA2 include directory
+#  QCA2_LIBRARIES - the libraries needed to use QCA2
+#  QCA2_DEFINITIONS - Compiler switches required for using QCA2
+#
+# use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+
+# Copyright (c) 2006, Michael Larouche, <michael.larouche@kdemail.net>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+include(FindLibraryWithDebug)
+
+if (QCA2_INCLUDE_DIR AND QCA2_LIBRARIES)
+
+  # in cache already
+  set(QCA2_FOUND TRUE)
+
+else (QCA2_INCLUDE_DIR AND QCA2_LIBRARIES)
+
+
+  if (NOT WIN32)
+    find_package(PkgConfig)
+    pkg_check_modules(PC_QCA2 qca2)
+    set(QCA2_DEFINITIONS ${PC_QCA2_CFLAGS_OTHER})
+  endif (NOT WIN32)
+
+  find_library_with_debug(QCA2_LIBRARIES
+                  WIN32_DEBUG_POSTFIX d
+                  NAMES qca
+                  HINTS ${PC_QCA2_LIBDIR} ${PC_QCA2_LIBRARY_DIRS}
+                  )
+
+  find_path(QCA2_INCLUDE_DIR qca.h 
+            HINTS ${PC_QCA2_INCLUDEDIR} ${PC_QCA2_INCLUDE_DIRS}
+            PATH_SUFFIXES QtCrypto)
+
+  include(FindPackageHandleStandardArgs)
+  find_package_handle_standard_args(QCA2  DEFAULT_MSG  QCA2_LIBRARIES QCA2_INCLUDE_DIR)
+
+  mark_as_advanced(QCA2_INCLUDE_DIR QCA2_LIBRARIES)
+
+endif (QCA2_INCLUDE_DIR AND QCA2_LIBRARIES)
--- a/hedgewars.kdevelop	Wed Feb 25 17:18:12 2009 +0000
+++ b/hedgewars.kdevelop	Wed Feb 25 17:36:02 2009 +0000
@@ -215,7 +215,7 @@
       <hidenonlocation>false</hidenonlocation>
     </groups>
     <tree>
-      <hidepatterns></hidepatterns>
+      <hidepatterns/>
       <hidenonprojectfiles>true</hidenonprojectfiles>
       <showvcsfields>false</showvcsfields>
     </tree>