CMakeLists.txt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. cmake_minimum_required(VERSION 2.8.7)
  2. if(POLICY CMP0046)
  3. cmake_policy(SET CMP0046 NEW)
  4. endif()
  5. if(POLICY CMP0054)
  6. cmake_policy(SET CMP0054 NEW)
  7. endif()
  8. set(CNSTREAM_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
  9. include(CheckCXXCompilerFlag)
  10. CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
  11. if(NOT COMPILER_SUPPORTS_CXX11)
  12. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  13. endif()
  14. if(USE_libstdcpp)
  15. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
  16. message("-- Warning: forcing libstdc++ (controlled by USE_libstdcpp option in cmake)")
  17. endif()
  18. # compile flags
  19. set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-as-needed")
  20. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
  21. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g")
  22. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_REENTRANT -fPIC -Wno-deprecated-declarations -Wall -Werror")
  23. set(LIBRARY_OUTPUT_PATH ${CNSTREAM_ROOT_DIR}/lib)
  24. set(contrib_modules_list fakesink)
  25. # ---[ cnstream_va
  26. include_directories(${CNSTREAM_ROOT_DIR}/modules)
  27. include_directories(${CNSTREAM_ROOT_DIR}/modules/util/include)
  28. foreach(contrib_module ${contrib_modules_list})
  29. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/${contrib_module}/include)
  30. install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${contrib_module}/include/ DESTINATION include)
  31. file(GLOB_RECURSE contrib_module_src ${CMAKE_CURRENT_SOURCE_DIR}/${contrib_module}/*.cpp)
  32. list(APPEND contrib_module_srcs ${contrib_module_src})
  33. endforeach()
  34. if(DEFINED contrib_modules_list)
  35. include(${CNSTREAM_ROOT_DIR}/cmake/have_cnstream_target.cmake)
  36. have_framework_target(${CNSTREAM_ROOT_DIR})
  37. have_modules_target(${CNSTREAM_ROOT_DIR})
  38. add_library(cnstream_contrib SHARED ${contrib_module_srcs})
  39. set_target_properties(cnstream_contrib PROPERTIES LINK_FLAGS_RELEASE -s)
  40. if(HAVE_FRAMEWORK_TARGET)
  41. add_dependencies(cnstream_contrib cnstream_core)
  42. endif()
  43. if(HAVE_MODULES_TARGET)
  44. add_dependencies(cnstream_contrib cnstream_va)
  45. endif()
  46. target_link_libraries(cnstream_contrib cnstream_va)
  47. install(TARGETS cnstream_contrib LIBRARY DESTINATION lib)
  48. endif()