diff --git a/.gitignore b/.gitignore index edc296abb..0e2ece8e9 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,5 @@ stderr.txt CMakeScripts/ *.xcodeproj/ .DS_Store +*.dmg +*.dylib diff --git a/CMakeLists.txt b/CMakeLists.txt index a22fce5e3..59f1d065e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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 @@ -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 @@ -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") @@ -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() diff --git a/build/macosx/C-Dogs SDL b/build/macosx/C-Dogs SDL new file mode 100644 index 000000000..c771d5fdb --- /dev/null +++ b/build/macosx/C-Dogs SDL @@ -0,0 +1,2 @@ +#!/bin/sh +(cd /Applications/cdogs-sdl/bin && exec /Applications/cdogs-sdl/bin/cdogs-sdl)