Skip to content

Commit

Permalink
CMake: Generate an installer for the framework on OSX
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
Paul Cercueil committed Jun 9, 2015
1 parent 3fb11de commit d46fc8f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
36 changes: 36 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
20 changes: 20 additions & 0 deletions Distribution.xml.cmakein
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<installer-gui-script minSpecVersion="1" >
<title>Libiio</title>
<options customize="never" rootVolumeOnly="true" />
<allowed-os-versions>
<os-version min="10.6.6" />
</allowed-os-versions>
<license file="@CMAKE_CURRENT_SOURCE_DIR@/COPYING.txt" mime-type="text/plain" />
<product id="libiio" version="@VERSION@" />
<choices-outline>
<line choice="default" >
<line choice="libiio" />
</line>
</choices-outline>
<choice id="default" />
<choice id="libiio" visible="false" >
<pkg-ref id="libiio" />
</choice>
<pkg-ref id="libiio" version="@VERSION@" onConclusion="none" >@LIBIIO_TEMP_PKG@</pkg-ref>
</installer-gui-script>

0 comments on commit d46fc8f

Please sign in to comment.