Skip to content

Commit

Permalink
adrv9002 plugin: updated cmake for static libraries
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Popa <[email protected]>
  • Loading branch information
andrei47w committed Aug 2, 2023
1 parent 7b22d60 commit 4c1274a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
43 changes: 33 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,39 @@ if ((NOT LIBAD9166_LIBRARIES) AND (NOT LIBAD9166_INCLUDE_DIRS))
set(LIBAD9166_INCLUDE_DIRS "")
endif()

find_library(LIBADRV9001_LIBRARIES adrv9001-iio NO_CACHE)
find_path(LIBADRV9001_INCLUDE_DIRS adrv9002_iio.h)
if ((NOT LIBADRV9001_LIBRARIES) OR (NOT LIBADRV9001_INCLUDE_DIRS))
set(LIBADRV9001_LIBRARIES "")
set(LIBADRV9001_INCLUDE_DIRS "")
set(LIBADRV9001_FOUND FALSE)
find_library(LIBADRV9001_IIO_LIBRARIES adrv9001-iio NO_CACHE)
find_path(LIBADRV9001_IIO_INCLUDE_DIRS adrv9002_iio.h)

if ((NOT LIBADRV9001_IIO_LIBRARIES) OR (NOT LIBADRV9001_IIO_INCLUDE_DIRS))
set(LIBADRV9001_IIO_LIBRARIES "")
set(LIBADRV9001_IIO_INCLUDE_DIRS "")
set(LIBADRV9001_FOUND FALSE)
else()
set(LIBADRV9001_FOUND TRUE)
set(ENABLE_IIO TRUE)
find_library(LIBADRV9001_FILTER_LIBRARIES adrv9001-filter-designer NO_CACHE)
find_library(LIBADRV9001_PROFILE_GEN_LIBRARIES adrv9001-profile-gen NO_CACHE)
find_library(LIBADRV9001_STREAM_GEN_LIBRARIES adrv9001-stream-gen NO_CACHE)
set(LIBADRV9001_FOUND TRUE)
set(ENABLE_IIO TRUE)

add_library(libadrv9002_iio STATIC IMPORTED)
set_target_properties(libadrv9002_iio PROPERTIES IMPORTED_LOCATION ${LIBADRV9001_IIO_LIBRARIES})
set_target_properties(libadrv9002_iio PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${LIBADRV9001_IIO_INCLUDE_DIRS})

add_library(libadrv9002_filter STATIC IMPORTED)
set_target_properties(libadrv9002_filter PROPERTIES IMPORTED_LOCATION ${LIBADRV9001_FILTER_LIBRARIES})

add_library(libadrv9002_profile_gen STATIC IMPORTED)
set_target_properties(libadrv9002_profile_gen PROPERTIES IMPORTED_LOCATION ${LIBADRV9001_PROFILE_GEN_LIBRARIES})

add_library(libadrv9002_stream_gen STATIC IMPORTED)
set_target_properties(libadrv9002_stream_gen PROPERTIES IMPORTED_LOCATION ${LIBADRV9001_STREAM_GEN_LIBRARIES})

add_library(libadrv9002 INTERFACE)

target_link_libraries(libadrv9002_iio INTERFACE stdc++)
target_link_libraries(libadrv9002_stream_gen INTERFACE stdc++)
target_link_libraries(libadrv9002_profile_gen INTERFACE stdc++ libadrv9002_filter)
target_link_libraries(libadrv9002 INTERFACE libadrv9002_iio libadrv9002_filter libadrv9002_profile_gen libadrv9002_stream_gen)
endif()

find_library(LIBSERIALPORT_LIBRARIES serialport)
Expand Down Expand Up @@ -177,7 +201,7 @@ set(LIBOSC_LIBS
${MATIO_LIBRARIES}
${LIBAD9361_LIBRARIES}
${LIBAD9166_LIBRARIES}
${LIBADRV9001_LIBRARIES}
libadrv9002
dl
)

Expand Down Expand Up @@ -240,7 +264,6 @@ target_include_directories(osc PRIVATE
${HDF5_INCLUDE_DIRS}
${LIBAD9361_INCLUDE_DIRS}
${LIBAD9166_INCLUDE_DIRS}
${LIBADRV9001_INCLUDE_DIRS}
)
target_link_libraries(osc PRIVATE ${LIBOSC_LIBS})
set_target_properties(osc PROPERTIES
Expand Down
11 changes: 6 additions & 5 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(EXTRA_WIN_LIBRARIES winpthread)
endif()

if("${LIBADRV9001_LIBRARIES}" STREQUAL "")
message(WARNING "libadrv9001-iio not found. The following plugins will not be installed: ${LIBADRV9001_PLUGINS}")
list(REMOVE_ITEM PLUGINS ${LIBADRV9002_PLUGINS})
if(NOT LIBADRV9001_FOUND)
message(WARNING "libadrv9001-iio not found. The ${LIBADRV9001_PLUGINS} plugin will not contain profile generation")
endif()

if("${LIBAD9166_LIBRARIES}" STREQUAL "")
Expand All @@ -96,15 +95,13 @@ foreach(plugin ${PLUGINS})
${LIBXML2_INCLUDE_DIRS}
${LIBAD9361_INCLUDE_DIRS}
${LIBAD9166_INCLUDE_DIRS}
${LIBADRV9001_INCLUDE_DIRS}
)
target_link_libraries(${plugin} PRIVATE
${GTK_LIBRARIES}
${LIBIIO_LIBRARIES}
${LIBXML2_LIBRARIES}
${LIBAD9361_LIBRARIES}
${LIBAD9166_LIBRARIES}
${LIBADRV9001_LIBRARIES}
${EXTRA_WIN_LIBRARIES}
osc
m
Expand All @@ -116,6 +113,10 @@ foreach(plugin ${PLUGINS})

endforeach()

if(LIBADRV9001_FOUND)
target_link_libraries(adrv9002 PRIVATE libadrv9002)
endif()

install(TARGETS ${PLUGINS}
LIBRARY DESTINATION ${PLIB_DEST}
RUNTIME DESTINATION ${PLIB_DEST}
Expand Down

0 comments on commit 4c1274a

Please sign in to comment.