Commit 1436e5dbd795d602039f80eeddeee254e3e9e060
1 parent
b7a65b8a
Fixes macOS build on some systems: Fixes #63
Signed-off-by: David Graeff <david.graeff@web.de>
Showing
3 changed files
with
79 additions
and
22 deletions
cmake/FindFFTW.cmake
| 1 | -# - Find FFTW | |
| 2 | -# Find the native FFTW includes and library | |
| 1 | +# - Find the FFTW library | |
| 3 | 2 | # |
| 4 | -# FFTW_INCLUDES - where to find fftw3.h | |
| 5 | -# FFTW_LIBRARIES - List of libraries when using FFTW. | |
| 6 | -# FFTW_FOUND - True if FFTW found. | |
| 3 | +# Usage: | |
| 4 | +# find_package(FFTW [REQUIRED] [QUIET] ) | |
| 5 | +# | |
| 6 | +# It sets the following variables: | |
| 7 | +# FFTW_FOUND ... true if fftw is found on the system | |
| 8 | +# FFTW_LIBRARIES ... full path to fftw library | |
| 9 | +# FFTW_INCLUDES ... fftw include directory | |
| 10 | +# | |
| 11 | +# The following variables will be checked by the function | |
| 12 | +# FFTW_USE_STATIC_LIBS ... if true, only static libraries are found | |
| 13 | +# FFTW_LIBRARIES ... fftw library to use | |
| 14 | +# FFTW_INCLUDE_DIRS ... fftw include directory | |
| 15 | +# | |
| 16 | + | |
| 17 | + | |
| 18 | +if (FFTW_LIBRARIES AND FFTW_INCLUDE_DIRS) | |
| 19 | + # in cache already | |
| 20 | + set(FFTW_FOUND TRUE) | |
| 21 | +else (FFTW_LIBRARIES AND FFTW_INCLUDE_DIRS) | |
| 22 | + | |
| 23 | +if (FFTW_USE_STATIC_LIBS AND NOT MSVC) | |
| 24 | + set (LIBFFTW_LIB_SUFFIX ".a" CACHE INTERNAL "libfftw3 library name suffix passed to find_library") | |
| 25 | +else (FFTW_USE_STATIC_LIBS AND NOT MSVC) | |
| 26 | + set (LIBFFTW_LIB_SUFFIX ".dylib" CACHE INTERNAL "libfftw3 library name suffix passed to find_library") | |
| 27 | +endif (FFTW_USE_STATIC_LIBS AND NOT MSVC) | |
| 28 | + | |
| 29 | + find_path(FFTW_INCLUDE_DIR | |
| 30 | + NAMES | |
| 31 | + fftw3.h | |
| 32 | + PATHS | |
| 33 | + /usr/include | |
| 34 | + /usr/local/include | |
| 35 | + /opt/local/include | |
| 36 | + /sw/include | |
| 37 | + ) | |
| 38 | + | |
| 39 | + find_library(FFTW_LIBRARY | |
| 40 | + NAMES | |
| 41 | + fftw3 | |
| 42 | + libfftw3${LIBFFTW_LIB_SUFFIX} | |
| 43 | + PATHS | |
| 44 | + /usr/lib | |
| 45 | + /usr/local/lib | |
| 46 | + /opt/local/lib | |
| 47 | + /sw/lib | |
| 48 | + ) | |
| 7 | 49 | |
| 8 | -if (FFTW_INCLUDES) | |
| 9 | - # Already in cache, be silent | |
| 10 | - set (FFTW_FIND_QUIETLY TRUE) | |
| 11 | -endif (FFTW_INCLUDES) | |
| 50 | + set(FFTW_INCLUDE_DIRS | |
| 51 | + ${FFTW_INCLUDE_DIR} | |
| 52 | + ) | |
| 53 | + set(FFTW_LIBRARIES | |
| 54 | + ${FFTW_LIBRARY} | |
| 55 | +) | |
| 12 | 56 | |
| 13 | -find_path (FFTW_INCLUDES fftw3.h) | |
| 57 | + if (FFTW_INCLUDE_DIRS AND FFTW_LIBRARIES) | |
| 58 | + set(FFTW_FOUND TRUE) | |
| 59 | + endif (FFTW_INCLUDE_DIRS AND FFTW_LIBRARIES) | |
| 14 | 60 | |
| 15 | -find_library (FFTW_LIBRARIES NAMES fftw3) | |
| 61 | + if (FFTW_FOUND) | |
| 62 | + if (NOT FFTW_FIND_QUIETLY) | |
| 63 | + message(STATUS "Found libfftw3:") | |
| 64 | + message(STATUS " - Includes: ${FFTW_INCLUDE_DIRS}") | |
| 65 | + message(STATUS " - Libraries: ${FFTW_LIBRARIES}") | |
| 66 | + endif (NOT FFTW_FIND_QUIETLY) | |
| 67 | + else (FFTW_FOUND) | |
| 68 | + if (FFTW_FIND_REQUIRED) | |
| 69 | + message(FATAL_ERROR "Could not find libfftw3") | |
| 70 | + endif (FFTW_FIND_REQUIRED) | |
| 71 | + endif (FFTW_FOUND) | |
| 16 | 72 | |
| 17 | -# handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if | |
| 18 | -# all listed variables are TRUE | |
| 19 | -include (FindPackageHandleStandardArgs) | |
| 20 | -find_package_handle_standard_args (FFTW DEFAULT_MSG FFTW_LIBRARIES FFTW_INCLUDES) | |
| 73 | + # show the FFTW_INCLUDE_DIRS and FFTW_LIBRARIES variables only in the advanced view | |
| 74 | + mark_as_advanced(FFTW_INCLUDE_DIRS FFTW_LIBRARIES) | |
| 21 | 75 | |
| 22 | -mark_as_advanced (FFTW_LIBRARIES FFTW_INCLUDES) | |
| 23 | 76 | \ No newline at end of file |
| 77 | +endif (FFTW_LIBRARIES AND FFTW_INCLUDE_DIRS) | ... | ... |
cmake/Findlibusb.cmake
| ... | ... | @@ -5,6 +5,7 @@ find_path(LIBUSB_INCLUDE_DIR |
| 5 | 5 | /usr/local/include |
| 6 | 6 | /opt/local/include |
| 7 | 7 | /usr/include |
| 8 | + /sw/include | |
| 8 | 9 | PATH_SUFFIXES |
| 9 | 10 | libusb-1.0 |
| 10 | 11 | ) |
| ... | ... | @@ -25,6 +26,7 @@ find_library(LIBUSB_LIBRARY |
| 25 | 26 | /opt/local/lib |
| 26 | 27 | /usr/lib |
| 27 | 28 | /lib64/ |
| 29 | + /sw/lib | |
| 28 | 30 | /usr/lib/i386-linux-gnu/ |
| 29 | 31 | /usr/lib/x86_64-linux-gnu/ |
| 30 | 32 | ) |
| ... | ... | @@ -36,4 +38,4 @@ if (LIBUSB_FOUND) |
| 36 | 38 | set(LIBUSB_INCLUDE_DIRS ${LIBUSB_INCLUDE_DIR}) |
| 37 | 39 | set(LIBUSB_LIBRARIES ${LIBUSB_LIBRARY}) |
| 38 | 40 | mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) |
| 39 | -endif (LIBUSB_FOUND) | |
| 40 | 41 | \ No newline at end of file |
| 42 | +endif (LIBUSB_FOUND) | ... | ... |
openhantek/CMakeLists.txt
| ... | ... | @@ -35,20 +35,21 @@ else() |
| 35 | 35 | target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:DEBUG>:-O0>") |
| 36 | 36 | target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:RELEASE>:-fno-rtti>") |
| 37 | 37 | endif() |
| 38 | - | |
| 39 | 38 | |
| 40 | -if (UNIX) | |
| 39 | +if(WIN32) | |
| 40 | + include(../cmake/fftw_on_windows.cmake) | |
| 41 | + include(../cmake/libusb_on_windows.cmake) | |
| 42 | +else() | |
| 41 | 43 | find_package(libusb REQUIRED) |
| 44 | + target_include_directories(${PROJECT_NAME} PRIVATE ${LIBUSB_INCLUDE_DIRS}) | |
| 42 | 45 | target_link_libraries(${PROJECT_NAME} ${LIBUSB_LIBRARIES}) |
| 43 | 46 | |
| 44 | 47 | find_package(Threads REQUIRED) |
| 45 | 48 | target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT}) |
| 46 | 49 | |
| 47 | 50 | find_package(FFTW REQUIRED) |
| 51 | + target_include_directories(${PROJECT_NAME} PRIVATE ${FFTW_INCLUDE_DIRS}) | |
| 48 | 52 | target_link_libraries(${PROJECT_NAME} ${FFTW_LIBRARIES}) |
| 49 | -elseif(WIN32) | |
| 50 | - include(../cmake/fftw_on_windows.cmake) | |
| 51 | - include(../cmake/libusb_on_windows.cmake) | |
| 52 | 53 | endif() |
| 53 | 54 | |
| 54 | 55 | # install commands | ... | ... |