From d97cd171f19588b3a3c9f287ba2d4840067b4aae Mon Sep 17 00:00:00 2001 From: David Rebbe Date: Wed, 10 Jul 2019 23:16:14 -0400 Subject: [PATCH] Fixed build issues on Ubuntu 18.04 LTS. -This should fix Issue #7. -Added Check to make sure libudev is found. -Added check to only link against udev if under linux. -Fixed a build issue with the example not building. -Added option to make sure compiler uses c++14 standard minimum. -Added hid.c include for mac as prelimiary fix for issue #5. Signed-off-by: David Rebbe --- CMakeLists.txt | 18 ++++++++++++++++-- example/CMakeLists.txt | 3 ++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d4a83b2..731931b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,13 @@ cmake_minimum_required(VERSION 3.9) +include(GNUInstallDirs) add_definitions(-DLIBNEORADIO2_EXPORTS) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + file(READ "version.txt" ver) string(REGEX MATCH "VERSION_MAJOR ([0-9]*)" _ "${ver}") @@ -33,8 +38,15 @@ add_library(neoradio2 SHARED if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") target_sources(neoradio2 PRIVATE ${PROJECT_SOURCE_DIR}/hidapi/linux/hid.c) + find_library(UDEV_LIB_PATH udev) + message("UDEV LIBRARY PATH: ${UDEV_LIB_PATH}") + if(NOT UDEV_LIB_PATH) + message(FATAL_ERROR "udev not found, try running 'sudo apt install libudev-dev'") + endif() elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows") target_sources(neoradio2 PRIVATE ${PROJECT_SOURCE_DIR}/hidapi/windows/hid.c) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + target_sources(neoradio2 PRIVATE ${PROJECT_SOURCE_DIR}/hidapi/mac/hid.c) endif() set_target_properties(neoradio2 PROPERTIES @@ -45,7 +57,9 @@ set_target_properties(neoradio2 PROPERTIES set_property(TARGET neoradio2 PROPERTY PUBLIC_HEADER libneoradio2.h libneoradio2common.h radio2_frames.h) -target_link_libraries(neoradio2 PRIVATE udev) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + target_link_libraries(neoradio2 PRIVATE udev) +endif() configure_file(libneoradio2.pc.in libneoradio2.pc @ONLY) @@ -55,4 +69,4 @@ install(TARGETS neoradio2 install(FILES ${CMAKE_BINARY_DIR}/libneoradio2.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) -add_subdirectory(${PROJECT_SOURCE_DIR}/example) \ No newline at end of file +add_subdirectory(${PROJECT_SOURCE_DIR}/example) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index a90cce8..5fb9215 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -2,4 +2,5 @@ cmake_minimum_required(VERSION 3.9) add_executable(basic basic.c) include_directories(basic "/usr/local/include") -target_link_libraries(basic neoradio2) \ No newline at end of file +include_directories(basic "../") +target_link_libraries(basic neoradio2)