diff --git a/host/libraries/libbladeRF/CMakeLists.txt b/host/libraries/libbladeRF/CMakeLists.txt index dbc62b601..2ba589195 100644 --- a/host/libraries/libbladeRF/CMakeLists.txt +++ b/host/libraries/libbladeRF/CMakeLists.txt @@ -9,6 +9,9 @@ project(libbladeRF C) set(VERSION_INFO_MAJOR 2) set(VERSION_INFO_MINOR 5) set(VERSION_INFO_PATCH 0) +set(LIBBLADERF_VERSION + ${VERSION_INFO_MAJOR}.${VERSION_INFO_MINOR}.${VERSION_INFO_PATCH}) + if(NOT DEFINED VERSION_INFO_EXTRA) set(VERSION_INFO_EXTRA "git") @@ -522,6 +525,26 @@ install(TARGETS libbladerf_shared RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} # .dll ) +# ############################################################################### +# CMake Config Files +# ############################################################################### +configure_file( + ${PROJECT_SOURCE_DIR}/cmake/libbladeRFConfigVersion.cmake.in + ${PROJECT_BINARY_DIR}/bladeRFConfigVersion.cmake @ONLY) + +configure_file( + ${PROJECT_SOURCE_DIR}/cmake/libbladeRFConfig.cmake.in + ${PROJECT_BINARY_DIR}/bladeRFConfig.cmake @ONLY) + +set(cmake_files + ${PROJECT_BINARY_DIR}/bladeRFConfig.cmake + ${PROJECT_BINARY_DIR}/bladeRFConfigVersion.cmake) + +if(UNIX) + install(FILES ${cmake_files} DESTINATION share/cmake/bladeRF) +elseif(WIN32) + install(FILES ${cmake_files} DESTINATION cmake) +endif() ################################################################################ # Informational output diff --git a/host/libraries/libbladeRF/cmake/libbladeRFConfig.cmake.in b/host/libraries/libbladeRF/cmake/libbladeRFConfig.cmake.in new file mode 100644 index 000000000..6af1ca1c0 --- /dev/null +++ b/host/libraries/libbladeRF/cmake/libbladeRFConfig.cmake.in @@ -0,0 +1,53 @@ +if(DEFINED INCLUDED_LIBBLADERF_CONFIG_CMAKE) + return() +endif() + +set(INCLUDED_LIBBLADERF_CONFIG_CMAKE TRUE) + +# ####################################################################### +# libbladeRFConfig - cmake project configuration +# +# The following will be set after find_package(libbladeRF CONFIG): +# libbladeRF_LIBRARIES - development libraries +# libbladeRF_INCLUDE_DIRS - development includes +# ####################################################################### + +# ####################################################################### +# # installation root +# ####################################################################### +if(UNIX) + get_filename_component(LIBBLADERF_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) +elseif(WIN32) + get_filename_component(LIBBLADERF_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) +endif() + +# ####################################################################### +# # locate the library +# ####################################################################### +find_library( + LIBBLADERF_LIBRARY bladeRF + PATHS ${LIBBLADERF_ROOT}/lib${LIB_SUFFIX} + PATH_SUFFIXES ${CMAKE_LIBRARY_ARCHITECTURE} + NO_DEFAULT_PATH +) + +if(NOT LIBBLADERF_LIBRARY) + message(FATAL_ERROR "cannot find libbladeRF library in ${LIBBLADERF_ROOT}/lib${LIB_SUFFIX}") +endif() + +set(libbladeRF_LIBRARIES ${LIBBLADERF_LIBRARY}) + +# ####################################################################### +# # locate the includes +# ####################################################################### +find_path( + LIBBLADERF_INCLUDE_DIR libbladeRF.h + PATHS ${LIBBLADERF_ROOT}/include + NO_DEFAULT_PATH +) + +if(NOT LIBBLADERF_INCLUDE_DIR) + message(FATAL_ERROR "cannot find libbladeRF includes in ${LIBBLADERF_ROOT}/include/libbladeRF") +endif() + +set(libbladeRF_INCLUDE_DIRS ${LIBBLADERF_INCLUDE_DIR}) diff --git a/host/libraries/libbladeRF/cmake/libbladeRFConfigVersion.cmake.in b/host/libraries/libbladeRF/cmake/libbladeRFConfigVersion.cmake.in new file mode 100644 index 000000000..992a1db71 --- /dev/null +++ b/host/libraries/libbladeRF/cmake/libbladeRFConfigVersion.cmake.in @@ -0,0 +1,11 @@ +set(PACKAGE_VERSION "@LIBBLADERF_VERSION@") + +# Check whether the requested PACKAGE_FIND_VERSION is compatible +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif()