CMake hack to build Subsurface-mobile on Mac

With this running

	make && make install

should give you a Subsurface-mobile.app that you can execute (either with
double click or using "open Subsurface-mobile.app" from the command line).

This contains a couple of hacks but I didn't try too hard to make this clean
since Tomaz is redoing the CMake build system, anyway and I'll need to make
sure this still works once he's done.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-11-30 15:06:18 -08:00
parent 26fbcb0b74
commit 05bf480e2e

View file

@ -299,16 +299,24 @@ if(ANDROID)
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -llog)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(SUBSURFACE_TARGET Subsurface)
if(SUBSURFACE_MOBILE)
set(SUBSURFACE_TARGET Subsurface-mobile)
set(MACOSX_BUNDLE_INFO_STRING "Subsurface-mobile")
set(MACOSX_BUNDLE_ICON_FILE Subsurface.icns)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.subsurface-divelog")
set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface-mobile")
else()
set(SUBSURFACE_TARGET Subsurface)
set(MACOSX_BUNDLE_INFO_STRING "Subsurface")
set(MACOSX_BUNDLE_ICON_FILE Subsurface.icns)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.subsurface-divelog")
set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface")
endif()
find_library(APP_SERVICES_LIBRARY ApplicationServices)
find_library(HID_LIB HidApi)
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${HID_LIB})
set(EXTRA_LIBS ${APP_SERVICES_LIBRARY})
set(ICON_FILE ${CMAKE_SOURCE_DIR}/packaging/macosx/Subsurface.icns)
set(MACOSX_BUNDLE_INFO_STRING "Subsurface")
set(MACOSX_BUNDLE_ICON_FILE Subsurface.icns)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.subsurface-divelog")
set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface")
set(MACOSX_BUNDLE_BUNDLE_VERSION "${SSRF_VERSION_STRING}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${SSRF_VERSION_STRING}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${SSRF_VERSION_STRING}")
@ -353,7 +361,11 @@ endif()
# create the executables
if(SUBSURFACE_MOBILE)
set(SUBSURFACE_TARGET subsurface-mobile)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(SUBSURFACE_TARGET Subsurface-mobile)
else()
set(SUBSURFACE_TARGET subsurface-mobile)
endif()
set(MOBILE_SRC
qt-mobile/qmlmanager.cpp
qt-mobile/qmlprofile.cpp
@ -365,7 +377,7 @@ if(SUBSURFACE_MOBILE)
if(ANDROID)
add_library(subsurface-mobile SHARED ${MOBILE_SRC} ${SUBSURFACE_PKG} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES})
else()
add_executable(subsurface-mobile ${SUBSURFACE_PKG} ${MOBILE_SRC} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES})
add_executable(${SUBSURFACE_TARGET} ${SUBSURFACE_PKG} ${MOBILE_SRC} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES})
endif()
target_link_libraries(
${SUBSURFACE_TARGET}
@ -512,8 +524,14 @@ endforeach()
# now for each platform the install instructions
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(RESOURCEDIR ${CMAKE_BINARY_DIR}/Subsurface.app/Contents/Resources)
set(PLUGINDIR ${CMAKE_BINARY_DIR}/Subsurface.app/Contents/PlugIns)
if(SUBSURFACE_MOBILE)
set(APP_BUNDLE_DIR Subsurface-mobile.app)
set(MACDEPLOY_ARGS "-qmldir=${APP_BUNDLE_DIR}/Contents/Frameworks/qml")
else()
set(APP_BUNDLE_DIR Subsurface.app)
endif()
set(RESOURCEDIR ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Resources)
set(PLUGINDIR ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/PlugIns)
install(DIRECTORY marbledata/maps DESTINATION ${RESOURCEDIR}/data)
install(DIRECTORY marbledata/bitmaps DESTINATION ${RESOURCEDIR}/data)
install(DIRECTORY Documentation/images DESTINATION ${RESOURCEDIR}/share/Documentation)
@ -527,7 +545,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
install(DIRECTORY ${Grantlee5_DIR}/../../grantlee DESTINATION ${PLUGINDIR})
# this is a hack - but I don't know how else to find the macdeployqt program if it's not in the PATH
string(REPLACE moc macdeployqt MACDEPLOYQT ${QT_MOC_EXECUTABLE})
install(CODE "execute_process(COMMAND ${MACDEPLOYQT} Subsurface.app)")
install(CODE "execute_process(COMMAND ${MACDEPLOYQT} ${APP_BUNDLE_DIR} ${MACDEPLOY_ARGS})")
# and another hack to get the QML Components in the right place
install(CODE "execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/qml)")
install(CODE "execute_process(COMMAND cp -a ${_qt5Core_install_prefix}/qml/QtQuick ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/qml)")
install(CODE "message(STATUS \"two ERRORS here about libmysqlclient and libpq not found are harmless\")")
endif()