Skip to content
Browse files

Complete and cleanup CMake build system.

  • Loading branch information...
1 parent 623314b commit c99881e673b58efba240d6b9440768eace28b027 @JonathanBeck committed Mar 27, 2009
Showing with 63 additions and 21 deletions.
  1. +17 −14 CMakeLists.txt
  2. +15 −0 cmake/libplistPackaging.cmake
  3. +21 −0 cmake/modules/cmake_uninstall.cmake.in
  4. +7 −7 libplist.pc.in
  5. +1 −0 plutil/CMakeLists.txt
  6. +2 −0 src/CMakeLists.txt
View
31 CMakeLists.txt
@@ -1,5 +1,12 @@
PROJECT( libplist )
+SET( LIBPLIST_VERSION_MAJOR "0" )
+SET( LIBPLIST_VERSION_MINOR "8" )
+SET( LIBPLIST_SOVERSION "0" )
+SET( LIBPLIST_VERSION "${LIBPLIST_VERSION_MAJOR}.${LIBPLIST_VERSION_MINOR}" )
+SET( LIBPLIST_LIBVERSION "${LIBPLIST_SOVERSION}.${LIBPLIST_VERSION}" )
+SET( PLUTIL_VERSION ${LIBPLIST_VERSION} )
+
SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/modules )
cmake_minimum_required(VERSION 2.6)
@@ -22,19 +29,15 @@ 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" )
-
+# add uninstall target
+CONFIGURE_FILE( "${CMAKE_SOURCE_DIR}/cmake/modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
+ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
-SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library to parse and generate Apple's binary and XML PList format")
-SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
-SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LESSER")
-SET(CPACK_PACKAGE_VERSION_MAJOR "0")
-SET(CPACK_PACKAGE_VERSION_MINOR "1")
-SET(CPACK_PACKAGE_VERSION_PATCH "0")
-SET(CPACK_COMPONENT_LIB_DISPLAY_NAME "PList library")
-SET(CPACK_COMPONENT_DEV_DISPLAY_NAME "PList development files")
-SET(CPACK_COMPONENT_PLUTIL_DISPLAY_NAME "PList conversion tool")
-set(CPACK_COMPONENT_DEV_DEPENDS lib)
-set(CPACK_COMPONENT_PLUTIL_DEPENDS lib)
-INCLUDE(CPack)
+########## PkgConfig ############################
+CONFIGURE_FILE( "libplist.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libplist.pc" )
+########## INSTALL ##############################
+INSTALL( FILES "${CMAKE_CURRENT_BINARY_DIR}/libplist.pc" DESTINATION ${LIBDATA_INSTALL_DIR}/pkgconfig/ )
+########## CPack ################################
+INCLUDE( libplistPackaging )
+LIBPLIST_PACKAGE(LIBPLIST_VERSION_MAJOR LIBPLIST_VERSION_MINOR)
View
15 cmake/libplistPackaging.cmake
@@ -0,0 +1,15 @@
+MACRO( LIBPLIST_PACKAGE _major _minor)
+
+ SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library to parse and generate Apple's binary and XML PList format")
+ SET(CPACK_PACKAGE_VERSION_MAJOR ${_major})
+ SET(CPACK_PACKAGE_VERSION_MINOR ${_minor})
+ SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
+ SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LESSER")
+ SET(CPACK_COMPONENT_LIB_DISPLAY_NAME "PList library")
+ SET(CPACK_COMPONENT_DEV_DISPLAY_NAME "PList development files")
+ SET(CPACK_COMPONENT_PLUTIL_DISPLAY_NAME "PList conversion tool")
+ set(CPACK_COMPONENT_DEV_DEPENDS lib)
+ set(CPACK_COMPONENT_PLUTIL_DEPENDS lib)
+ INCLUDE( CPack )
+
+ENDMACRO( LIBPLIST_PACKAGE )
View
21 cmake/modules/cmake_uninstall.cmake.in
@@ -0,0 +1,21 @@
+IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
+ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+STRING(REGEX REPLACE "\n" ";" files "${files}")
+FOREACH(file ${files})
+ MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
+ IF(EXISTS "$ENV{DESTDIR}${file}")
+ EXEC_PROGRAM(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ IF(NOT "${rm_retval}" STREQUAL 0)
+ MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
+ ENDIF(NOT "${rm_retval}" STREQUAL 0)
+ ELSE(EXISTS "$ENV{DESTDIR}${file}")
+ MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
+ ENDIF(EXISTS "$ENV{DESTDIR}${file}")
+ENDFOREACH(file)
View
14 libplist.pc.in
@@ -1,12 +1,12 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
+prefix=${CMAKE_INSTALL_PREFIX}
+exec_prefix=${CMAKE_INSTALL_PREFIX}
+libdir=${CMAKE_INSTALL_PREFIX}/lib
+includedir=${CMAKE_INSTALL_PREFIX}/include
Name: libplist
Description: A library to handle Apple Property Lists whereas they are binary or XML
-Version: @VERSION@
+Version: ${LIBPLIST_VERSION}
Requires: libxml-2.0 >= 2.6.30 glib-2.0 >= 2.14.1
-Libs: -L${libdir} -lplist
-Cflags: -I${includedir}
+Libs: -L${CMAKE_INSTALL_PREFIX}/lib -lplist
+Cflags: -I${CMAKE_INSTALL_PREFIX}/include
View
1 plutil/CMakeLists.txt
@@ -4,5 +4,6 @@ SET(plutil_SRC
ADD_EXECUTABLE(plutil ${plutil_SRC})
TARGET_LINK_LIBRARIES(plutil plist)
+SET_TARGET_PROPERTIES( plutil PROPERTIES VERSION ${PLUTIL_VERSION} )
INSTALL( TARGETS plutil RUNTIME DESTINATION bin COMPONENT plutil )
View
2 src/CMakeLists.txt
@@ -9,6 +9,8 @@ SET(libplist_SRC
ADD_LIBRARY( plist SHARED ${libplist_SRC} )
TARGET_LINK_LIBRARIES( plist ${LIBXML2_LIBRARIES} ${GLIB2_LIBRARIES} )
+SET_TARGET_PROPERTIES( plist PROPERTIES VERSION ${LIBPLIST_LIBVERSION} )
+SET_TARGET_PROPERTIES( plist PROPERTIES SOVERSION ${LIBPLIST_SOVERSION} )
INSTALL(TARGETS plist
RUNTIME DESTINATION bin COMPONENT lib

0 comments on commit c99881e

Please sign in to comment.
Something went wrong with that request. Please try again.