1 # ----------------------------------------------------------------------------
2 # Applies to all targets in this CMakeLists.
3 # ----------------------------------------------------------------------------
6 -DWAFFLE_API_VERSION=${waffle_api_version}
7 -DWAFFLE_API_EXPERIMENTAL
29 ${libudev_INCLUDE_DIRS}
31 ${wayland-client_INCLUDE_DIRS}
32 ${wayland-egl_INCLUDE_DIRS}
33 ${x11-xcb_INCLUDE_DIRS}
36 # ----------------------------------------------------------------------------
37 # Target: waffle (shared library)
38 # ----------------------------------------------------------------------------
40 list(APPEND waffle_libdeps
46 list(APPEND waffle_libdeps
51 list(APPEND waffle_libdeps
58 list(APPEND waffle_libdeps
65 api/waffle_attrib_list.c
75 core/wcore_attrib_list.c
76 core/wcore_config_attrs.c
84 list(APPEND waffle_sources
94 list(APPEND waffle_libdeps
100 list(APPEND waffle_sources
111 list(APPEND waffle_sources
121 list(APPEND waffle_sources
123 linux/linux_platform.c
125 list(APPEND waffle_libdeps
131 if(waffle_has_surfaceless_egl)
132 list(APPEND waffle_sources
133 surfaceless_egl/sl_display.c
134 surfaceless_egl/sl_platform.c
135 surfaceless_egl/sl_window.c
139 if(waffle_has_wayland)
140 list(APPEND waffle_sources
141 wayland/wayland_display.c
142 wayland/wayland_platform.c
143 wayland/wayland_window.c
144 wayland/wayland_wrapper.c
149 list(APPEND waffle_sources
155 if(waffle_has_x11_egl)
156 list(APPEND waffle_sources
164 list(APPEND waffle_sources
172 if(waffle_on_windows)
173 list(APPEND waffle_sources
183 list(APPEND waffle_libdeps
189 list(APPEND waffle_sources
197 list(APPEND waffle_cxx_sources
198 nacl/nacl_container.cpp
202 # CMake will pass to the C compiler only C sources. CMake does not recognize the
203 # .m extension and ignores any such files in the source lists. To coerce CMake
204 # to pass .m files to the compiler, we must lie and claim that they are
206 set_source_files_properties(
212 if(waffle_on_windows)
215 ${CMAKE_CURRENT_SOURCE_DIR}/${waffle_libname}.def
219 list(APPEND waffle_sources
220 ${waffle_libname}.def
227 ${X11-XCB_INCLUDE_DIRS}
231 add_library(${waffle_libname} SHARED ${waffle_sources} ${waffle_cxx_sources})
233 # Debian's packaging system emits warnings if wflinfo directly links to any
234 # library that it doesn't directly use. Silence the warnings by annotating
235 # libwaffle's library dependencies as private, which prevents wflinfo from
237 if(CMAKE_VERSION VERSION_LESS "2.8.12")
238 # On older CMake, we must rely on hacking the LINK_INTERFACE_LIBRARIES
240 if(NOT waffle_on_mac)
241 set_target_properties(${waffle_libname}
243 LINK_INTERFACE_LIBRARIES ""
247 # CMake 2.8.12 introduced the PRIVATE keyword to target_link_libraries().
248 # All libraries listed after PRIVATE get annotated as such.
249 list(INSERT waffle_libdeps 0 PRIVATE)
252 target_link_libraries(${waffle_libname} ${waffle_libdeps})
254 set_target_properties(${waffle_libname}
256 SOVERSION ${waffle_soversion}
257 VERSION ${waffle_soversion}.${waffle_minor_version}.${waffle_patch_version}
260 if(waffle_on_windows)
261 set_target_properties(${waffle_libname}
268 TARGETS ${waffle_libname}
269 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
270 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
271 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
275 # ----------------------------------------------------------------------------
276 # Target: waffle_static
277 # ----------------------------------------------------------------------------
279 # The unittest executable needs access to waffle's internal symbols. Yet, the
280 # sources in libwaffle.so are compiled with -fvisibility=hidden.
281 # One solution is to additionally build a static libwaffle and let the
282 # unittest executable link to that. Visibility options do not apply to static
283 # libraries; that is, all symbols are public.
285 add_library(waffle_static
291 target_link_libraries(waffle_static ${waffle_libdeps})
293 set_target_properties(waffle_static
295 OUTPUT_NAME "waffle-static-${waffle_major_version}"
298 # ----------------------------------------------------------------------------
300 # ----------------------------------------------------------------------------
302 function(add_unittest unittest_name)
303 if(NOT waffle_build_tests)
307 add_executable(${unittest_name} ${ARGN})
308 set_target_properties(${unittest_name}
310 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests"
312 target_link_libraries(${unittest_name}
316 add_custom_target(${unittest_name}_run
317 COMMAND "${unittest_name}"
319 add_dependencies(check ${unittest_name}_run)
321 if(VALGRIND_EXECUTABLE)
322 add_custom_target(valgrind_${unittest_name}_run
323 DEPENDS ${unittest_name}
324 COMMAND ${VALGRIND_EXECUTABLE} $<TARGET_FILE:${unittest_name}>
326 add_dependencies(valgrind-check valgrind_${unittest_name}_run)
330 add_unittest(wcore_attrib_list_unittest
331 core/wcore_attrib_list_unittest.c
333 add_unittest(wcore_config_attrs_unittest
334 core/wcore_config_attrs_unittest.c
336 add_unittest(wcore_error_unittest
337 core/wcore_error_unittest.c