thom311 / libnl

Netlink Library Suite
GNU Lesser General Public License v2.1
419 stars 313 forks source link

CMakeLists.txt for libnl ? #323

Closed titusece closed 2 years ago

titusece commented 2 years ago

Hi, I have a CPP based application with CMakeLists.txt and would like to add support for libnl, can pls help me to provide the CMakeLists.txt for CPP code. Actually I have added my application in yocto repo and building the same.

I am able to do 'bitbake libnl' but not sure how to add support for libnl in CMakeLists.txt BTW, I can build with C code by passing Library flags.

titusece commented 2 years ago

Able to do with this.

cmake_minimum_required(VERSION 3.1)
project(yamlparselibnl)

add_subdirectory(third-party/yaml-cpp)

include_directories(/usr/include/libnl3/ include/)

add_executable(
    yaml-libnl
    src/main.cpp
)

target_link_libraries(
    yaml-libnl
    PRIVATE
    nl-3
    nl-genl-3
    yaml-cpp
)

install(TARGETS yaml-libnl DESTINATION bin)