Examples and some fixies
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(i3ipc++)
|
||||
|
||||
OPTION(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF)
|
||||
option(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF)
|
||||
option(I3IPCpp_BUILD_EXAMPLES "Build example executables" OFF)
|
||||
|
||||
SET(BUILD_STATIC_LIBS ON)
|
||||
SET(BUILD_SHARED_LIBS OFF)
|
||||
set(BUILD_STATIC_LIBS ON)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
add_subdirectory(3rd/jsoncpp)
|
||||
UNSET(BUILD_STATIC_LIBS)
|
||||
UNSET(BUILD_SHARED_LIBS)
|
||||
@@ -31,9 +32,20 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
||||
file(GLOB_RECURSE SRC src/*.cpp)
|
||||
add_library(i3ipc++_static STATIC ${SRC})
|
||||
|
||||
SET(I3IPCpp_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
|
||||
SET(I3IPCpp_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include/ PARENT_SCOPE)
|
||||
SET(I3IPCpp_LIBRARIES i3ipc++_static ${SIGCPP_LIBRARIES} jsoncpp_lib_static PARENT_SCOPE)
|
||||
set(I3IPCpp_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(I3IPCpp_INCLUDE_DIRS
|
||||
3rd/auss/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/
|
||||
)
|
||||
set(I3IPCpp_LIBRARIES i3ipc++_static ${SIGCPP_LIBRARIES} jsoncpp_lib_static)
|
||||
|
||||
set(I3IPCpp_LIBRARY_DIRS ${I3IPCpp_LIBRARY_DIRS} PARENT_SCOPE)
|
||||
set(I3IPCpp_INCLUDE_DIRS ${I3IPCpp_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
set(I3IPCpp_LIBRARIES ${I3IPCpp_LIBRARIES} PARENT_SCOPE)
|
||||
|
||||
if(I3IPCpp_BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
if(I3IPCpp_WITH_TESTS)
|
||||
find_package(CxxTest)
|
||||
|
||||
17
examples/CMakeLists.txt
Normal file
17
examples/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(i3ipc++-examples)
|
||||
|
||||
include_directories(
|
||||
${I3IPCpp_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
link_directories(
|
||||
${I3IPCpp_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wno-unused-parameter")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -DDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
||||
|
||||
add_executable(workspaces workspaces.cpp)
|
||||
target_link_libraries(workspaces ${I3IPCpp_LIBRARIES})
|
||||
22
examples/workspaces.cpp
Normal file
22
examples/workspaces.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <i3ipc++/ipc.hpp>
|
||||
|
||||
int main() {
|
||||
i3ipc::I3Connection conn;
|
||||
for (auto& w : conn.get_workspaces()) {
|
||||
std::cout << '#' << std::hex << w.num << std::dec
|
||||
<< "\n\tName: " << w.name
|
||||
<< "\n\tVisible: " << w.visible
|
||||
<< "\n\tFocused: " << w.focused
|
||||
<< "\n\tUrgent: " << w.urgent
|
||||
<< "\n\tRect: "
|
||||
<< "\n\t\tX: " << w.rect.x
|
||||
<< "\n\t\tY: " << w.rect.y
|
||||
<< "\n\t\tWidth: " << w.rect.width
|
||||
<< "\n\t\tHeight: " << w.rect.height
|
||||
<< "\n\tOutput: " << w.output
|
||||
<< std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user