Skip to content

Commit

Permalink
WIP OSX package (#130)
Browse files Browse the repository at this point in the history
Can create .dmg, binaries do not build in correct location
  • Loading branch information
cxong committed Sep 8, 2013
1 parent 4b5a98b commit f7ae7c0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ stderr.txt
CMakeScripts/
*.xcodeproj/
.DS_Store
*.dmg
*.dylib
38 changes: 27 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ set(CDOGS_DATA_DIR "../")
set(CDOGS_CFG_DIR ".cdogs/")
SET(SOURCE_DIRECTORY ".")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ".")
IF(UNIX)
IF(UNIX AND NOT APPLE)
CONFIGURE_FILE(${SOURCE_DIRECTORY}/build/linux/cdogs-sdl.cmake ${SOURCE_DIRECTORY}/build/linux/cdogs-sdl)
ENDIF()
IF(WIN32)
Expand All @@ -115,16 +115,21 @@ set_target_properties(hqx PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src
)

set(INSTALL_PREFIX ".")
if(WIN32)
set(EXE_EXTENSION ".exe")
set(LIB_EXTENSION ".dll")
elseif(APPLE)
set(EXE_EXTENSION "")
set(LIB_EXTENSION ".dylib")
set(INSTALL_PREFIX "cdogs-sdl")
else()
set(EXE_EXTENSION "")
set(LIB_EXTENSION ".so")
endif()
install(
PROGRAMS src/cdogs-sdl${EXE_EXTENSION} src/cdogs-sdl-editor${EXE_EXTENSION} src/libhqx${LIB_EXTENSION}
DESTINATION bin)
DESTINATION ${INSTALL_PREFIX}/bin)

# Installation
INSTALL(DIRECTORY
Expand All @@ -134,8 +139,8 @@ INSTALL(DIRECTORY
${SOURCE_DIRECTORY}/graphics
${SOURCE_DIRECTORY}/music
${SOURCE_DIRECTORY}/sounds
DESTINATION .)
INSTALL(FILES ${SOURCE_DIRECTORY}/cdogs_icon.bmp ${SOURCE_DIRECTORY}/README.md DESTINATION .)
DESTINATION ${INSTALL_PREFIX})
INSTALL(FILES ${SOURCE_DIRECTORY}/cdogs_icon.bmp ${SOURCE_DIRECTORY}/README.md DESTINATION ${INSTALL_PREFIX})
IF(UNIX AND NOT APPLE)
INSTALL(
FILES ${SOURCE_DIRECTORY}/build/linux/cdogs-sdl
Expand All @@ -144,16 +149,21 @@ IF(UNIX AND NOT APPLE)
INSTALL(FILES
${SOURCE_DIRECTORY}/build/linux/cdogs-sdl.desktop
${SOURCE_DIRECTORY}/cdogs_icon.png
DESTINATION bin)
ENDIF()
IF(MSVC)
DESTINATION ${INSTALL_PREFIX}/bin)
elseif(MSVC)
# Package for Windows
FILE(GLOB DLLS "${SOURCE_DIRECTORY}/src/*.dll")
FOREACH(DLL ${DLLS})
INSTALL(FILES "${DLL}" DESTINATION ./bin)
INSTALL(FILES "${DLL}" DESTINATION ${INSTALL_PREFIX}/bin)
ENDFOREACH()
install(DIRECTORY ${SOURCE_DIRECTORY}/build/licenses DESTINATION .)
ENDIF()
install(DIRECTORY ${SOURCE_DIRECTORY}/build/licenses DESTINATION ${INSTALL_PREFIX})
elseif(APPLE)
set(CMAKE_INSTALL_PREFIX "/Applications/cdogs-sdl")
install(
FILES "${SOURCE_DIRECTORY}/build/macosx/C-Dogs SDL"
DESTINATION ${INSTALL_PREFIX}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif()

# Packaging
SET(CPACK_PACKAGE_NAME "C-Dogs SDL")
Expand All @@ -176,7 +186,13 @@ IF(WIN32)
SET(CPACK_NSIS_MUI_FINISHPAGE_RUN cdogs-sdl.exe)
SET(CPACK_NSIS_URL_INFO_ABOUT ${WEBSITE})
elseif(APPLE)
set(CPACK_GENERATOR DRAGNDROP)
set(CMAKE_INSTALL_PREFIX "/Applications/cdogs-sdl")
set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_FORMAT "UDBZ")
set(CPACK_DMG_VOLUME_NAME "C-Dogs SDL")
set(CPACK_SYSTEM_NAME "OSX")
set(CPACK_PACKAGE_ICON
"${CMAKE_CURRENT_BINARY_DIR}/build/macosx/cdogs-icon.icns")
ELSE()
SET(CPACK_GENERATOR TGZ)
ENDIF()
Expand Down
2 changes: 2 additions & 0 deletions build/macosx/C-Dogs SDL
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
(cd /Applications/cdogs-sdl/bin && exec /Applications/cdogs-sdl/bin/cdogs-sdl)

0 comments on commit f7ae7c0

Please sign in to comment.