Skip to content

Commit

Permalink
[cmake] Fix build if '-Wl,--no-undefined' is specified in CMAKE_SHARE…
Browse files Browse the repository at this point in the history
…D_LINKER_FLAGS.

Also add '-Wl,--no-undefined' to the linker options of the base library.
  • Loading branch information
NilsBrause committed Oct 8, 2019
1 parent f7d4fd2 commit f478bb7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ cmake_dependent_option(BUILD_EXAMPLES
"whether to build the examples (requires BUILD_LIBRARIES to be ON)" OFF
"BUILD_LIBRARIES" OFF)

# Do not report undefined references in libraries, since the protocol libraries cannot be used on their own.
string(REPLACE "-Wl,--no-undefined" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS})

# variables for .pc.in files
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(bindir "${CMAKE_INSTALL_FULL_BINDIR}")
Expand Down Expand Up @@ -154,6 +157,8 @@ if(BUILD_LIBRARIES)
define_library(wayland-client++ "${WAYLAND_CLIENT_CFLAGS}" "${WAYLAND_CLIENT_LIBRARIES}"
"include/wayland-client.hpp;include/wayland-util.hpp;${CMAKE_CURRENT_BINARY_DIR}/wayland-client-protocol.hpp;${CMAKE_CURRENT_BINARY_DIR}/wayland-version.hpp"
src/wayland-client.cpp src/wayland-util.cpp wayland-client-protocol.cpp wayland-client-protocol.hpp)
# Report undefined references only for the base library.
target_link_options(wayland-client++ PRIVATE "-Wl,--no-undefined")
define_library(wayland-client-extra++ "${WAYLAND_CLIENT_CFLAGS}" "${WAYLAND_CLIENT_LIBRARIES}"
"${CMAKE_CURRENT_BINARY_DIR}/wayland-client-protocol-extra.hpp"
wayland-client-protocol-extra.cpp wayland-client-protocol-extra.hpp wayland-client-protocol.hpp)
Expand Down

0 comments on commit f478bb7

Please sign in to comment.