From d46fc8f6799f47baf320aa60357ae674c098eb04 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Tue, 9 Jun 2015 16:37:16 +0200 Subject: [PATCH] CMake: Generate an installer for the framework on OSX Signed-off-by: Paul Cercueil --- CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++++ Distribution.xml.cmakein | 20 ++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 Distribution.xml.cmakein diff --git a/CMakeLists.txt b/CMakeLists.txt index d446fb2d0..c75055990 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,6 +195,42 @@ else() message(STATUS "Doxygen not found, API documentation won't be generated") endif() +# Create an installer if compiling for OSX +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(LIBIIO_PKG ${CMAKE_CURRENT_BINARY_DIR}/libiio-${VERSION}.pkg) + set(LIBIIO_TEMP_PKG ${CMAKE_CURRENT_BINARY_DIR}/libiio-${VERSION}-temp.pkg) + set(LIBIIO_DISTRIBUTION_XML ${CMAKE_CURRENT_BINARY_DIR}/Distribution.xml) + configure_file(Distribution.xml.cmakein ${LIBIIO_DISTRIBUTION_XML} @ONLY) + + find_program(PKGBUILD_EXECUTABLE + NAMES pkgbuild + DOC "OSX Package builder (pkgbuild)") + mark_as_advanced(PKGBUILD_EXECUTABLE) + + find_program(PRODUCTBUILD_EXECUTABLE + NAMES productbuild + DOC "OSX Package builder (productbuild)") + mark_as_advanced(PRODUCTBUILD_EXECUTABLE) + + add_custom_command(OUTPUT ${LIBIIO_TEMP_PKG} COMMAND ${PKGBUILD_EXECUTABLE} + --root ${CMAKE_CURRENT_BINARY_DIR}/Debug + --identifier libiio --version ${VERSION} + --install-location /System/Library/Frameworks ${LIBIIO_TEMP_PKG} + DEPENDS iio + ) + + add_custom_command(OUTPUT ${LIBIIO_PKG} COMMAND ${PRODUCTBUILD_EXECUTABLE} + --distribution ${LIBIIO_DISTRIBUTION_XML} ${LIBIIO_PKG} + DEPENDS ${LIBIIO_DISTRIBUTION_XML} ${LIBIIO_TEMP_PKG} + ) + + if (PKGBUILD_EXECUTABLE AND PRODUCTBUILD_EXECUTABLE) + add_custom_target(libiio-pkg ALL DEPENDS ${LIBIIO_PKG}) + else() + message(WARNING "Missing pkgbuild or productbuild: OSX installer won't be created.") + endif() +endif() + if(WITH_IIOD) add_subdirectory(iiod) endif() diff --git a/Distribution.xml.cmakein b/Distribution.xml.cmakein new file mode 100644 index 000000000..9997bfafd --- /dev/null +++ b/Distribution.xml.cmakein @@ -0,0 +1,20 @@ + + + Libiio + + + + + + + + + + + + + + + + @LIBIIO_TEMP_PKG@ +