Skip to content

Commit 1a9aacd

Browse files
committed
Examples and some fixies
1 parent e8a1a97 commit 1a9aacd

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

CMakeLists.txt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
cmake_minimum_required(VERSION 3.0)
22
project(i3ipc++)
33

4-
OPTION(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF)
4+
option(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF)
5+
option(I3IPCpp_BUILD_EXAMPLES "Build example executables" OFF)
56

6-
SET(BUILD_STATIC_LIBS ON)
7-
SET(BUILD_SHARED_LIBS OFF)
7+
set(BUILD_STATIC_LIBS ON)
8+
set(BUILD_SHARED_LIBS OFF)
89
add_subdirectory(3rd/jsoncpp)
910
UNSET(BUILD_STATIC_LIBS)
1011
UNSET(BUILD_SHARED_LIBS)
@@ -31,9 +32,20 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
3132
file(GLOB_RECURSE SRC src/*.cpp)
3233
add_library(i3ipc++_static STATIC ${SRC})
3334

34-
SET(I3IPCpp_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
35-
SET(I3IPCpp_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include/ PARENT_SCOPE)
36-
SET(I3IPCpp_LIBRARIES i3ipc++_static ${SIGCPP_LIBRARIES} jsoncpp_lib_static PARENT_SCOPE)
35+
set(I3IPCpp_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR})
36+
set(I3IPCpp_INCLUDE_DIRS
37+
3rd/auss/include
38+
${CMAKE_CURRENT_SOURCE_DIR}/include/
39+
)
40+
set(I3IPCpp_LIBRARIES i3ipc++_static ${SIGCPP_LIBRARIES} jsoncpp_lib_static)
41+
42+
set(I3IPCpp_LIBRARY_DIRS ${I3IPCpp_LIBRARY_DIRS} PARENT_SCOPE)
43+
set(I3IPCpp_INCLUDE_DIRS ${I3IPCpp_INCLUDE_DIRS} PARENT_SCOPE)
44+
set(I3IPCpp_LIBRARIES ${I3IPCpp_LIBRARIES} PARENT_SCOPE)
45+
46+
if(I3IPCpp_BUILD_EXAMPLES)
47+
add_subdirectory(examples)
48+
endif()
3749

3850
if(I3IPCpp_WITH_TESTS)
3951
find_package(CxxTest)

examples/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cmake_minimum_required(VERSION 3.0)
2+
project(i3ipc++-examples)
3+
4+
include_directories(
5+
${I3IPCpp_INCLUDE_DIRS}
6+
)
7+
8+
link_directories(
9+
${I3IPCpp_LIBRARY_DIRS}
10+
)
11+
12+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wno-unused-parameter")
13+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -DDEBUG")
14+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
15+
16+
add_executable(workspaces workspaces.cpp)
17+
target_link_libraries(workspaces ${I3IPCpp_LIBRARIES})

examples/workspaces.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <iostream>
2+
3+
#include <i3ipc++/ipc.hpp>
4+
5+
int main() {
6+
i3ipc::I3Connection conn;
7+
for (auto& w : conn.get_workspaces()) {
8+
std::cout << '#' << std::hex << w.num << std::dec
9+
<< "\n\tName: " << w.name
10+
<< "\n\tVisible: " << w.visible
11+
<< "\n\tFocused: " << w.focused
12+
<< "\n\tUrgent: " << w.urgent
13+
<< "\n\tRect: "
14+
<< "\n\t\tX: " << w.rect.x
15+
<< "\n\t\tY: " << w.rect.y
16+
<< "\n\t\tWidth: " << w.rect.width
17+
<< "\n\t\tHeight: " << w.rect.height
18+
<< "\n\tOutput: " << w.output
19+
<< std::endl;
20+
}
21+
return 0;
22+
}

0 commit comments

Comments
 (0)