Skip to content

Commit

Permalink
Fixed build issues on Ubuntu 18.04 LTS.
Browse files Browse the repository at this point in the history
-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 <[email protected]>
  • Loading branch information
drebbe-intrepid committed Jul 11, 2019
1 parent fe5500a commit d97cd17
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}")
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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)
add_subdirectory(${PROJECT_SOURCE_DIR}/example)
3 changes: 2 additions & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
include_directories(basic "../")
target_link_libraries(basic neoradio2)

0 comments on commit d97cd17

Please sign in to comment.