CMakeLists.txt 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. # Project setup
  21. ########################################################################
  22. cmake_minimum_required(VERSION 2.6)
  23. project(rtlsdr C)
  24. #select the release build type by default to get optimization flags
  25. if(NOT CMAKE_BUILD_TYPE)
  26. set(CMAKE_BUILD_TYPE "Release")
  27. message(STATUS "Build type not specified: defaulting to release.")
  28. endif(NOT CMAKE_BUILD_TYPE)
  29. set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
  30. list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
  31. ########################################################################
  32. # Compiler specific setup
  33. ########################################################################
  34. if(CMAKE_COMPILER_IS_GNUCC AND NOT WIN32)
  35. ADD_DEFINITIONS(-Wall)
  36. ADD_DEFINITIONS(-Wextra)
  37. ADD_DEFINITIONS(-Wno-unused)
  38. ADD_DEFINITIONS(-Wsign-compare)
  39. #http://gcc.gnu.org/wiki/Visibility
  40. add_definitions(-fvisibility=hidden)
  41. endif()
  42. ########################################################################
  43. # Find build dependencies
  44. ########################################################################
  45. find_package(PkgConfig)
  46. find_package(LibUSB)
  47. set(THREADS_USE_PTHREADS_WIN32 true)
  48. find_package(Threads)
  49. if(NOT LIBUSB_FOUND)
  50. message(FATAL_ERROR "LibUSB 1.0 required to compile rtl-sdr")
  51. endif()
  52. if(NOT THREADS_FOUND)
  53. message(FATAL_ERROR "pthreads(-win32) required to compile rtl-sdr")
  54. endif()
  55. ########################################################################
  56. # Setup the include and linker paths
  57. ########################################################################
  58. include_directories(
  59. ${CMAKE_SOURCE_DIR}/include
  60. ${LIBUSB_INCLUDE_DIR}
  61. ${THREADS_PTHREADS_INCLUDE_DIR}
  62. )
  63. #link_directories(
  64. # ...
  65. #)
  66. # Set component parameters
  67. #set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE INTERNAL "" FORCE)
  68. ########################################################################
  69. # Create uninstall target
  70. ########################################################################
  71. configure_file(
  72. ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
  73. ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
  74. @ONLY)
  75. add_custom_target(uninstall
  76. ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
  77. )
  78. ########################################################################
  79. # Add subdirectories
  80. ########################################################################
  81. add_subdirectory(include)
  82. add_subdirectory(src)