From a38c20d4401ac22d8310e1af494d53b35ee01be0 Mon Sep 17 00:00:00 2001 From: TitanMKD Date: Sat, 18 May 2013 10:25:01 +0200 Subject: [PATCH] Fixed hackrf-tools CMake scripts to build them out of tree. --- host/hackrf-tools/CMakeLists.txt | 1 - host/hackrf-tools/FindLIBHACKRF.cmake | 29 ++++++++++++++++---- host/hackrf-tools/src/CMakeLists.txt | 38 +++++++++++++-------------- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/host/hackrf-tools/CMakeLists.txt b/host/hackrf-tools/CMakeLists.txt index 130d2369..229eccfa 100644 --- a/host/hackrf-tools/CMakeLists.txt +++ b/host/hackrf-tools/CMakeLists.txt @@ -40,6 +40,5 @@ include_directories(${LIBUSB_INCLUDE_DIR}) find_package(LIBHACKRF REQUIRED) include_directories(${LIBHACKRF_INCLUDE_DIR}) -link_directories(${LIBHACKRF_LIBRARIES} ${CMAKE_SOURCE_DIR}/../libhackrf/src) add_subdirectory(src) diff --git a/host/hackrf-tools/FindLIBHACKRF.cmake b/host/hackrf-tools/FindLIBHACKRF.cmake index 469e6ec7..6a4a919c 100644 --- a/host/hackrf-tools/FindLIBHACKRF.cmake +++ b/host/hackrf-tools/FindLIBHACKRF.cmake @@ -19,14 +19,33 @@ else (LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES) # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls find_package(PkgConfig) - pkg_check_modules(PC_LIBHACKRF libhackrf) + pkg_check_modules(PC_LIBHACKRF QUIET libhackrf) ENDIF(NOT WIN32) - FIND_PATH(LIBHACKRF_INCLUDE_DIR hackrf.h - PATHS ${PC_LIBHACKRF_INCLUDEDIR} ${PC_LIBHACKRF_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/../libhackrf/src) + FIND_PATH(LIBHACKRF_INCLUDE_DIR + NAMES hackrf.h + HINTS $ENV{LIBHACKRF_DIR}/include ${PC_LIBHACKRF_INCLUDEDIR} + PATHS /usr/local/include/libhackrf /usr/local/include + /usr/include ${CMAKE_SOURCE_DIR}/../libhackrf/src + /opt/local/include/libhackrf + ${LIBHACKRF_INCLUDE_DIR} + ) - FIND_LIBRARY(LIBHACKRF_LIBRARIES NAMES hackrf - PATHS ${PC_LIBHACKRF_LIBDIR} ${PC_LIBHACKRF_LIBRARY_DIRS} ${CMAKE_SOURCE_DIR}/../libhackrf/src) + set(libhackrf_library_names hackrf) + + FIND_LIBRARY(LIBHACKRF_LIBRARIES + NAMES ${libhackrf_library_names} + HINTS $ENV{LIBHACKRF_DIR}/lib ${PC_LIBHACKRF_LIBDIR} + PATHS /usr/local/lib /usr/lib /opt/local/lib ${PC_LIBHACKRF_LIBDIR} ${PC_LIBHACKRF_LIBRARY_DIRS} ${CMAKE_SOURCE_DIR}/../libhackrf/src + ) + + if(LIBHACKRF_INCLUDE_DIR) + set(CMAKE_REQUIRED_INCLUDES ${LIBHACKRF_INCLUDE_DIR}) + endif() + + if(LIBHACKRF_LIBRARIES) + set(CMAKE_REQUIRED_LIBRARIES ${LIBHACKRF_LIBRARIES}) + endif() include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBHACKRF DEFAULT_MSG LIBHACKRF_LIBRARIES LIBHACKRF_INCLUDE_DIR) diff --git a/host/hackrf-tools/src/CMakeLists.txt b/host/hackrf-tools/src/CMakeLists.txt index 097a8ad2..ff1f588a 100644 --- a/host/hackrf-tools/src/CMakeLists.txt +++ b/host/hackrf-tools/src/CMakeLists.txt @@ -21,24 +21,22 @@ # Based heavily upon the libftdi cmake setup. -option(EXAMPLES "Build example programs" ON) +add_executable(hackrf_max2837 hackrf_max2837.c) +add_executable(hackrf_si5351c hackrf_si5351c.c) +add_executable(hackrf_transfer hackrf_transfer.c) +add_executable(hackrf_rffc5071 hackrf_rffc5071.c) +add_executable(hackrf_spiflash hackrf_spiflash.c) +add_executable(hackrf_cpldjtag hackrf_cpldjtag.c) +add_executable(hackrf_info hackrf_info.c) + +include_directories(${LIBHACKRF_INCLUDE_DIR}) + +target_link_libraries(hackrf_max2837 ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_si5351c ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_transfer ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_rffc5071 ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_spiflash ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_cpldjtag ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_info ${LIBHACKRF_LIBRARIES}) + -IF( EXAMPLES ) - add_executable(hackrf_max2837 hackrf_max2837.c) - add_executable(hackrf_si5351c hackrf_si5351c.c) - add_executable(hackrf_transfer hackrf_transfer.c) - add_executable(hackrf_rffc5071 hackrf_rffc5071.c) - add_executable(hackrf_spiflash hackrf_spiflash.c) - add_executable(hackrf_cpldjtag hackrf_cpldjtag.c) - add_executable(hackrf_info hackrf_info.c) - - target_link_libraries(hackrf_max2837 hackrf) - target_link_libraries(hackrf_si5351c hackrf) - target_link_libraries(hackrf_transfer hackrf) - target_link_libraries(hackrf_rffc5071 hackrf) - target_link_libraries(hackrf_spiflash hackrf) - target_link_libraries(hackrf_cpldjtag hackrf) - target_link_libraries(hackrf_info hackrf) - - include_directories(BEFORE ${CMAKE_SOURCE_DIR}/../libhackrf/src) -endif(EXAMPLES)