diff options
author | 2015-12-01 15:25:41 -0500 | |
---|---|---|
committer | 2015-12-01 15:25:41 -0500 | |
commit | 1fbabc6c747205e62cd1dff3771bd319a935438f (patch) | |
tree | 8c079c9fe0f909be8429ab010ed75853bd3429d0 /CMakeLists.txt | |
parent | Merge pull request #286 from mikkeloscar/wlc-origin-point (diff) | |
parent | cmake: remove unnecessary quotes (diff) | |
download | sway-1fbabc6c747205e62cd1dff3771bd319a935438f.tar.gz sway-1fbabc6c747205e62cd1dff3771bd319a935438f.tar.zst sway-1fbabc6c747205e62cd1dff3771bd319a935438f.zip |
Merge pull request #285 from christophgysin/cmake
cmake configuration cleanup
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 171 |
1 files changed, 94 insertions, 77 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 68dd7fa3..48f03e2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -4,39 +4,44 @@ project(sway C) | |||
4 | 4 | ||
5 | set(FALLBACK_CONFIG_DIR "/etc/sway" CACHE PATH | 5 | set(FALLBACK_CONFIG_DIR "/etc/sway" CACHE PATH |
6 | "Fallback config directory defaults to /etc/sway") | 6 | "Fallback config directory defaults to /etc/sway") |
7 | add_definitions('-DFALLBACK_CONFIG_DIR=\"${FALLBACK_CONFIG_DIR}\"') | 7 | add_definitions(-DFALLBACK_CONFIG_DIR=\"${FALLBACK_CONFIG_DIR}\") |
8 | 8 | ||
9 | set(CMAKE_C_FLAGS "-g") | 9 | set(CMAKE_C_FLAGS "-g") |
10 | set(CMAKE_C_STANDARD 99) | 10 | set(CMAKE_C_STANDARD 99) |
11 | SET(CMAKE_C_EXTENSIONS OFF) | 11 | set(CMAKE_C_EXTENSIONS OFF) |
12 | set(CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/bin") | 12 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) |
13 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") | 13 | add_definitions( |
14 | add_definitions("-Wall -Wextra -Wno-unused-parameter -D_GNU_SOURCE") | 14 | -D_GNU_SOURCE |
15 | ) | ||
16 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") | ||
17 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra") | ||
18 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter") | ||
19 | |||
15 | list(INSERT CMAKE_MODULE_PATH 0 | 20 | list(INSERT CMAKE_MODULE_PATH 0 |
16 | "${CMAKE_CURRENT_SOURCE_DIR}/CMake") | 21 | ${CMAKE_CURRENT_SOURCE_DIR}/CMake |
17 | 22 | ) | |
18 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") | 23 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) |
19 | execute_process( | 24 | execute_process( |
20 | COMMAND git describe --always | 25 | COMMAND git describe --always |
21 | OUTPUT_VARIABLE GIT_COMMIT_HASH | 26 | OUTPUT_VARIABLE GIT_COMMIT_HASH |
22 | OUTPUT_STRIP_TRAILING_WHITESPACE | 27 | OUTPUT_STRIP_TRAILING_WHITESPACE |
23 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | 28 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
24 | ) | 29 | ) |
25 | execute_process( | 30 | execute_process( |
26 | COMMAND git rev-parse --abbrev-ref HEAD | 31 | COMMAND git rev-parse --abbrev-ref HEAD |
27 | OUTPUT_VARIABLE GIT_BRANCH | 32 | OUTPUT_VARIABLE GIT_BRANCH |
28 | OUTPUT_STRIP_TRAILING_WHITESPACE | 33 | OUTPUT_STRIP_TRAILING_WHITESPACE |
29 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | 34 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
30 | ) | 35 | ) |
31 | endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") | 36 | endif() |
32 | 37 | ||
33 | add_definitions("-DSWAY_GIT_VERSION=\"g${GIT_COMMIT_HASH}\"") | 38 | add_definitions(-DSWAY_GIT_VERSION=\"${GIT_COMMIT_HASH}\") |
34 | add_definitions("-DSWAY_GIT_BRANCH=\"${GIT_BRANCH}\"") | 39 | add_definitions(-DSWAY_GIT_BRANCH=\"${GIT_BRANCH}\") |
35 | 40 | ||
36 | string(TIMESTAMP CURRENT_DATE "%Y-%m-%d" UTC) | 41 | string(TIMESTAMP CURRENT_DATE "%Y-%m-%d" UTC) |
37 | add_definitions('-DSWAY_VERSION_DATE="${CURRENT_DATE}"') | 42 | add_definitions(-DSWAY_VERSION_DATE=\"${CURRENT_DATE}\") |
38 | 43 | ||
39 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") | 44 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) |
40 | 45 | ||
41 | add_subdirectory(swaybg) | 46 | add_subdirectory(swaybg) |
42 | add_subdirectory(swaymsg) | 47 | add_subdirectory(swaymsg) |
@@ -50,68 +55,78 @@ find_package(PCRE REQUIRED) | |||
50 | find_package(Wayland REQUIRED) | 55 | find_package(Wayland REQUIRED) |
51 | find_package(JsonC REQUIRED) | 56 | find_package(JsonC REQUIRED) |
52 | 57 | ||
53 | FILE(GLOB sources ${PROJECT_SOURCE_DIR}/sway/*.c) | 58 | file(GLOB sources ${PROJECT_SOURCE_DIR}/sway/*.c) |
54 | FILE(GLOB common ${PROJECT_SOURCE_DIR}/common/*.c) | 59 | file(GLOB common ${PROJECT_SOURCE_DIR}/common/*.c) |
55 | 60 | ||
56 | include(Wayland) | 61 | include(Wayland) |
57 | WAYLAND_ADD_PROTOCOL_SERVER(proto-desktop-shell "${PROJECT_SOURCE_DIR}/protocols/desktop-shell.xml" desktop-shell) | 62 | WAYLAND_ADD_PROTOCOL_SERVER(proto-desktop-shell |
63 | ${PROJECT_SOURCE_DIR}/protocols/desktop-shell.xml | ||
64 | desktop-shell | ||
65 | ) | ||
58 | 66 | ||
59 | include_directories( | 67 | include_directories( |
60 | ${WLC_INCLUDE_DIRS} | 68 | ${WLC_INCLUDE_DIRS} |
61 | ${PCRE_INCLUDE_DIRS} | 69 | ${PCRE_INCLUDE_DIRS} |
62 | ${JSONC_INCLUDE_DIRS} | 70 | ${JSONC_INCLUDE_DIRS} |
63 | ${XKBCOMMON_INCLUDE_DIRS} | 71 | ${XKBCOMMON_INCLUDE_DIRS} |
64 | ${CMAKE_CURRENT_BINARY_DIR} | 72 | ${CMAKE_CURRENT_BINARY_DIR} |
65 | ) | 73 | ) |
66 | 74 | ||
67 | add_executable(sway | 75 | add_executable(sway |
68 | ${sources} | 76 | ${sources} |
69 | ${common} | 77 | ${common} |
70 | ${proto-desktop-shell} | 78 | ${proto-desktop-shell} |
71 | ) | 79 | ) |
72 | 80 | ||
73 | target_link_libraries(sway | 81 | target_link_libraries(sway |
74 | ${WLC_LIBRARIES} | 82 | ${WLC_LIBRARIES} |
75 | ${XKBCOMMON_LIBRARIES} | 83 | ${XKBCOMMON_LIBRARIES} |
76 | ${PCRE_LIBRARIES} | 84 | ${PCRE_LIBRARIES} |
77 | ${JSONC_LIBRARIES} | 85 | ${JSONC_LIBRARIES} |
78 | ${WAYLAND_SERVER_LIBRARIES} | 86 | ${WAYLAND_SERVER_LIBRARIES} |
79 | ) | 87 | ) |
80 | 88 | ||
81 | install( | 89 | install( |
82 | TARGETS sway | 90 | TARGETS sway |
83 | RUNTIME DESTINATION bin | 91 | RUNTIME |
84 | COMPONENT runtime) | 92 | DESTINATION bin |
93 | COMPONENT runtime | ||
94 | ) | ||
85 | install( | 95 | install( |
86 | FILES "${CMAKE_CURRENT_SOURCE_DIR}/config" | 96 | FILES ${CMAKE_CURRENT_SOURCE_DIR}/config |
87 | DESTINATION "${FALLBACK_CONFIG_DIR}" | 97 | DESTINATION ${FALLBACK_CONFIG_DIR} |
88 | COMPONENT configuration) | 98 | COMPONENT configuration |
99 | ) | ||
89 | 100 | ||
90 | add_custom_target(man ALL) | 101 | add_custom_target(man ALL) |
91 | 102 | ||
92 | function (add_manpage name section) | 103 | function(add_manpage name section) |
93 | add_custom_command( | 104 | add_custom_command( |
94 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.${section}" | 105 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.${section} |
95 | COMMAND "${A2X_COMMAND}" | 106 | COMMAND ${A2X_COMMAND} |
96 | --no-xmllint | 107 | --no-xmllint |
97 | --doctype manpage | 108 | --doctype manpage |
98 | --format manpage | 109 | --format manpage |
99 | -D "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" | 110 | -D ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} |
100 | "${CMAKE_CURRENT_SOURCE_DIR}/${name}.${section}.txt" | 111 | ${CMAKE_CURRENT_SOURCE_DIR}/${name}.${section}.txt |
101 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.${section}.txt" | 112 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.${section}.txt |
102 | COMMENT "Generating manpage for ${name}.${section}") | 113 | COMMENT Generating manpage for ${name}.${section} |
103 | 114 | ) | |
104 | add_custom_target("man-${name}.${section}" | 115 | |
105 | DEPENDS | 116 | add_custom_target(man-${name}.${section} |
106 | "${CMAKE_CURRENT_BINARY_DIR}/${name}.${section}") | 117 | DEPENDS |
107 | add_dependencies(man | 118 | ${CMAKE_CURRENT_BINARY_DIR}/${name}.${section} |
108 | "man-${name}.${section}") | 119 | ) |
109 | 120 | add_dependencies(man | |
110 | install( | 121 | man-${name}.${section} |
111 | FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${name}.${section}" | 122 | ) |
112 | DESTINATION "share/man/man${section}" | 123 | |
113 | COMPONENT documentation) | 124 | install( |
114 | endfunction () | 125 | FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${name}.${section} |
126 | DESTINATION share/man/man${section} | ||
127 | COMPONENT documentation | ||
128 | ) | ||
129 | endfunction() | ||
115 | 130 | ||
116 | add_manpage(sway 1) | 131 | add_manpage(sway 1) |
117 | add_manpage(sway 5) | 132 | add_manpage(sway 5) |
@@ -119,10 +134,12 @@ add_manpage(swaymsg 1) | |||
119 | add_manpage(swaygrab 1) | 134 | add_manpage(swaygrab 1) |
120 | 135 | ||
121 | install( | 136 | install( |
122 | FILES "${CMAKE_CURRENT_SOURCE_DIR}/sway.desktop" | 137 | FILES ${CMAKE_CURRENT_SOURCE_DIR}/sway.desktop |
123 | DESTINATION share/wayland-sessions | 138 | DESTINATION share/wayland-sessions |
124 | COMPONENT data) | 139 | COMPONENT data |
140 | ) | ||
125 | install( | 141 | install( |
126 | FILES "${CMAKE_CURRENT_SOURCE_DIR}/sway-xorg.desktop" | 142 | FILES ${CMAKE_CURRENT_SOURCE_DIR}/sway-xorg.desktop |
127 | DESTINATION share/xsessions | 143 | DESTINATION share/xsessions |
128 | COMPONENT data) | 144 | COMPONENT data |
145 | ) | ||