CMakeLists.txt 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Copyright 2012 OSMOCOM Project
  2. #
  3. # This file is part of rtl-sdr
  4. #
  5. # GNU Radio is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 3, or (at your option)
  8. # any later version.
  9. #
  10. # GNU Radio is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with GNU Radio; see the file COPYING. If not, write to
  17. # the Free Software Foundation, Inc., 51 Franklin Street,
  18. # Boston, MA 02110-1301, USA.
  19. ########################################################################
  20. # Setup library
  21. ########################################################################
  22. add_library(rtlsdr_shared SHARED
  23. rtl-sdr.c
  24. tuner_e4000.c
  25. tuner_fc0012.c
  26. tuner_fc0013.c
  27. tuner_fc2580.c
  28. )
  29. target_link_libraries(rtlsdr_shared
  30. ${LIBUSB_LIBRARIES}
  31. )
  32. set_target_properties(rtlsdr_shared PROPERTIES DEFINE_SYMBOL "rtlsdr_EXPORTS")
  33. set_target_properties(rtlsdr_shared PROPERTIES OUTPUT_NAME rtlsdr)
  34. add_library(rtlsdr_static STATIC
  35. rtl-sdr.c
  36. tuner_e4000.c
  37. tuner_fc0012.c
  38. tuner_fc0013.c
  39. tuner_fc2580.c
  40. )
  41. target_link_libraries(rtlsdr_static
  42. ${LIBUSB_LIBRARIES}
  43. )
  44. set_property(TARGET rtlsdr_static APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
  45. if(NOT WIN32)
  46. # Force same library filename for static and shared variants of the library
  47. set_target_properties(rtlsdr_static PROPERTIES OUTPUT_NAME rtlsdr)
  48. endif()
  49. ########################################################################
  50. # Build utility
  51. ########################################################################
  52. add_executable(rtl_sdr main.c)
  53. add_executable(rtl_tcp rtl_tcp.c)
  54. target_link_libraries(rtl_sdr rtlsdr_static
  55. ${LIBUSB_LIBRARIES}
  56. ${CMAKE_THREAD_LIBS_INIT}
  57. )
  58. target_link_libraries(rtl_tcp rtlsdr_static
  59. ${LIBUSB_LIBRARIES}
  60. ${CMAKE_THREAD_LIBS_INIT}
  61. )
  62. if(WIN32)
  63. set_property(TARGET rtl_sdr APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
  64. set_property(TARGET rtl_tcp APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
  65. endif()
  66. ########################################################################
  67. # Install built library files & utilities
  68. ########################################################################
  69. install(TARGETS rtlsdr_shared rtlsdr_static rtl_sdr rtl_tcp
  70. LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file
  71. ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
  72. RUNTIME DESTINATION bin # .dll file
  73. )