From 4278fced578920c4b9c1ffe0862e94d90430b227 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Mon, 9 Feb 2009 20:44:11 +0100 Subject: Add a cmake build system. --- CMakeLists.txt | 22 ++++++++++++++++ cmake/modules/FindGLIB2.cmake | 51 ++++++++++++++++++++++++++++++++++++ cmake/modules/FindLibXml2.cmake | 57 +++++++++++++++++++++++++++++++++++++++++ include/CMakeLists.txt | 4 +++ plutil/CMakeLists.txt | 9 +++++++ src/CMakeLists.txt | 17 ++++++++++++ swig/CMakeLists.txt | 14 ++++++++++ 7 files changed, 174 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/modules/FindGLIB2.cmake create mode 100644 cmake/modules/FindLibXml2.cmake create mode 100644 include/CMakeLists.txt create mode 100644 plutil/CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 swig/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b6fe029 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +PROJECT( libplist ) + +SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/modules ) + +cmake_minimum_required(VERSION 2.6) + +FIND_PACKAGE( LibXml2 REQUIRED ) +FIND_PACKAGE( GLIB2 REQUIRED ) +FIND_PACKAGE( SWIG ) +FIND_PACKAGE( PythonLibs ) + +INCLUDE_DIRECTORIES( "${CMAKE_CURRENT_SOURCE_DIR}/include" ) + +ADD_SUBDIRECTORY( src ) +ADD_SUBDIRECTORY( plutil ) +ADD_SUBDIRECTORY( include ) + +IF ( SWIG_FOUND AND PYTHON_LIBRARY ) + ADD_SUBDIRECTORY( swig ) +ENDIF ( SWIG_FOUND AND PYTHON_LIBRARY ) + +CONFIGURE_FILE( "libplist.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libplist.pc" ) \ No newline at end of file diff --git a/cmake/modules/FindGLIB2.cmake b/cmake/modules/FindGLIB2.cmake new file mode 100644 index 0000000..226d551 --- /dev/null +++ b/cmake/modules/FindGLIB2.cmake @@ -0,0 +1,51 @@ +# - Try to find the GLIB2 libraries +# Once done this will define +# +# GLIB2_FOUND - system has glib2 +# GLIB2_INCLUDE_DIR - the glib2 include directory +# GLIB2_LIBRARIES - glib2 library + +# Copyright (c) 2008 Laurent Montel, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) + # Already in cache, be silent + set(GLIB2_FIND_QUIETLY TRUE) +endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) + +if (NOT WIN32) + FIND_PACKAGE(PkgConfig) + PKG_CHECK_MODULES(PC_GLIB2 glib-2.0) + SET(GLIB2_DEFINITIONS ${PC_GLIB2_CFLAGS_OTHER}) +endif(NOT WIN32) + +find_path(GLIB2_MAIN_INCLUDE_DIR glib.h + PATH_SUFFIXES glib-2.0 + PATHS ${_LibGLIB2IncDir} ) + +# search the glibconfig.h include dir under the same root where the library is found +find_library(GLIB2_LIBRARIES + NAMES glib-2.0 + PATHS ${_LibGLIB2LinkDir} ) + +get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH) + +find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h + PATH_SUFFIXES glib-2.0/include + PATHS ${_LibGLIB2IncDir} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH}) + +set(GLIB2_INCLUDE_DIR "${GLIB2_MAIN_INCLUDE_DIR}") + +# not sure if this include dir is optional or required +# for now it is optional +if(GLIB2_INTERNAL_INCLUDE_DIR) + set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} "${GLIB2_INTERNAL_INCLUDE_DIR}") +endif(GLIB2_INTERNAL_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR) + +mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindLibXml2.cmake b/cmake/modules/FindLibXml2.cmake new file mode 100644 index 0000000..8d3c77e --- /dev/null +++ b/cmake/modules/FindLibXml2.cmake @@ -0,0 +1,57 @@ +# - Try to find LibXml2 +# Once done this will define +# +# LIBXML2_FOUND - System has LibXml2 +# LIBXML2_INCLUDE_DIR - The LibXml2 include directory +# 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 + +# Copyright (c) 2006, Alexander Neundorf, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +IF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES) + # in cache already + SET(LibXml2_FIND_QUIETLY TRUE) +ENDIF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES) + +IF (NOT WIN32) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + FIND_PACKAGE(PkgConfig) + PKG_CHECK_MODULES(PC_LIBXML libxml-2.0) + SET(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER}) +ENDIF (NOT WIN32) + +FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xpath.h + HINTS + ${PC_LIBXML_INCLUDEDIR} + ${PC_LIBXML_INCLUDE_DIRS} + PATH_SUFFIXES libxml2 + ) + +FIND_LIBRARY(LIBXML2_LIBRARIES NAMES xml2 libxml2 + HINTS + ${PC_LIBXML_LIBDIR} + ${PC_LIBXML_LIBRARY_DIRS} + ) + +FIND_PROGRAM(LIBXML2_XMLLINT_EXECUTABLE xmllint) +# for backwards compat. with KDE 4.0.x: +SET(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}") + +IF( NOT LIBXML2_XMLLINT_EXECUTABLE ) + MESSAGE(STATUS "xmllint program not found. Install it if you want validate generated doc file.") +ENDIF(NOT LIBXML2_XMLLINT_EXECUTABLE ) + + +INCLUDE(FindPackageHandleStandardArgs) + +# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if +# all listed variables are TRUE +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) + +MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..8dc7e32 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,4 @@ + + +INSTALL( FILES ${CMAKE_CURRENT_SOURCE_DIR}/plist/plist.h + DESTINATION include/plist ) diff --git a/plutil/CMakeLists.txt b/plutil/CMakeLists.txt new file mode 100644 index 0000000..c6dc3f3 --- /dev/null +++ b/plutil/CMakeLists.txt @@ -0,0 +1,9 @@ + +SET(plutil_SRC + plutil.c) + +ADD_EXECUTABLE(plutil ${plutil_SRC}) +TARGET_LINK_LIBRARIES(plutil plist) + +INSTALL( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/plutil + DESTINATION bin ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..d5e6205 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,17 @@ + +INCLUDE_DIRECTORIES( ${LIBXML2_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR} ) + + +SET(libplist_SRC + plist.c + bplist.c + xplist.c ) + +ADD_LIBRARY( plist SHARED ${libplist_SRC} ) +TARGET_LINK_LIBRARIES( plist ${LIBXML2_LIBRARIES} ${GLIB2_LIBRARIES} ) + +INSTALL(TARGETS plist + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt new file mode 100644 index 0000000..28d7aed --- /dev/null +++ b/swig/CMakeLists.txt @@ -0,0 +1,14 @@ +INCLUDE( ${SWIG_USE_FILE} ) + +SET(CMAKE_SWIG_FLAGS -Werror -Wall -modern) + +INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_PATH} ) + +SWIG_ADD_MODULE( PList python plist.i ) +SWIG_LINK_LIBRARIES( PList plist ${PYTHON_LIBRARIES} ) + +INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/_PList${CMAKE_SHARED_MODULE_SUFFIX} + DESTINATION ${LIB_INSTALL_DIR}/python${PYTHON_VERSION}/site-packages/ ) +INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/__init__.py + DESTINATION ${LIB_INSTALL_DIR}/python${PYTHON_VERSION}/site-packages/ ) + -- cgit v1.1-32-gdbae