-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathCMakeLists.txt
216 lines (214 loc) · 9.19 KB
/
CMakeLists.txt
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
cmake_minimum_required(VERSION 3.10)
project(CEF3SimpleSample VERSION 1.0)
set(APP_NAME "CEF3SimpleSample")
set(APP_FOLDER_NAME "CEF3SimpleSample")
if(APPLE)
### Build main executable
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
find_program(INTOOL install_name_tool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
find_library(COCOA_LIBRARY Cocoa)
file(GLOB SRC_FILES CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/Mac/*.mm"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CrossPlatform/*.cpp"
)
add_executable(MainExecutable MACOSX_BUNDLE ${SRC_FILES})
target_compile_features(MainExecutable PRIVATE cxx_range_for)
target_link_libraries(MainExecutable
${COCOA_LIBRARY}
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Mac/lib/cef_sandbox.a"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Mac/lib/libcef_dll_wrapper.a"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Mac/lib/Chromium Embedded Framework.framework"
)
target_include_directories(MainExecutable PUBLIC
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Mac"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Mac/include"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CrossPlatform"
)
set(EXECUTABLE_NAME ${APP_NAME})
set(PRODUCT_NAME ${APP_NAME})
set_target_properties(MainExecutable PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/Mac/CEF3SimpleSample-Info.plist"
OUTPUT_NAME "${APP_NAME}"
)
add_custom_command (TARGET MainExecutable POST_BUILD
COMMAND ${IBTOOL} --errors --warnings --notices
--output-format human-readable-text --compile
"${PROJECT_BINARY_DIR}/${APP_NAME}.app/Contents/Resources/Base.lproj/MainMenu.nib"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/Mac/Resources/Base.lproj/MainMenu.xib"
)
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CrossPlatform/html"
"${PROJECT_BINARY_DIR}/${APP_NAME}.app/Contents/Resources/html"
VERBATIM
)
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Mac/lib/Chromium Embedded Framework.framework"
"${PROJECT_BINARY_DIR}/${APP_NAME}.app/Contents/Frameworks/Chromium Embedded Framework.framework"
VERBATIM
)
### Build helpers
set(HELPER_SUFFIXES "None" "GPU" "Plugin" "Renderer")
foreach(suffix ${HELPER_SUFFIXES})
file(GLOB SRC_FILES CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/Mac/Helper Process Main.cpp"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CrossPlatform/*.cpp"
)
if(${suffix} STREQUAL "None")
set(suffix "")
set(HELPER_BUNDLE "${APP_NAME} Helper")
else()
set(HELPER_BUNDLE "${APP_NAME} Helper (${suffix})")
endif()
set(HELPER_NAME "${suffix}HelperApp")
set(HELPER_INSTALL_PATH "${PROJECT_BINARY_DIR}/${APP_NAME}.app/Contents/Frameworks/${HELPER_BUNDLE}.app")
add_executable(${HELPER_NAME} MACOSX_BUNDLE ${SRC_FILES})
target_compile_features(${HELPER_NAME} PRIVATE cxx_range_for)
target_link_libraries(${HELPER_NAME}
${COCOA_LIBRARY}
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Mac/lib/cef_sandbox.a"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Mac/lib/libcef_dll_wrapper.a"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Mac/lib/Chromium Embedded Framework.framework"
)
target_include_directories(${HELPER_NAME} PUBLIC
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Mac"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Mac/include"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CrossPlatform"
)
set_target_properties(${HELPER_NAME} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/${APP_FOLDER_NAME}/Mac/CEF3SimpleSampleHelper-Info.plist"
OUTPUT_NAME ${HELPER_BUNDLE}
)
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_BINARY_DIR}/${HELPER_BUNDLE}.app"
"${HELPER_INSTALL_PATH}"
VERBATIM
)
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory "${HELPER_INSTALL_PATH}/Contents/Frameworks" VERBATIM
)
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${INTOOL} -change
"@executable_path/../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework"
"@executable_path/../../../Chromium Embedded Framework.framework/Chromium Embedded Framework"
"${HELPER_INSTALL_PATH}/Contents/MacOS/${HELPER_BUNDLE}"
VERBATIM
)
add_dependencies(MainExecutable ${HELPER_NAME})
endforeach()
elseif(WIN32)
file(GLOB SRC_FILES CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/Win/main.cpp"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CrossPlatform/*.cpp"
)
add_executable(MainExecutable WIN32 ${SRC_FILES})
target_compile_features(MainExecutable PRIVATE cxx_range_for)
target_compile_options(MainExecutable PUBLIC "/EHsc" "/MT")
target_link_libraries(MainExecutable
${GTK3_LIBRARIES}
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Win/lib/libcef_dll_wrapper.lib"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Win/lib/libcef.lib"
)
target_include_directories(MainExecutable PUBLIC
${GTK3_INCLUDE_DIRS}
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Win"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Win/include"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CrossPlatform"
)
set(EXECUTABLE_NAME ${APP_NAME})
set(PRODUCT_NAME ${APP_NAME})
set_target_properties(MainExecutable PROPERTIES OUTPUT_NAME "${APP_NAME}")
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CrossPlatform/html"
"${PROJECT_BINARY_DIR}/bin/html"
VERBATIM
)
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Win/Resources"
"${PROJECT_BINARY_DIR}/bin"
VERBATIM
)
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Win/lib"
"${PROJECT_BINARY_DIR}/bin"
VERBATIM
)
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${PROJECT_BINARY_DIR}/Release/${APP_NAME}.exe"
"${PROJECT_BINARY_DIR}/bin/${APP_NAME}.exe"
VERBATIM
)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
file(GLOB SRC_FILES CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/Linux/main.cpp"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CrossPlatform/*.cpp"
)
add_executable(MainExecutable ${SRC_FILES})
target_compile_options(MainExecutable PUBLIC ${GTK3_CFLAGS_OTHER})
target_compile_features(MainExecutable PRIVATE cxx_range_for)
target_link_directories(MainExecutable PUBLIC ${GTK3_LIBRARY_DIRS})
target_link_libraries(MainExecutable
${GTK3_LIBRARIES}
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Linux/lib/libcef_dll_wrapper.a"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Linux/lib/libcef.so"
)
target_include_directories(MainExecutable PUBLIC
${GTK3_INCLUDE_DIRS}
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Linux"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Linux/include"
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CrossPlatform"
)
set(EXECUTABLE_NAME ${APP_NAME})
set(PRODUCT_NAME ${APP_NAME})
set_target_properties(MainExecutable PROPERTIES OUTPUT_NAME "${APP_NAME}")
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CrossPlatform/html"
"${PROJECT_BINARY_DIR}/bin/html"
VERBATIM
)
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/${APP_FOLDER_NAME}/CEF/Linux/lib"
"${PROJECT_BINARY_DIR}/bin"
VERBATIM
)
add_custom_command(
TARGET MainExecutable
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${PROJECT_BINARY_DIR}/${APP_NAME}"
"${PROJECT_BINARY_DIR}/bin/${APP_NAME}"
VERBATIM
)
endif()