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