Merge pull request #291 from christophgysin/libs

cmake: build common code only once
This commit is contained in:
Drew DeVault 2015-12-02 05:34:18 -05:00
commit 7a1c8c2939
9 changed files with 93 additions and 78 deletions

View file

@ -41,7 +41,19 @@ add_definitions(-DSWAY_GIT_BRANCH=\"${GIT_BRANCH}\")
string(TIMESTAMP CURRENT_DATE "%Y-%m-%d" UTC)
add_definitions(-DSWAY_VERSION_DATE=\"${CURRENT_DATE}\")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
find_package(Cairo REQUIRED)
find_package(JsonC REQUIRED)
find_package(PCRE REQUIRED)
find_package(Pango REQUIRED)
find_package(WLC REQUIRED)
find_package(Wayland REQUIRED)
find_package(XKBCommon REQUIRED)
include_directories(include)
add_subdirectory(protocols)
add_subdirectory(common)
add_subdirectory(wayland)
add_subdirectory(sway)
add_subdirectory(swaybg)

7
common/CMakeLists.txt Normal file
View file

@ -0,0 +1,7 @@
add_library(sway-common
ipc-client.c
list.c
log.c
readline.c
stringop.c
)

22
protocols/CMakeLists.txt Normal file
View file

@ -0,0 +1,22 @@
include(Wayland)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-client-xdg-shell
xdg-shell.xml
xdg-shell
)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-client-desktop-shell
desktop-shell.xml
desktop-shell
)
WAYLAND_ADD_PROTOCOL_SERVER(proto-server-desktop-shell
desktop-shell.xml
desktop-shell
)
add_library(sway-protocols
${proto-client-xdg-shell}
${proto-client-desktop-shell}
${proto-server-desktop-shell}
)
set(PROTOCOLS_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/protocols PARENT_SCOPE)

View file

@ -1,33 +1,33 @@
find_package(XKBCommon REQUIRED)
find_package(WLC REQUIRED)
find_package(PCRE REQUIRED)
find_package(Wayland REQUIRED)
find_package(JsonC REQUIRED)
include(Wayland)
WAYLAND_ADD_PROTOCOL_SERVER(proto-desktop-shell
${PROJECT_SOURCE_DIR}/protocols/desktop-shell.xml
desktop-shell
)
file(GLOB sources ${PROJECT_SOURCE_DIR}/sway/*.c)
file(GLOB common ${PROJECT_SOURCE_DIR}/common/*.c)
include_directories(
${PROTOCOLS_INCLUDE_DIRS}
${WLC_INCLUDE_DIRS}
${PCRE_INCLUDE_DIRS}
${JSONC_INCLUDE_DIRS}
${XKBCOMMON_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
)
add_executable(sway
${sources}
${common}
${proto-desktop-shell}
commands.c
config.c
container.c
criteria.c
debug_log.c
extensions.c
focus.c
handlers.c
input_state.c
ipc-server.c
layout.c
main.c
output.c
resize.c
util.c
workspace.c
)
target_link_libraries(sway
sway-common
sway-protocols
${WLC_LIBRARIES}
${XKBCOMMON_LIBRARIES}
${PCRE_LIBRARIES}

View file

@ -1,37 +1,17 @@
find_package(Wayland REQUIRED)
find_package(Cairo REQUIRED)
find_package(Pango REQUIRED)
include(Wayland)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-xdg-shell
../protocols/xdg-shell.xml
xdg-shell
)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-desktop-shell
../protocols/desktop-shell.xml
desktop-shell
)
include_directories(
${PROTOCOLS_INCLUDE_DIRS}
${WAYLAND_CLIENT_INCLUDE_DIR}
${CAIRO_INCLUDE_DIRS}
${PANGO_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
)
file(GLOB sources *.c)
file(GLOB common ../common/*.c)
file(GLOB wl_sources ../wayland/*.c)
add_executable(swaybar
${sources}
${wl_sources}
${common}
${proto-xdg-shell}
${proto-desktop-shell}
main.c
)
target_link_libraries(swaybar
sway-common
sway-wayland
${WAYLAND_CLIENT_LIBRARIES}
${WAYLAND_CURSOR_LIBRARIES}
${CAIRO_LIBRARIES}

View file

@ -1,37 +1,17 @@
find_package(Wayland REQUIRED)
find_package(Cairo REQUIRED)
find_package(Pango REQUIRED)
include(Wayland)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-xdg-shell
../protocols/xdg-shell.xml
xdg-shell
)
WAYLAND_ADD_PROTOCOL_CLIENT(proto-desktop-shell
../protocols/desktop-shell.xml
desktop-shell
)
include_directories(
${PROTOCOLS_INCLUDE_DIRS}
${WAYLAND_CLIENT_INCLUDE_DIR}
${CAIRO_INCLUDE_DIRS}
${PANGO_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
)
file(GLOB sources *.c)
file(GLOB common ../common/*.c)
file(GLOB wl_sources ../wayland/*.c)
add_executable(swaybg
${sources}
${wl_sources}
${common}
${proto-xdg-shell}
${proto-desktop-shell}
main.c
)
target_link_libraries(swaybg
sway-common
sway-wayland
${WAYLAND_CLIENT_LIBRARIES}
${WAYLAND_CURSOR_LIBRARIES}
${CAIRO_LIBRARIES}

View file

@ -1,12 +1,9 @@
file(GLOB sources *.c)
file(GLOB common ../common/*.c)
add_executable(swaygrab
${sources}
${common}
main.c
)
target_link_libraries(swaygrab
sway-common
rt
)

View file

@ -1,11 +1,11 @@
file(GLOB sources *.c)
file(GLOB common ../common/*.c)
add_executable(swaymsg
${sources}
${common}
main.c
)
target_link_libraries(swaymsg
sway-common
)
install(
TARGETS swaymsg
RUNTIME

17
wayland/CMakeLists.txt Normal file
View file

@ -0,0 +1,17 @@
include_directories(
${PROTOCOLS_INCLUDE_DIRS}
${PANGO_INCLUDE_DIRS}
)
add_library(sway-wayland
buffers.c
pango.c
registry.c
window.c
)
target_link_libraries(sway-wayland
sway-common
sway-protocols
${PANGO_LIBRARIES}
)