Browse Source

Mac bundle always has setup script

Thomas Buck 10 years ago
parent
commit
69e8a7172c
2 changed files with 39 additions and 30 deletions
  1. 0
    30
      CMakeLists.txt
  2. 39
    0
      src/CMakeLists.txt

+ 0
- 30
CMakeLists.txt View File

25
 
25
 
26
 #################################################################
26
 #################################################################
27
 
27
 
28
-if (APPLE)
29
-    # Preparing the bundle on install
30
-    # http://www.cmake.org/Wiki/BundleUtilitiesExample
31
-    set (plugin_dest_dir OpenRaider.app/Contents/MacOS)
32
-    set (APPS "${PROJECT_BINARY_DIR}/src/OpenRaider.app")
33
-    install (CODE "
34
-        file(GLOB_RECURSE PLUGINS
35
-            \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
36
-        include(BundleUtilities)
37
-        fixup_bundle(\"${APPS}\" \"\${PLUGINS}\" \"\")
38
-        " COMPONENT Runtime
39
-    )
40
-
41
-    # Copy setup script
42
-    install (PROGRAMS ${PROJECT_SOURCE_DIR}/cmake/setup_mac.sh
43
-        DESTINATION ${PROJECT_BINARY_DIR}/src/OpenRaider.app/Contents/MacOS
44
-        RENAME OpenRaider.sh
45
-    )
46
-
47
-    # Fix executable name, so setup script will be called
48
-    install (CODE "
49
-        execute_process (
50
-            COMMAND /usr/libexec/PlistBuddy -c \"Set :CFBundleExecutable OpenRaider.sh\" Info.plist
51
-            WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/src/OpenRaider.app/Contents
52
-        )
53
-    " COMPONENT Runtime)
54
-endif (APPLE)
55
-
56
-#################################################################
57
-
58
 # Target for running cppcheck
28
 # Target for running cppcheck
59
 set (CHECK_STD "--std=c++11" "--std=posix")
29
 set (CHECK_STD "--std=c++11" "--std=posix")
60
 set (CHECK_FLAGS "--quiet" "--force")
30
 set (CHECK_FLAGS "--quiet" "--force")

+ 39
- 0
src/CMakeLists.txt View File

21
 set (SRCS ${SRCS} World.cpp)
21
 set (SRCS ${SRCS} World.cpp)
22
 set (SRCS ${SRCS} tga.cpp)
22
 set (SRCS ${SRCS} tga.cpp)
23
 
23
 
24
+#################################################################
25
+
24
 # Apple specific bundling
26
 # Apple specific bundling
25
 if (APPLE)
27
 if (APPLE)
26
     # Mac Bundle Data
28
     # Mac Bundle Data
46
     set (SRCS ${SRCS} ${MAC_DATA})
48
     set (SRCS ${SRCS} ${MAC_DATA})
47
 endif (APPLE)
49
 endif (APPLE)
48
 
50
 
51
+#################################################################
52
+
49
 # Add Executable
53
 # Add Executable
50
 add_executable (OpenRaider MACOSX_BUNDLE ${SRCS})
54
 add_executable (OpenRaider MACOSX_BUNDLE ${SRCS})
51
 
55
 
56
+#################################################################
57
+
58
+if (APPLE)
59
+    # Copy setup script
60
+    add_custom_command (TARGET OpenRaider POST_BUILD
61
+        COMMAND echo "Injecting setup script..."
62
+        COMMAND cp "${PROJECT_SOURCE_DIR}/cmake/setup_mac.sh" "${PROJECT_BINARY_DIR}/src/OpenRaider.app/Contents/MacOS/OpenRaider.sh"
63
+    )
64
+
65
+    # Fix executable name, so setup script will be called
66
+    add_custom_command (TARGET OpenRaider POST_BUILD
67
+        COMMAND echo "Changing executable name..."
68
+        COMMAND /usr/libexec/PlistBuddy -c "Set :CFBundleExecutable OpenRaider.sh" Info.plist
69
+        WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/src/OpenRaider.app/Contents
70
+    )
71
+
72
+    # Preparing the bundle on install
73
+    # http://www.cmake.org/Wiki/BundleUtilitiesExample
74
+    set (plugin_dest_dir OpenRaider.app/Contents/MacOS)
75
+    set (APPS "${PROJECT_BINARY_DIR}/src/OpenRaider.app")
76
+    install (CODE "
77
+        file(GLOB_RECURSE PLUGINS
78
+            \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
79
+        include(BundleUtilities)
80
+        fixup_bundle(\"${APPS}\" \"\${PLUGINS}\" \"\")
81
+        " COMPONENT Runtime
82
+    )
83
+endif (APPLE)
84
+
85
+#################################################################
86
+
52
 # Debug build warnings
87
 # Debug build warnings
53
 set (WARNINGS "${WARNINGS} -Weverything -Wno-padded -Wno-packed")
88
 set (WARNINGS "${WARNINGS} -Weverything -Wno-padded -Wno-packed")
54
 set (WARNINGS "${WARNINGS} -Wno-global-constructors -Wno-exit-time-destructors")
89
 set (WARNINGS "${WARNINGS} -Wno-global-constructors -Wno-exit-time-destructors")
82
 # Include External Modules
117
 # Include External Modules
83
 set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
118
 set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
84
 
119
 
120
+#################################################################
121
+
85
 # Add Math Library
122
 # Add Math Library
86
 set (LIBS ${LIBS} m)
123
 set (LIBS ${LIBS} m)
87
 
124
 
122
 # Link to all found libs
159
 # Link to all found libs
123
 target_link_libraries (OpenRaider ${LIBS})
160
 target_link_libraries (OpenRaider ${LIBS})
124
 
161
 
162
+#################################################################
163
+
125
 # Add target to run executable
164
 # Add target to run executable
126
 add_custom_target(run COMMAND OpenRaider DEPENDS OpenRaider WORKING_DIRECTORY ${CMAKE_PROJECT_DIR})
165
 add_custom_target(run COMMAND OpenRaider DEPENDS OpenRaider WORKING_DIRECTORY ${CMAKE_PROJECT_DIR})

Loading…
Cancel
Save