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# ceftests sources. 10{{ 11 'prefix': 'ceftests', 12 'set': 'UNITTESTS_SRCS', 13 'includes': [ 14 'shared_sources_browser', 15 'shared_sources_common', 16 'shared_sources_linux:LINUX', 17 'shared_sources_mac:MAC', 18 'shared_sources_renderer:WINDOWS', 19 'shared_sources_renderer:LINUX', 20 'shared_sources_win:WINDOWS', 21 'ceftests_sources_common', 22 'ceftests_sources_linux:LINUX', 23 'ceftests_sources_mac:MAC', 24 'ceftests_sources_win:WINDOWS', 25 ], 26}} 27 28# ceftests helper sources. 29{{ 30 'prefix': 'ceftests_helper', 31 'set': 'UNITTESTS_HELPER_SRCS', 32 'includes': [ 33 'shared_sources_common', 34 'shared_sources_mac_helper:MAC', 35 'shared_sources_renderer', 36 'ceftests_sources_mac_helper:MAC', 37 ], 38}} 39 40# ceftests resources. 41{{ 42 'prefix': 'ceftests_resources', 43 'set': 'UNITTESTS_RESOURCES_SRCS', 44 'includes': [ 45 'shared_sources_resources', 46 'ceftests_bundle_resources_mac:MAC', 47 ], 48}} 49 50 51# 52# Shared configuration. 53# 54 55# Target executable names. 56set(CEF_TARGET "ceftests") 57if(OS_MAC) 58 set(CEF_HELPER_TARGET "ceftests_Helper") 59 set(CEF_HELPER_OUTPUT_NAME "ceftests Helper") 60else() 61 # Logical target used to link the libcef library. 62 ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}") 63endif() 64 65# Determine the target output directory. 66SET_CEF_TARGET_OUT_DIR() 67 68 69# 70# Linux configuration. 71# 72 73if(OS_LINUX) 74 # Find required libraries and update compiler/linker variables. 75 FIND_LINUX_LIBRARIES("glib-2.0") 76 77 # Executable target. 78 add_executable(${CEF_TARGET} ${UNITTESTS_SRCS} ${UNITTESTS_RESOURCES_SRCS}) 79 SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET}) 80 add_dependencies(${CEF_TARGET} libcef_dll_wrapper cef_gtest) 81 target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper cef_gtest ${CEF_STANDARD_LIBS}) 82 83 # Set rpath so that libraries can be placed next to the executable. 84 set_target_properties(${CEF_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN") 85 set_target_properties(${CEF_TARGET} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) 86 set_target_properties(${CEF_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR}) 87 88 # Copy binary and resource files to the target output directory. 89 COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}") 90 COPY_FILES("${CEF_TARGET}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}") 91 92 # Copy ceftests resource files to the target output directory. 93 COPY_FILES("${CEF_TARGET}" "${UNITTESTS_RESOURCES_SRCS}" "${CMAKE_CURRENT_SOURCE_DIR}" "${CEF_TARGET_OUT_DIR}/ceftests_files") 94 95 # Set SUID permissions on the chrome-sandbox target. 96 SET_LINUX_SUID_PERMISSIONS("${CEF_TARGET}" "${CEF_TARGET_OUT_DIR}/chrome-sandbox") 97endif() 98 99 100# 101# Mac OS X configuration. 102# 103 104if(OS_MAC) 105 # Output path for the main app bundle. 106 set(CEF_APP "${CEF_TARGET_OUT_DIR}/${CEF_TARGET}.app") 107 108 # Variables referenced from the main Info.plist file. 109 set(EXECUTABLE_NAME "${CEF_TARGET}") 110 set(PRODUCT_NAME "${CEF_TARGET}") 111 112 if(USE_SANDBOX) 113 # Logical target used to link the cef_sandbox library. 114 ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") 115 endif() 116 117 # Main app bundle target. 118 add_executable(${CEF_TARGET} MACOSX_BUNDLE ${UNITTESTS_RESOURCES_SRCS} ${UNITTESTS_SRCS}) 119 SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET}) 120 add_dependencies(${CEF_TARGET} libcef_dll_wrapper cef_gtest) 121 target_link_libraries(${CEF_TARGET} libcef_dll_wrapper cef_gtest ${CEF_STANDARD_LIBS}) 122 set_target_properties(${CEF_TARGET} PROPERTIES 123 MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/mac/Info.plist 124 ) 125 126 # Copy the CEF framework into the Frameworks directory. 127 add_custom_command( 128 TARGET ${CEF_TARGET} 129 POST_BUILD 130 COMMAND ${CMAKE_COMMAND} -E copy_directory 131 "${CEF_BINARY_DIR}/Chromium Embedded Framework.framework" 132 "${CEF_APP}/Contents/Frameworks/Chromium Embedded Framework.framework" 133 VERBATIM 134 ) 135 136 # Create the multiple Helper app bundle targets. 137 foreach(_suffix_list ${CEF_HELPER_APP_SUFFIXES}) 138 # Convert to a list and extract the suffix values. 139 string(REPLACE ":" ";" _suffix_list ${_suffix_list}) 140 list(GET _suffix_list 0 _name_suffix) 141 list(GET _suffix_list 1 _target_suffix) 142 list(GET _suffix_list 2 _plist_suffix) 143 144 # Define Helper target and output names. 145 set(_helper_target "${CEF_HELPER_TARGET}${_target_suffix}") 146 set(_helper_output_name "${CEF_HELPER_OUTPUT_NAME}${_name_suffix}") 147 148 # Create Helper-specific variants of the helper-Info.plist file. Do this 149 # manually because the configure_file command (which is executed as part of 150 # MACOSX_BUNDLE_INFO_PLIST) uses global env variables and would insert the 151 # wrong values with multiple targets. 152 set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/helper-Info${_target_suffix}.plist") 153 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/resources/mac/helper-Info.plist" _plist_contents) 154 string(REPLACE "\${EXECUTABLE_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents}) 155 string(REPLACE "\${PRODUCT_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents}) 156 string(REPLACE "\${BUNDLE_ID_SUFFIX}" "${_plist_suffix}" _plist_contents ${_plist_contents}) 157 file(WRITE ${_helper_info_plist} ${_plist_contents}) 158 159 # Create Helper executable target. 160 add_executable(${_helper_target} MACOSX_BUNDLE ${UNITTESTS_HELPER_SRCS}) 161 SET_EXECUTABLE_TARGET_PROPERTIES(${_helper_target}) 162 add_dependencies(${_helper_target} libcef_dll_wrapper cef_gtest) 163 target_link_libraries(${_helper_target} libcef_dll_wrapper cef_gtest ${CEF_STANDARD_LIBS}) 164 set_target_properties(${_helper_target} PROPERTIES 165 MACOSX_BUNDLE_INFO_PLIST ${_helper_info_plist} 166 OUTPUT_NAME ${_helper_output_name} 167 ) 168 169 if(USE_SANDBOX) 170 target_link_libraries(${_helper_target} cef_sandbox_lib) 171 endif() 172 173 # Add the Helper as a dependency of the main executable target. 174 add_dependencies(${CEF_TARGET} "${_helper_target}") 175 176 # Copy the Helper app bundle into the Frameworks directory. 177 add_custom_command( 178 TARGET ${CEF_TARGET} 179 POST_BUILD 180 COMMAND ${CMAKE_COMMAND} -E copy_directory 181 "${CEF_TARGET_OUT_DIR}/${_helper_output_name}.app" 182 "${CEF_APP}/Contents/Frameworks/${_helper_output_name}.app" 183 VERBATIM 184 ) 185 endforeach() 186 187 # Manually process and copy over resource files. 188 # The Xcode generator can support this via the set_target_properties RESOURCE 189 # directive but that doesn't properly handle nested resource directories. 190 # Remove these prefixes from input file paths. 191 set(PREFIXES 192 "resources/mac/" 193 "../shared/resources/" 194 ) 195 COPY_MAC_RESOURCES("${UNITTESTS_RESOURCES_SRCS}" "${PREFIXES}" "${CEF_TARGET}" "${CMAKE_CURRENT_SOURCE_DIR}" "${CEF_APP}") 196endif() 197 198 199# 200# Windows configuration. 201# 202 203if(OS_WINDOWS) 204 # Executable target. 205 add_executable(${CEF_TARGET} WIN32 ${UNITTESTS_SRCS} ${UNITTESTS_RESOURCES_SRCS}) 206 add_dependencies(${CEF_TARGET} libcef_dll_wrapper cef_gtest) 207 208 list(APPEND CEF_EXE_LINKER_FLAGS 209 /SUBSYSTEM:CONSOLE # Configure as a console application. 210 ) 211 212 SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET}) 213 target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper cef_gtest ${CEF_STANDARD_LIBS}) 214 215 if(USE_SANDBOX) 216 # Logical target used to link the cef_sandbox library. 217 ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") 218 target_link_libraries(${CEF_TARGET} cef_sandbox_lib ${CEF_SANDBOX_STANDARD_LIBS}) 219 endif() 220 221 # Add the custom manifest files to the executable. 222 ADD_WINDOWS_MANIFEST("${CMAKE_CURRENT_SOURCE_DIR}/resources/win" "${CEF_TARGET}" "exe") 223 224 # Copy CEF binary and resource files to the target output directory. 225 COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}") 226 COPY_FILES("${CEF_TARGET}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}") 227endif() 228 229