CMake: Check for libDl, conditionally check for libXCB
This commit is contained in:
+11
-10
@@ -1,6 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(harikoff VERSION 0.00.002 LANGUAGES CXX)
|
||||
|
||||
include(CMakeDependentOption)
|
||||
|
||||
# Set C++ standard
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
@@ -33,23 +35,23 @@ include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
)
|
||||
|
||||
# Find dependencies
|
||||
# Find core dependencies
|
||||
find_package(Boost 1.69.0 REQUIRED COMPONENTS system)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
# Flex/Bison setup
|
||||
find_package(FLEX REQUIRED)
|
||||
find_package(BISON REQUIRED)
|
||||
|
||||
# XCB (optional, controlled by feature flags)
|
||||
option(ENABLE_XCB "Enable XCB/Xorg support" ON)
|
||||
if(ENABLE_XCB)
|
||||
pkg_check_modules(XCB REQUIRED xcb)
|
||||
# Need dlopen() and dlsym()
|
||||
find_library(DL_LIBRARY NAMES dl ldl)
|
||||
if(NOT DL_LIBRARY)
|
||||
message(FATAL_ERROR "Dynamic linking library (libdl/libldl) not found")
|
||||
endif()
|
||||
|
||||
# Add subdirectories
|
||||
# Add core components
|
||||
add_subdirectory(hcore)
|
||||
add_subdirectory(commonLibs)
|
||||
add_subdirectory(senseApis)
|
||||
add_subdirectory(wilzorApis)
|
||||
|
||||
# Main executable
|
||||
add_executable(harikoff main.cpp)
|
||||
@@ -58,8 +60,7 @@ target_link_libraries(harikoff
|
||||
deviceManager
|
||||
senseApis
|
||||
${Boost_LIBRARIES}
|
||||
dl
|
||||
${DL_LIBRARY}
|
||||
)
|
||||
|
||||
# Install rules
|
||||
install(TARGETS harikoff DESTINATION bin)
|
||||
@@ -1,4 +1 @@
|
||||
# Conditional compilation based on feature flags
|
||||
if(ENABLE_XCB)
|
||||
add_subdirectory(xcbXorg)
|
||||
endif()
|
||||
add_subdirectory(xcbXorg)
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
add_library(xcbXorg SHARED
|
||||
option(ENABLE_LIB_xcbXorg "Enable XCB/Xorg Connection Manager backend lib" ON)
|
||||
|
||||
if(ENABLE_LIB_xcbXorg)
|
||||
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()
|
||||
|
||||
add_library(xcbXorg SHARED
|
||||
xcbXorg.cpp
|
||||
)
|
||||
)
|
||||
|
||||
target_include_directories(xcbXorg PUBLIC
|
||||
${XCB_INCLUDE_DIRS}
|
||||
)
|
||||
# Set config define for header generation
|
||||
add_compile_definitions(CONFIG_LIB_XCBXORG_ENABLED)
|
||||
target_include_directories(xcbXorg PUBLIC ${XCB_INCLUDE_DIRS})
|
||||
target_link_libraries(xcbXorg ${XCB_LIBRARIES})
|
||||
|
||||
target_link_libraries(xcbXorg
|
||||
${XCB_LIBRARIES}
|
||||
)
|
||||
|
||||
# Install rules
|
||||
install(TARGETS xcbXorg DESTINATION lib)
|
||||
# Install rules
|
||||
install(TARGETS xcbXorg DESTINATION lib)
|
||||
endif()
|
||||
|
||||
@@ -9,11 +9,6 @@ target_include_directories(hcore PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
# Device manager (with Flex/Bison)
|
||||
add_subdirectory(deviceManager)
|
||||
|
||||
# Sense APIs
|
||||
add_subdirectory(senseApis)
|
||||
|
||||
# Marionette
|
||||
add_subdirectory(marionette)
|
||||
@@ -6,15 +6,15 @@ set(YACC_HEADER ${CMAKE_CURRENT_BINARY_DIR}/deviceSpecp.hh)
|
||||
# Generate Flex/Bison files using custom commands
|
||||
add_custom_command(
|
||||
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
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/deviceSpecl.ll
|
||||
COMMENT "Generating deviceSpecl.cc from deviceSpecl.ll"
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
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
|
||||
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"
|
||||
)
|
||||
|
||||
@@ -26,6 +26,4 @@ add_library(deviceManager STATIC
|
||||
${YACC_OUTPUT}
|
||||
)
|
||||
|
||||
target_include_directories(deviceManager PUBLIC
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
target_include_directories(deviceManager PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@@ -2,6 +2,4 @@ add_library(senseApis STATIC
|
||||
senseApiManager.cpp
|
||||
)
|
||||
|
||||
target_include_directories(senseApis PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
target_include_directories(senseApis PUBLIC ${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