1# Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights 2# reserved. Use of this source code is governed by a BSD-style license that 3# can be found in the LICENSE file. 4 5# 6# Source files. 7# 8 9# cefclient browser sources. 10{{ 11 'prefix': 'cefclient_browser', 12 'set': 'CEFCLIENT_BROWSER_SRCS', 13 'includes': [ 14 'shared_sources_browser', 15 'cefclient_sources_browser', 16 ], 17}} 18 19# cefclient common sources. 20{{ 21 'prefix': 'cefclient_common', 22 'set': 'CEFCLIENT_COMMON_SRCS', 23 'includes': [ 24 'shared_sources_common', 25 'cefclient_sources_common', 26 ], 27}} 28 29# cefclient renderer sources. 30{{ 31 'prefix': 'cefclient_renderer', 32 'set': 'CEFCLIENT_RENDERER_SRCS', 33 'includes': [ 34 'shared_sources_renderer', 35 'cefclient_sources_renderer', 36 ], 37}} 38 39#cefclient Linux sources 40{{ 41 'prefix': 'cefclient_linux', 42 'set': 'CEFCLIENT_LINUX_SRCS', 43 'includes': [ 44 'shared_sources_linux', 45 'cefclient_sources_linux', 46 ], 47}} 48 49#cefclient Mac OS X sources 50{{ 51 'prefix': 'cefclient_macosx', 52 'set': 'CEFCLIENT_MAC_SRCS', 53 'includes': [ 54 'shared_sources_mac', 55 'cefclient_sources_mac', 56 ], 57}} 58 59# cefclient Mac OS X helper sources. 60{{ 61 'prefix': 'cefclient_helper', 62 'set': 'CEFCLIENT_MAC_HELPER_SRCS', 63 'includes': [ 64 'shared_sources_mac_helper', 65 ], 66}} 67 68#cefclient Windows sources 69{{ 70 'prefix': 'cefclient_windows', 71 'set': 'CEFCLIENT_WINDOWS_SRCS', 72 'includes': [ 73 'shared_sources_win', 74 'cefclient_sources_win', 75 ], 76}} 77 78# cefclient resources. 79{{ 80 'prefix': 'cefclient_resources', 81 'set': 'CEFCLIENT_RESOURCES_SRCS', 82 'includes': [ 83 'shared_sources_resources', 84 'cefclient_bundle_resources_mac:MAC', 85 'cefclient_sources_resources', 86 'cefclient_sources_resources_extensions_set_page_color', 87 ], 88}} 89 90 91# 92# Shared configuration. 93# 94 95# Target executable names. 96set(CEF_TARGET "cefclient") 97if(OS_MAC) 98 set(CEF_HELPER_TARGET "cefclient_Helper") 99 set(CEF_HELPER_OUTPUT_NAME "cefclient Helper") 100else() 101 # Logical target used to link the libcef library. 102 ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}") 103endif() 104 105# Determine the target output directory. 106SET_CEF_TARGET_OUT_DIR() 107 108 109# 110# Linux configuration. 111# 112 113if(OS_LINUX) 114 # All sources required by the "cefclient" target. Generates an executable that 115 # is used for all processes. 116 set(CEFCLIENT_SRCS 117 ${CEFCLIENT_BROWSER_SRCS} 118 ${CEFCLIENT_COMMON_SRCS} 119 ${CEFCLIENT_RENDERER_SRCS} 120 ${CEFCLIENT_RESOURCES_SRCS} 121 ${CEFCLIENT_LINUX_SRCS} 122 ) 123 124 # Find required libraries and update compiler/linker variables. 125 FIND_LINUX_LIBRARIES("gmodule-2.0 gtk+-3.0 gthread-2.0 gtk+-unix-print-3.0 xi") 126 127 # Executable target. 128 add_executable(${CEF_TARGET} ${CEFCLIENT_SRCS}) 129 SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET}) 130 add_dependencies(${CEF_TARGET} libcef_dll_wrapper) 131 target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper "GL" ${CEF_STANDARD_LIBS}) 132 133 # Set rpath so that libraries can be placed next to the executable. 134 set_target_properties(${CEF_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN") 135 set_target_properties(${CEF_TARGET} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) 136 set_target_properties(${CEF_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR}) 137 138 # We don't call deprecated GTK functions, and they can cause build failures, so disable them. 139 add_definitions("-DGTK_DISABLE_DEPRECATED") 140 141 # Copy CEF binary and resource files to the target output directory. 142 COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}") 143 COPY_FILES("${CEF_TARGET}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}") 144 145 # Copy cefclient resource files to the target output directory. 146 COPY_FILES("${CEF_TARGET}" "${CEFCLIENT_RESOURCES_SRCS}" "${CMAKE_CURRENT_SOURCE_DIR}" "${CEF_TARGET_OUT_DIR}/cefclient_files") 147 148 # Set SUID permissions on the chrome-sandbox target. 149 SET_LINUX_SUID_PERMISSIONS("${CEF_TARGET}" "${CEF_TARGET_OUT_DIR}/chrome-sandbox") 150endif() 151 152 153# 154# Mac OS X configuration. 155# 156 157if(OS_MAC) 158 option(OPTION_USE_ARC "Build with ARC (automatic Reference Counting) on macOS." ON) 159 if(OPTION_USE_ARC) 160 list(APPEND CEF_COMPILER_FLAGS 161 -fobjc-arc 162 ) 163 set_target_properties(${target} PROPERTIES 164 CLANG_ENABLE_OBJC_ARC "YES" 165 ) 166 endif() 167 168 # All sources required by the "cefclient" target. Generates an app bundle that 169 # is used only for the browser process. 170 set(CEFCLIENT_SRCS 171 ${CEFCLIENT_BROWSER_SRCS} 172 ${CEFCLIENT_COMMON_SRCS} 173 ${CEFCLIENT_RESOURCES_SRCS} 174 ${CEFCLIENT_MAC_SRCS} 175 ) 176 177 # All sources required by the "cefclient Helper" target. Generates an app 178 # bundle that is used only for non-browser processes. 179 set(CEFCLIENT_HELPER_SRCS 180 ${CEFCLIENT_COMMON_SRCS} 181 ${CEFCLIENT_RENDERER_SRCS} 182 ${CEFCLIENT_MAC_HELPER_SRCS} 183 ) 184 185 # Output path for the main app bundle. 186 set(CEF_APP "${CEF_TARGET_OUT_DIR}/${CEF_TARGET}.app") 187 188 # Variables referenced from the main Info.plist file. 189 set(EXECUTABLE_NAME "${CEF_TARGET}") 190 set(PRODUCT_NAME "${CEF_TARGET}") 191 192 if(USE_SANDBOX) 193 # Logical target used to link the cef_sandbox library. 194 ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") 195 endif() 196 197 # Main app bundle target. 198 add_executable(${CEF_TARGET} MACOSX_BUNDLE ${CEFCLIENT_RESOURCES_SRCS} ${CEFCLIENT_SRCS}) 199 SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET}) 200 add_dependencies(${CEF_TARGET} libcef_dll_wrapper) 201 target_link_libraries(${CEF_TARGET} libcef_dll_wrapper ${CEF_STANDARD_LIBS} "-framework OpenGL") 202 set_target_properties(${CEF_TARGET} PROPERTIES 203 MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/mac/Info.plist 204 ) 205 206 # Copy the CEF framework into the Frameworks directory. 207 add_custom_command( 208 TARGET ${CEF_TARGET} 209 POST_BUILD 210 COMMAND ${CMAKE_COMMAND} -E copy_directory 211 "${CEF_BINARY_DIR}/Chromium Embedded Framework.framework" 212 "${CEF_APP}/Contents/Frameworks/Chromium Embedded Framework.framework" 213 VERBATIM 214 ) 215 216 # Create the multiple Helper app bundle targets. 217 foreach(_suffix_list ${CEF_HELPER_APP_SUFFIXES}) 218 # Convert to a list and extract the suffix values. 219 string(REPLACE ":" ";" _suffix_list ${_suffix_list}) 220 list(GET _suffix_list 0 _name_suffix) 221 list(GET _suffix_list 1 _target_suffix) 222 list(GET _suffix_list 2 _plist_suffix) 223 224 # Define Helper target and output names. 225 set(_helper_target "${CEF_HELPER_TARGET}${_target_suffix}") 226 set(_helper_output_name "${CEF_HELPER_OUTPUT_NAME}${_name_suffix}") 227 228 # Create Helper-specific variants of the helper-Info.plist file. Do this 229 # manually because the configure_file command (which is executed as part of 230 # MACOSX_BUNDLE_INFO_PLIST) uses global env variables and would insert the 231 # wrong values with multiple targets. 232 set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/helper-Info${_target_suffix}.plist") 233 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/resources/mac/helper-Info.plist" _plist_contents) 234 string(REPLACE "\${EXECUTABLE_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents}) 235 string(REPLACE "\${PRODUCT_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents}) 236 string(REPLACE "\${BUNDLE_ID_SUFFIX}" "${_plist_suffix}" _plist_contents ${_plist_contents}) 237 file(WRITE ${_helper_info_plist} ${_plist_contents}) 238 239 # Create Helper executable target. 240 add_executable(${_helper_target} MACOSX_BUNDLE ${CEFCLIENT_HELPER_SRCS}) 241 SET_EXECUTABLE_TARGET_PROPERTIES(${_helper_target}) 242 add_dependencies(${_helper_target} libcef_dll_wrapper) 243 target_link_libraries(${_helper_target} libcef_dll_wrapper ${CEF_STANDARD_LIBS}) 244 set_target_properties(${_helper_target} PROPERTIES 245 MACOSX_BUNDLE_INFO_PLIST ${_helper_info_plist} 246 OUTPUT_NAME ${_helper_output_name} 247 ) 248 249 if(USE_SANDBOX) 250 target_link_libraries(${_helper_target} cef_sandbox_lib) 251 endif() 252 253 # Add the Helper as a dependency of the main executable target. 254 add_dependencies(${CEF_TARGET} "${_helper_target}") 255 256 # Copy the Helper app bundle into the Frameworks directory. 257 add_custom_command( 258 TARGET ${CEF_TARGET} 259 POST_BUILD 260 COMMAND ${CMAKE_COMMAND} -E copy_directory 261 "${CEF_TARGET_OUT_DIR}/${_helper_output_name}.app" 262 "${CEF_APP}/Contents/Frameworks/${_helper_output_name}.app" 263 VERBATIM 264 ) 265 endforeach() 266 267 # Manually process and copy over resource files. 268 # The Xcode generator can support this via the set_target_properties RESOURCE 269 # directive but that doesn't properly handle nested resource directories. 270 # Remove these prefixes from input file paths. 271 set(PREFIXES 272 "resources/mac/" 273 "resources/" 274 "../shared/resources/" 275 ) 276 COPY_MAC_RESOURCES("${CEFCLIENT_RESOURCES_SRCS}" "${PREFIXES}" "${CEF_TARGET}" "${CMAKE_CURRENT_SOURCE_DIR}" "${CEF_APP}") 277endif() 278 279 280# 281# Windows configuration. 282# 283 284if(OS_WINDOWS) 285 # All sources required by the "cefclient" target. Generates an executable that 286 # is used for all processes. 287 set(CEFCLIENT_SRCS 288 ${CEFCLIENT_BROWSER_SRCS} 289 ${CEFCLIENT_COMMON_SRCS} 290 ${CEFCLIENT_RENDERER_SRCS} 291 ${CEFCLIENT_RESOURCES_SRCS} 292 ${CEFCLIENT_WINDOWS_SRCS} 293 ) 294 295 # Executable target. 296 add_executable(${CEF_TARGET} WIN32 ${CEFCLIENT_SRCS}) 297 SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET}) 298 add_dependencies(${CEF_TARGET} libcef_dll_wrapper) 299 target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS} d3d11.lib glu32.lib imm32.lib opengl32.lib) 300 301 if(USE_ATL) 302 # Required by VS2013 to link accessibility API functions. 303 target_link_libraries(${CEF_TARGET} oleacc.lib) 304 endif() 305 306 if(USE_SANDBOX) 307 # Logical target used to link the cef_sandbox library. 308 ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") 309 target_link_libraries(${CEF_TARGET} cef_sandbox_lib ${CEF_SANDBOX_STANDARD_LIBS}) 310 endif() 311 312 # Add the custom manifest files to the executable. 313 ADD_WINDOWS_MANIFEST("${CMAKE_CURRENT_SOURCE_DIR}/resources/win" "${CEF_TARGET}" "exe") 314 315 # Copy CEF binary and resource files to the target output directory. 316 COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}") 317 COPY_FILES("${CEF_TARGET}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}") 318endif() 319