Skip to content

Commit

Permalink
cmake: simplify integration of Cohda LLC API
Browse files Browse the repository at this point in the history
  • Loading branch information
riebl committed Jun 1, 2023
1 parent bf7a588 commit 40bb4a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ endforeach()
include(CompatBoostTargets)
find_package(CryptoPP 5.6.1 REQUIRED)
find_package(GeographicLib 1.37 REQUIRED)
find_package(Cohda MODULE QUIET)

option(VANETZA_WITH_OPENSSL "Enable OpenSSL extensions" OFF)
if (VANETZA_WITH_OPENSSL)
Expand Down
21 changes: 18 additions & 3 deletions tools/socktap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,26 @@ add_executable(socktap
target_link_libraries(socktap PUBLIC Boost::system Boost::program_options Threads::Threads vanetza)
install(TARGETS socktap EXPORT ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})

option(SOCKTAP_WITH_COHDA_LLC "Use Cohda LLC API for socktap" ${COHDA_FOUND})
find_file(COHDA_LLC_API_HEADER llc-api.c
PATHS "/home/duser"
PATH_SUFFIXES "cohda/kernel/include/linux/cohda/llc"
CMAKE_FIND_ROOT_PATH_BOTH
DOC "Cohda LLC API header")
mark_as_advanced(COHDA_LLC_API_HEADER)
if(COHDA_LLC_API_HEADER)
set(COHDA_LLC_API_FOUND ON)
else()
set(COHDA_LLC_API_FOUND OFF)
endif()

option(SOCKTAP_WITH_COHDA_LLC "Enable Cohda LLC link layer for socktap" ${COHDA_LLC_API_FOUND})
if(SOCKTAP_WITH_COHDA_LLC)
find_package(Cohda MODULE REQUIRED)
if(NOT COHDA_LLC_API_HEADER)
message(SEND_ERROR "Cohda LLC API header [llc-api.h] is missing")
endif()
get_filename_component(COHDA_LLC_INCLUDE_DIR ${COHDA_LLC_API_HEADER} DIRECTORY)
target_compile_definitions(socktap PUBLIC "SOCKTAP_WITH_COHDA_LLC")
target_include_directories(socktap PUBLIC ${COHDA_INCLUDE_DIRS})
target_include_directories(socktap PUBLIC ${COHDA_LLC_INCLUDE_DIR})
target_sources(socktap PRIVATE cohda.cpp cohda_link.cpp)
endif()

Expand Down

0 comments on commit 40bb4a2

Please sign in to comment.