diff options
author | Ian Monroe <ian.monroe@collabora.co.uk> | 2009-04-10 16:22:01 -0500 |
---|---|---|
committer | Dario Freddi <dario.freddi@collabora.co.uk> | 2010-09-20 17:03:39 +0200 |
commit | 57658488f07b45d2057a0fa5a78df8f7c85f5fee (patch) | |
tree | 85b6463b3cccedde966464e23910f8ec4371e96b /cmake | |
parent | 02882fa8091e78f9a067210ee97e50a00ac94e04 (diff) |
Added the CMake build system files. This allows telepathy-qt4 to be built
on Windows.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/Doxygen.cmake | 25 | ||||
-rw-r--r-- | cmake/modules/FindLibPython.py | 12 | ||||
-rw-r--r-- | cmake/modules/FindPythonLibrary.cmake | 84 | ||||
-rw-r--r-- | cmake/modules/TelepathyDefaults.cmake | 62 | ||||
-rw-r--r-- | cmake/modules/TelepathyDist.cmake | 10 | ||||
-rw-r--r-- | cmake/modules/distcheck.py | 83 |
6 files changed, 276 insertions, 0 deletions
diff --git a/cmake/modules/Doxygen.cmake b/cmake/modules/Doxygen.cmake new file mode 100644 index 00000000..ba77af5a --- /dev/null +++ b/cmake/modules/Doxygen.cmake @@ -0,0 +1,25 @@ +# generate documentation on 'make doxygen-doc' +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/doc) + +find_package(Doxygen) +if(DOXYGEN_FOUND) + find_program(QHELPGENERATOR_EXECUTABLE qhelpgenerator) + mark_as_advanced(QHELPGENERATOR_EXECUTABLE) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(QHELPGENERATOR DEFAULT_MSG QHELPGENERATOR_EXECUTABLE) + + set(abs_top_builddir ${CMAKE_BINARY_DIR}) + set(abs_top_srcdir ${CMAKE_SOURCE_DIR}) + set(GENERATE_HTML YES) + set(GENERATE_QHP YES) + set(GENERATE_RTF NO) + set(GENERATE_CHM NO) + set(GENERATE_CHI NO) + set(GENERATE_LATEX NO) + set(GENERATE_MAN NO) + set(GENERATE_XML NO) + set(GENERATE_QHP ${QHELPGENERATOR_FOUND}) + configure_file(doxygen.cfg.in ${CMAKE_BINARY_DIR}/doxygen.cfg) + add_custom_target(doxygen-doc ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doxygen.cfg) +endif(DOXYGEN_FOUND) diff --git a/cmake/modules/FindLibPython.py b/cmake/modules/FindLibPython.py new file mode 100644 index 00000000..0cbd53c5 --- /dev/null +++ b/cmake/modules/FindLibPython.py @@ -0,0 +1,12 @@ +# Copyright (c) 2007, Simon Edwards <simon@simonzone.com> +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +import sys +import distutils.sysconfig + +print("exec_prefix:%s" % sys.exec_prefix) +print("short_version:%s" % sys.version[:3]) +print("long_version:%s" % sys.version.split()[0]) +print("py_inc_dir:%s" % distutils.sysconfig.get_python_inc()) +print("site_packages_dir:%s" % distutils.sysconfig.get_python_lib(plat_specific=1)) diff --git a/cmake/modules/FindPythonLibrary.cmake b/cmake/modules/FindPythonLibrary.cmake new file mode 100644 index 00000000..cbfe3185 --- /dev/null +++ b/cmake/modules/FindPythonLibrary.cmake @@ -0,0 +1,84 @@ +# FindPythonLibrary.cmake +# ~~~~~~~~~~~~~~~~~~~~~~~ +# Find the Python interpreter and related Python directories. +# +# This file defines the following variables: +# +# PYTHON_EXECUTABLE - The path and filename of the Python interpreter. +# +# PYTHON_SHORT_VERSION - The version of the Python interpreter found, +# excluding the patch version number. (e.g. 2.5 and not 2.5.1)) +# +# PYTHON_LONG_VERSION - The version of the Python interpreter found as a human +# readable string. +# +# PYTHON_SITE_PACKAGES_DIR - Location of the Python site-packages directory. +# +# PYTHON_INCLUDE_PATH - Directory holding the python.h include file. +# +# PYTHON_LIBRARY, PYTHON_LIBRARIES- Location of the Python library. + +# Copyright (c) 2007, Simon Edwards <simon@simonzone.com> +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +INCLUDE(CMakeFindFrameworks) + +if(EXISTS PYTHON_LIBRARY) + # Already in cache, be silent + set(PYTHONLIBRARY_FOUND TRUE) +else(EXISTS PYTHON_LIBRARY) + FIND_PACKAGE(PythonInterp) + + if(PYTHONINTERP_FOUND) + FIND_FILE(_find_lib_python_py FindLibPython.py PATHS ${CMAKE_MODULE_PATH}) + + EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_lib_python_py} OUTPUT_VARIABLE python_config) + if(python_config) + STRING(REGEX REPLACE ".*exec_prefix:([^\n]+).*$" "\\1" PYTHON_PREFIX ${python_config}) + STRING(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" PYTHON_SHORT_VERSION ${python_config}) + STRING(REGEX REPLACE ".*\nlong_version:([^\n]+).*$" "\\1" PYTHON_LONG_VERSION ${python_config}) + STRING(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" PYTHON_INCLUDE_PATH ${python_config}) + STRING(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" PYTHON_SITE_PACKAGES_DIR ${python_config}) + STRING(REGEX REPLACE "([0-9]+).([0-9]+)" "\\1\\2" PYTHON_SHORT_VERSION_NO_DOT ${PYTHON_SHORT_VERSION}) + set(PYTHON_LIBRARY_NAMES python${PYTHON_SHORT_VERSION} python${PYTHON_SHORT_VERSION_NO_DOT}) + if(WIN32) + STRING(REPLACE "\\" "/" PYTHON_SITE_PACKAGES_DIR ${PYTHON_SITE_PACKAGES_DIR}) + endif(WIN32) + FIND_LIBRARY(PYTHON_LIBRARY NAMES ${PYTHON_LIBRARY_NAMES} PATHS ${PYTHON_PREFIX}/lib ${PYTHON_PREFIX}/libs NO_DEFAULT_PATH) + set(PYTHONLIBRARY_FOUND TRUE) + endif(python_config) + + # adapted from cmake's builtin FindPythonLibs + if(APPLE) + CMAKE_FIND_FRAMEWORKS(Python) + set(PYTHON_FRAMEWORK_INCLUDES) + if(Python_FRAMEWORKS) + # If a framework has been selected for the include path, + # make sure "-framework" is used to link it. + if("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework") + set(PYTHON_LIBRARY "") + set(PYTHON_DEBUG_LIBRARY "") + endif("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework") + if(NOT PYTHON_LIBRARY) + set (PYTHON_LIBRARY "-framework Python" CACHE FILEPATH "Python Framework" FORCE) + endif(NOT PYTHON_LIBRARY) + set(PYTHONLIBRARY_FOUND TRUE) + endif(Python_FRAMEWORKS) + endif(APPLE) + endif(PYTHONINTERP_FOUND) + + if(PYTHONLIBRARY_FOUND) + set(PYTHON_LIBRARIES ${PYTHON_LIBRARY}) + if(NOT PYTHONLIBRARY_FIND_QUIETLY) + message(STATUS "Found Python executable: ${PYTHON_EXECUTABLE}") + message(STATUS "Found Python version: ${PYTHON_LONG_VERSION}") + message(STATUS "Found Python library: ${PYTHON_LIBRARY}") + endif(NOT PYTHONLIBRARY_FIND_QUIETLY) + else(PYTHONLIBRARY_FOUND) + if(PYTHONLIBRARY_FIND_REQUIRED) + message(FATAL_ERROR "Could not find Python") + endif(PYTHONLIBRARY_FIND_REQUIRED) + endif(PYTHONLIBRARY_FOUND) + +endif (EXISTS PYTHON_LIBRARY) diff --git a/cmake/modules/TelepathyDefaults.cmake b/cmake/modules/TelepathyDefaults.cmake new file mode 100644 index 00000000..d2055558 --- /dev/null +++ b/cmake/modules/TelepathyDefaults.cmake @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 2.6) + +if(POLICY CMP0011) + cmake_policy(SET CMP0011 OLD) +endif(POLICY CMP0011) + +# Enable testing using CTest +enable_testing() + +# Always include srcdir and builddir in include path +# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} in about every subdir +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# put the include dirs which are in the source or build tree +# before all other include dirs, so the headers in the sources +# are prefered over the already installed ones +set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) + +# Use colored output +set(CMAKE_COLOR_MAKEFILE ON) + +# Set compiler flags +if(CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DQT_NO_DEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DQT_NO_DEBUG") + set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline -DENABLE_DEBUG") + set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline -DENABLE_DEBUG") + set(CMAKE_CXX_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs -DENABLE_DEBUG") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DQT_NO_DEBUG") + set(CMAKE_C_FLAGS_RELEASE "-O2 -DQT_NO_DEBUG") + set(CMAKE_C_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline -DENABLE_DEBUG") + set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline -DENABLE_DEBUG") + set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs -DENABLE_DEBUG") + + if(CMAKE_SYSTEM_NAME MATCHES Linux) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wdeclaration-after-statement -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wsign-compare -Wnested-externs -Wpointer-arith -Wformat-security -Winit-self") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wsign-compare -Wpointer-arith -Wformat-security -Winit-self -Wnon-virtual-dtor") + add_definitions(-D_BSD_SOURCE) + endif(CMAKE_SYSTEM_NAME MATCHES Linux) + + # gcc under Windows + if(MINGW) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols -Wl,--disable-auto-import") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--export-all-symbols -Wl,--disable-auto-import") + + # we always link against the release version of QT with mingw + # (even for debug builds). So we need to define QT_NO_DEBUG + # or else QPluginLoader rejects plugins because it thinks + # they're built against the wrong QT. + add_definitions(-DQT_NO_DEBUG) + endif(MINGW) +endif(CMAKE_COMPILER_IS_GNUCXX) + +if(MSVC) + set(ESCAPE_CHAR ^) +endif(MSVC) + +set(LIB_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" ) +set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})" FORCE) +set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The subdirectory to the header prefix" FORCE) + +include(TelepathyDist) diff --git a/cmake/modules/TelepathyDist.cmake b/cmake/modules/TelepathyDist.cmake new file mode 100644 index 00000000..3e4ce428 --- /dev/null +++ b/cmake/modules/TelepathyDist.cmake @@ -0,0 +1,10 @@ +# setup make dist +add_custom_target(clone git clone ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}-${PACKAGE_VERSION}) +add_custom_target(clean-git rm -rf ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}-${PACKAGE_VERSION}/.git*) +add_custom_target(dist tar -czf ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz ${PACKAGE_NAME}-${PACKAGE_VERSION}) +add_dependencies(clean-git clone) +add_dependencies(dist clean-git) + +# setup make distcheck +FIND_FILE(_distcheck_py distcheck.py PATHS ${CMAKE_MODULE_PATH}) +add_custom_target(distcheck ${PYTHON_EXECUTABLE} ${_distcheck_py} ${PACKAGE_NAME} ${PACKAGE_VERSION} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) diff --git a/cmake/modules/distcheck.py b/cmake/modules/distcheck.py new file mode 100644 index 00000000..1edc89c7 --- /dev/null +++ b/cmake/modules/distcheck.py @@ -0,0 +1,83 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (C) 2009 Collabora Limited <http://www.collabora.co.uk> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import os +import re +import shutil +import sys +import tarfile +import subprocess + +project = sys.argv[1] +version = sys.argv[2] +srcDir = sys.argv[3] +buildDir = sys.argv[4] + +tarName = project + '-' + version +distfilesDir = buildDir + "/distfiles" + +try: + os.mkdir( distfilesDir ) +except: + print "Delete " + distfilesDir + " before running distcheck again." + exit( 1 ) + +cloneSrcDir = distfilesDir + "/" + tarName +cloneBuildDir = cloneSrcDir + "_build" + +os.chdir( buildDir ) +subprocess.call( ["git", "clone", srcDir, cloneSrcDir ] ) +os.chdir( cloneSrcDir ) +hashOfTar = subprocess.Popen(["git", "log", "--pretty=oneline", "-n1"], stdout=subprocess.PIPE).communicate()[0].strip() +os.mkdir( cloneBuildDir ) +os.chdir( cloneBuildDir ) + +originalCache = open( buildDir + "/CMakeCache.txt" ) +newCache = open( cloneBuildDir + "/CMakeCache.txt", 'w' ) +reSrcDir = re.compile( srcDir + "$" ) +reBuildDir = re.compile( buildDir + "$" ) +for line in originalCache.xreadlines(): + line = reSrcDir.sub( cloneSrcDir, line ) + newCache.write( reBuildDir.sub( cloneBuildDir, line ) ) +newCache.close() + +if subprocess.call( ["cmake", cloneSrcDir] ) == 0: + if subprocess.call( ["make"] ) == 0: + docStatus = ( subprocess.call( ["make", "doxygen-doc"] ) == 0 ) + shutil.move( cloneBuildDir + "/doc", cloneSrcDir ) + + testStatus = ( subprocess.call( ["make", "test"] ) == 0 ) + + subprocess.call( ["rm", "-rf", cloneSrcDir + "/.git*" ] ) + tarPath = buildDir + "/" + tarName + ".tar.gz" + tar = tarfile.open( tarPath, "w|gz" ) + tar.add( cloneSrcDir ) + tar.close() + print "Tarball " + tarPath + " built." + print "Remember to tag " + hashOfTar + if not docStatus: + print "WARNING: Problem building documentation." + if not testStatus: + print "WARNING: One or more tests failed." + else: + print "Building failed" + exit( 1 ) +else: + print "CMake failed" + exit( 1 ) |