CMake: Check for libDl, conditionally check for libXCB
This commit is contained in:
+12
-11
@@ -1,6 +1,8 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(harikoff VERSION 0.00.002 LANGUAGES CXX)
|
project(harikoff VERSION 0.00.002 LANGUAGES CXX)
|
||||||
|
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
|
||||||
# Set C++ standard
|
# Set C++ standard
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
@@ -33,23 +35,23 @@ include_directories(
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||||
)
|
)
|
||||||
|
|
||||||
# Find dependencies
|
# Find core dependencies
|
||||||
find_package(Boost 1.69.0 REQUIRED COMPONENTS system)
|
find_package(Boost 1.69.0 REQUIRED COMPONENTS system)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
|
||||||
# Flex/Bison setup
|
|
||||||
find_package(FLEX REQUIRED)
|
find_package(FLEX REQUIRED)
|
||||||
find_package(BISON REQUIRED)
|
find_package(BISON REQUIRED)
|
||||||
|
|
||||||
# XCB (optional, controlled by feature flags)
|
# Need dlopen() and dlsym()
|
||||||
option(ENABLE_XCB "Enable XCB/Xorg support" ON)
|
find_library(DL_LIBRARY NAMES dl ldl)
|
||||||
if(ENABLE_XCB)
|
if(NOT DL_LIBRARY)
|
||||||
pkg_check_modules(XCB REQUIRED xcb)
|
message(FATAL_ERROR "Dynamic linking library (libdl/libldl) not found")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add subdirectories
|
# Add core components
|
||||||
add_subdirectory(hcore)
|
add_subdirectory(hcore)
|
||||||
add_subdirectory(commonLibs)
|
add_subdirectory(commonLibs)
|
||||||
|
add_subdirectory(senseApis)
|
||||||
|
add_subdirectory(wilzorApis)
|
||||||
|
|
||||||
# Main executable
|
# Main executable
|
||||||
add_executable(harikoff main.cpp)
|
add_executable(harikoff main.cpp)
|
||||||
@@ -58,8 +60,7 @@ target_link_libraries(harikoff
|
|||||||
deviceManager
|
deviceManager
|
||||||
senseApis
|
senseApis
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
dl
|
${DL_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install rules
|
install(TARGETS harikoff DESTINATION bin)
|
||||||
install(TARGETS harikoff DESTINATION bin)
|
|
||||||
|
|||||||
@@ -1,4 +1 @@
|
|||||||
# Conditional compilation based on feature flags
|
add_subdirectory(xcbXorg)
|
||||||
if(ENABLE_XCB)
|
|
||||||
add_subdirectory(xcbXorg)
|
|
||||||
endif()
|
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
add_library(xcbXorg SHARED
|
option(ENABLE_LIB_xcbXorg "Enable XCB/Xorg Connection Manager backend lib" ON)
|
||||||
xcbXorg.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(xcbXorg PUBLIC
|
if(ENABLE_LIB_xcbXorg)
|
||||||
${XCB_INCLUDE_DIRS}
|
pkg_check_modules(XCB REQUIRED xcb)
|
||||||
)
|
if(NOT XCB_FOUND)
|
||||||
|
message(FATAL_ERROR "XCB library not found. XCB/Xorg requires the XCB dev headers and shlib.")
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(xcbXorg
|
add_library(xcbXorg SHARED
|
||||||
${XCB_LIBRARIES}
|
xcbXorg.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install rules
|
# Set config define for header generation
|
||||||
install(TARGETS xcbXorg DESTINATION lib)
|
add_compile_definitions(CONFIG_LIB_XCBXORG_ENABLED)
|
||||||
|
target_include_directories(xcbXorg PUBLIC ${XCB_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(xcbXorg ${XCB_LIBRARIES})
|
||||||
|
|
||||||
|
# Install rules
|
||||||
|
install(TARGETS xcbXorg DESTINATION lib)
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -9,11 +9,6 @@ target_include_directories(hcore PUBLIC
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
)
|
)
|
||||||
|
|
||||||
# Device manager (with Flex/Bison)
|
|
||||||
add_subdirectory(deviceManager)
|
add_subdirectory(deviceManager)
|
||||||
|
|
||||||
# Sense APIs
|
|
||||||
add_subdirectory(senseApis)
|
add_subdirectory(senseApis)
|
||||||
|
add_subdirectory(marionette)
|
||||||
# Marionette
|
|
||||||
add_subdirectory(marionette)
|
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ set(YACC_HEADER ${CMAKE_CURRENT_BINARY_DIR}/deviceSpecp.hh)
|
|||||||
# Generate Flex/Bison files using custom commands
|
# Generate Flex/Bison files using custom commands
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${LEX_OUTPUT}
|
OUTPUT ${LEX_OUTPUT}
|
||||||
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/deviceSpecl.ll ${YACC_HEADER}
|
||||||
COMMAND ${FLEX_EXECUTABLE} --header-file=${CMAKE_CURRENT_BINARY_DIR}/deviceSpecl.hh -o ${LEX_OUTPUT} ${CMAKE_CURRENT_SOURCE_DIR}/deviceSpecl.ll
|
COMMAND ${FLEX_EXECUTABLE} --header-file=${CMAKE_CURRENT_BINARY_DIR}/deviceSpecl.hh -o ${LEX_OUTPUT} ${CMAKE_CURRENT_SOURCE_DIR}/deviceSpecl.ll
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/deviceSpecl.ll
|
|
||||||
COMMENT "Generating deviceSpecl.cc from deviceSpecl.ll"
|
COMMENT "Generating deviceSpecl.cc from deviceSpecl.ll"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${YACC_OUTPUT} ${YACC_HEADER}
|
OUTPUT ${YACC_OUTPUT} ${YACC_HEADER}
|
||||||
COMMAND ${BISON_EXECUTABLE} -p deviceSpecp --header=${YACC_HEADER} -o ${YACC_OUTPUT} ${CMAKE_CURRENT_SOURCE_DIR}/deviceSpecp.yy
|
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/deviceSpecp.yy
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/deviceSpecp.yy
|
||||||
|
COMMAND ${BISON_EXECUTABLE} -p deviceSpecp --header=${YACC_HEADER} -o ${YACC_OUTPUT} ${CMAKE_CURRENT_SOURCE_DIR}/deviceSpecp.yy
|
||||||
COMMENT "Generating deviceSpecp.cc and deviceSpecp.hh from deviceSpecp.yy"
|
COMMENT "Generating deviceSpecp.cc and deviceSpecp.hh from deviceSpecp.yy"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,6 +26,4 @@ add_library(deviceManager STATIC
|
|||||||
${YACC_OUTPUT}
|
${YACC_OUTPUT}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(deviceManager PUBLIC
|
target_include_directories(deviceManager PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ add_library(marionette STATIC
|
|||||||
|
|
||||||
target_include_directories(marionette PUBLIC
|
target_include_directories(marionette PUBLIC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,6 +2,4 @@ add_library(senseApis STATIC
|
|||||||
senseApiManager.cpp
|
senseApiManager.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(senseApis PUBLIC
|
target_include_directories(senseApis PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
add_subdirectory(xcbWindow)
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# XCB/Xorg Window Attaching SenseAPI backend
|
||||||
|
cmake_dependent_option(ENABLE_SENSEAPI_xcbWindow
|
||||||
|
"Enable XCB/Xorg Window Attaching SenseAPI backend" OFF
|
||||||
|
"ENABLE_LIB_xcbXorg" OFF)
|
||||||
|
|
||||||
|
if(ENABLE_SENSEAPI_xcbWindow)
|
||||||
|
# For now, just create a placeholder library
|
||||||
|
add_library(senseApiXcbWindow STATIC
|
||||||
|
# xcbWindow.cpp would go here
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(senseApiXcbWindow
|
||||||
|
xcbXorg
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(senseApiXcbWindow PUBLIC
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set config define for header generation
|
||||||
|
add_compile_definitions(CONFIG_SENSEAPI_XCBWINDOW_ENABLED)
|
||||||
|
endif()
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
add_subdirectory(xcbMouse)
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# XCB/Xorg Mouse Wilzor API backend
|
||||||
|
cmake_dependent_option(ENABLE_WILZORAPI_xcbMouse
|
||||||
|
"Enable XCB/Xorg Mouse Wilzor API backend" OFF
|
||||||
|
"ENABLE_LIB_xcbXorg" OFF)
|
||||||
|
|
||||||
|
if(ENABLE_WILZORAPI_xcbMouse)
|
||||||
|
# For now, just create a placeholder library
|
||||||
|
add_library(wilzorApiXcbMouse STATIC
|
||||||
|
# xcbMouse.cpp would go here
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(wilzorApiXcbMouse
|
||||||
|
xcbXorg
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(wilzorApiXcbMouse PUBLIC
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set config define for header generation
|
||||||
|
add_compile_definitions(CONFIG_WILZORAPI_XCBMOUSE_ENABLED)
|
||||||
|
endif()
|
||||||
Reference in New Issue
Block a user