Fixed hackrf-tools CMake scripts to build them out of tree.

This commit is contained in:
TitanMKD
2013-05-18 10:25:01 +02:00
parent cc74842b78
commit a38c20d440
3 changed files with 42 additions and 26 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)