-
Notifications
You must be signed in to change notification settings - Fork 289
/
Mac.cmake
136 lines (107 loc) · 5 KB
/
Mac.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#/**********************************************************\
#Original Author: Richard Bateman (taxilian)
#
#Created: Jan 11, 2010
#License: Dual license model; choose one of two:
# New BSD License
# http://www.opensource.org/licenses/bsd-license.php
# - or -
# GNU Lesser General Public License, version 2.1
# http://www.gnu.org/licenses/lgpl-2.1.html
#
#Copyright 2009 PacketPass, Inc and the Firebreath development team
#\**********************************************************/
# The reason 2.8.5 is required as a minimum version on Mac is that 2.8.5 is where the patch to allow
# direct compilation of cfbundle projects in Xcode and gcc was introduced into cmake.
cmake_minimum_required(VERSION 2.8.5)
set (PATCH_DESC_FILENAME ${CMAKE_BINARY_DIR}/xcode_patch_desc.txt)
if ("${CMAKE_GENERATOR}" STREQUAL "Xcode" AND NOT XCODE_DIR)
execute_process (COMMAND
xcode-select -print-path
RESULT_VARIABLE XCODE_RES
OUTPUT_VARIABLE XCODE_DIR
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT XCODE_RES EQUAL 0)
set (XCODE_DIR "/Developer")
message ("Could not find Xcode. Defaulting to ${XCODE_DIR}")
endif()
set (XCODE_DIR "${XCODE_DIR}" CACHE PATH "Path to Xcode")
endif()
function(patch_xcode_plugin PRJNAME TARGETNAME)
file(APPEND ${PATCH_DESC_FILENAME} "${TARGETNAME} ${PRJNAME}\n")
endfunction(patch_xcode_plugin)
function(clear_xcode_patches)
if (APPLE)
if (EXISTS ${PATCH_DESC_FILENAME})
file(REMOVE ${PATCH_DESC_FILENAME})
endif()
endif(APPLE)
endfunction(clear_xcode_patches)
MACRO(add_mac_plugin PROJECT_NAME PLIST_TEMPLATE STRINGS_TEMPLATE LOCALIZED_TEMPLATE INSOURCES)
message ("Creating Mac Browser Plugin project ${PROJECT_NAME}")
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/bundle)
file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bundle)
file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj)
endif()
configure_template(${PLIST_TEMPLATE} ${CMAKE_CURRENT_BINARY_DIR}/bundle/Info.plist)
configure_template(${STRINGS_TEMPLATE} ${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/InfoPlist.strings)
configure_template(${LOCALIZED_TEMPLATE} ${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/Localized.r)
#set(MAC_RESOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/Localized.r)
set(SOURCES
${${INSOURCES}}
${CMAKE_CURRENT_BINARY_DIR}/bundle/Info.plist
${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/InfoPlist.strings
${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/Localized.r
${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/Localized.rsrc
)
add_definitions(
-DXP_MACOSX=1
)
set (RCFILES ${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/Localized.r)
foreach(ARCH ${CMAKE_OSX_ARCHITECTURES})
list(APPEND ARCHS -arch ${ARCH})
endforeach()
# Compile the resource file
firebreath_find_commands()
set(RC_COMPILER ${CMD_REZ})
execute_process(COMMAND
${RC_COMPILER} ${RCFILES} -useDF ${ARCHS} -arch x86_64 -o ${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/Localized.rsrc
)
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/Localized.rsrc
PROPERTIES GENERATED 1
)
message("Generating ${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/Localized.rsrc")
add_library( ${PROJECT_NAME} MODULE
${SOURCES}
)
string(REPLACE " " "\ " FB_ESC_ROOT_DIR ${FB_ROOT_DIR})
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_NAME ${FBSTRING_PluginName}
BUNDLE 1
BUNDLE_EXTENSION plugin
XCODE_ATTRIBUTE_WRAPPER_EXTENSION plugin #sets the extension to .plugin
XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle
XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/bundle/Info.plist
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/bundle/Info.plist
LINK_FLAGS "-Wl,-exported_symbols_list,${FB_ESC_ROOT_DIR}/gen_templates/ExportList_plugin.txt")
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/InfoPlist.strings
${CMAKE_CURRENT_BINARY_DIR}/bundle/English.lproj/Localized.rsrc
PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/English.lproj")
ENDMACRO(add_mac_plugin)
MACRO(firebreath_find_commands)
set(XCODE_TOOLS_PATHS /Developer/Tools /Applications/Xcode.app/Contents/Developer/Tools /Applications/Xcode.app/Contents/Developer/usr/bin /usr/bin)
find_program(CMD_CP cp)
find_program(CMD_RM rm)
find_program(CMD_LN ln)
find_program(CMD_MV mv)
find_program(CMD_HDIUTIL hdiutil)
find_program(CMD_SIPS sips)
find_program(CMD_SLEEP sleep)
find_program(CMD_OSASCRIPT osascript)
find_program(CMD_SETFILE SetFile ${XCODE_TOOLS_PATHS} )
find_program(CMD_DEREZ DeRez ${XCODE_TOOLS_PATHS} )
find_program(CMD_REZ Rez ${XCODE_TOOLS_PATHS} )
ENDMACRO(firebreath_find_commands)