CMakeLists.txt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. cmake_minimum_required (VERSION 3.1)
  2. project (RTLSDR-Airband CXX)
  3. execute_process(COMMAND ${PROJECT_SOURCE_DIR}/scripts/find_version
  4. OUTPUT_VARIABLE RTL_AIRBAND_VERSION
  5. OUTPUT_STRIP_TRAILING_WHITESPACE
  6. ERROR_VARIABLE RTL_AIRBAND_VERSION_ERROR
  7. ERROR_STRIP_TRAILING_WHITESPACE)
  8. string(COMPARE EQUAL "${RTL_AIRBAND_VERSION}" "" RTL_AIRBAND_VERSION_UNSET)
  9. if(RTL_AIRBAND_VERSION_UNSET)
  10. message(FATAL_ERROR "Failed to detect RTL_AIRBAND_VERSION - \"${RTL_AIRBAND_VERSION_ERROR}\"")
  11. endif()
  12. set (CMAKE_CXX_STANDARD 11)
  13. set (CXX_STANDARD_REQUIRED ON)
  14. set (CMAKE_CXX_EXTENSIONS OFF)
  15. set (CMAKE_COMPILE_WARNING_AS_ERROR ON)
  16. if(NOT CMAKE_BUILD_TYPE)
  17. set(CMAKE_BUILD_TYPE Release)
  18. message(STATUS "Build type not specified: defaulting to Release")
  19. endif(NOT CMAKE_BUILD_TYPE)
  20. # TODO: flags to add: -Wfloat-equal -Wconversion -Wstrict-overflow=5 -Waggregate-return -Wpedantic -Wcast-align
  21. # TODO: these could be added except for gtest: -Wswitch-enum -Wundef -Wswitch-default
  22. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wshadow -Wdate-time -Wpointer-arith -Wwrite-strings -Wcast-qual -Wunreachable-code -Werror")
  23. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -DDEBUG")
  24. if(DEBUG_SQUELCH)
  25. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG_SQUELCH")
  26. endif()
  27. add_subdirectory (src)