additional variable (BUNDLE) to make a standalone Mac application
authorkoda
Thu, 02 Jul 2009 14:59:27 +0000
changeset 2219 07f5345ecae7
parent 2218 59a9bebc4988
child 2220 110266ba2ef7
additional variable (BUNDLE) to make a standalone Mac application
CMakeLists.txt
QTfrontend/CMakeLists.txt
hedgewars/CMakeLists.txt
tools/CMakeLists.txt
tools/CreateMacBundle.cmake.in
--- a/CMakeLists.txt	Thu Jul 02 00:58:46 2009 +0000
+++ b/CMakeLists.txt	Thu Jul 02 14:59:27 2009 +0000
@@ -12,19 +12,20 @@
 set(CPACK_PACKAGE_VERSION_MINOR "9")
 set(CPACK_PACKAGE_VERSION_PATCH "12-dev")
 
-set(universal_build "0")
+set(universal_build false)
 
 if(APPLE)
-set(CMAKE_INSTALL_PREFIX "Hedgewars.app/Contents/MacOS/") 
+set(bundle_name Hedgewars.app)
+set(CMAKE_INSTALL_PREFIX ${bundle_name}/Contents/MacOS/) 
 set(DATA_INSTALL_DIR "../Resources/")
-set (target_dir ".")
+set(target_dir ".")
 
 if(CMAKE_OSX_ARCHITECTURES MATCHES "i386;ppc7400" OR CMAKE_OSX_ARCHITECTURES MATCHES "ppc7400;i386" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386;ppc" OR CMAKE_OSX_ARCHITECTURES MATCHES "ppc;i386")
-	set(universal_build "1")
+	set(universal_build true)
 	message("-- Building a Universal Application")
 endif()
 else(APPLE)
-set (target_dir "bin")
+set(target_dir "bin")
 endif(APPLE)
 
 if(DEFINED DATA_INSTALL_DIR)
@@ -49,7 +50,7 @@
 add_subdirectory(QTfrontend)
 add_subdirectory(hedgewars)
 add_subdirectory(share)
-
+add_subdirectory(tools)
 
 # CPack vars
 
--- a/QTfrontend/CMakeLists.txt	Thu Jul 02 00:58:46 2009 +0000
+++ b/QTfrontend/CMakeLists.txt	Thu Jul 02 14:59:27 2009 +0000
@@ -43,8 +43,7 @@
 	endif(DEFINED DATA_INSTALL_DIR)
 endif(WIN32 AND NOT UNIX)
 
-configure_file(${hedgewars_SOURCE_DIR}/QTfrontend/hwconsts.cpp.in 
-	${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hwconsts.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp)
 
 set(hwfr_src
 	game.cpp
--- a/hedgewars/CMakeLists.txt	Thu Jul 02 00:58:46 2009 +0000
+++ b/hedgewars/CMakeLists.txt	Thu Jul 02 14:59:27 2009 +0000
@@ -1,5 +1,4 @@
-configure_file(${hedgewars_SOURCE_DIR}/hedgewars/proto.inc.in 
-	${CMAKE_CURRENT_BINARY_DIR}/proto.inc)
+configure_file(${hedgewars_SOURCE_DIR}/hedgewars/proto.inc.in ${CMAKE_CURRENT_BINARY_DIR}/proto.inc)
 
 set(fpc_tryexe fpc)
 set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.dpr)
@@ -65,7 +64,6 @@
 endif (${testnoexecstack})
 
 IF(APPLE)
-
 	FIND_PACKAGE(SDL)
 
 	if (SDL_FOUND)
@@ -82,7 +80,6 @@
 	else (SDL_FOUND)
 		message(FATAL_ERROR "No SDL framework found!")
 	endif (SDL_FOUND)
-
 ENDIF(APPLE)
 
 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
@@ -112,7 +109,7 @@
 	set(pascal_compiler_flags "-dMSVC" ${pascal_compiler_flags})
 endif(MSVC)
 
-IF(NOT APPLE OR NOT universal_build MATCHES "1")
+IF(NOT APPLE OR NOT universal_build)
 #here is the standard command for any system
 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
 		COMMAND "${pascal_compiler}"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/CMakeLists.txt	Thu Jul 02 14:59:27 2009 +0000
@@ -0,0 +1,23 @@
+if (APPLE AND BUNDLE)
+
+find_program(macdeployqt_EXE NAMES macdeployqt macdeployqt-mac)
+
+if(NOT macdeployqt_EXE)
+	message(FATAL_ERROR "The utility macdeployqt is required to create the bundle!")
+endif()
+
+#if(HAVE_NETSERVER)
+add_custom_target(bundle)
+#set(deps_list hedgewars "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" "${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}")
+#else(HAVE_NETSERVER)
+#add_custom_target(bundle )
+#set(deps_list hedgewars "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}")
+#endif(HAVE_NETSERVER)
+
+set_target_properties(bundle PROPERTIES POST_INSTALL_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake)
+
+set(frameworks_dir ${bundle_name}/Contents/Frameworks/)
+
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CreateMacBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake)
+
+endif()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/CreateMacBundle.cmake.in	Thu Jul 02 14:59:27 2009 +0000
@@ -0,0 +1,12 @@
+execute_process(COMMAND ${macdeployqt_EXE} ${CMAKE_BINARY_DIR}/${bundle_name} OUTPUT_QUIET)
+
+execute_process(COMMAND cp -pPR /Library/Frameworks/SDL.framework/	  ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL.framework)
+execute_process(COMMAND cp -pPR /Library/Frameworks/SDL_image.framework/  ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_image.framework)
+execute_process(COMMAND cp -pPR /Library/Frameworks/SDL_net.framework/    ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_net.framework)
+execute_process(COMMAND cp -pPR /Library/Frameworks/SDL_ttf.framework/    ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_ttf.framework)
+execute_process(COMMAND cp -pPR /Library/Frameworks/Ogg.framework/  	  ${CMAKE_BINARY_DIR}/${frameworks_dir}/Ogg.framework)
+execute_process(COMMAND cp -pPR /Library/Frameworks/Vorbis.framework/	  ${CMAKE_BINARY_DIR}/${frameworks_dir}/Vorbis.framework)
+
+if(${HAVE_NETSERVER})
+execute_process(COMMAND cp -pPR /Library/Frameworks/SDL_ttf.framework/ ${CMAKE_BINARY_DIR}/${frameworks_dir}/GMP.framework)
+endif()