CMakeLists.txt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. option(USE_STATIC_WX "Link wxWidgets statically" false)
  2. if(USE_STATIC_WX)
  3. set(wxWidgets_USE_STATIC true)
  4. endif()
  5. find_package(wxWidgets COMPONENTS core base REQUIRED)
  6. include("${wxWidgets_USE_FILE}")
  7. function(wx_required_version)
  8. include(CheckCXXSourceCompiles)
  9. set(WX_CHECK_DEFINITIONS "")
  10. foreach(wxw_def ${wxWidgets_DEFINITIONS})
  11. set(WX_CHECK_DEFINITIONS "${WX_CHECK_DEFINITIONS} -D${wxw_def}")
  12. endforeach()
  13. set(CMAKE_REQUIRED_DEFINITIONS ${WX_CHECK_DEFINITIONS})
  14. set(CMAKE_REQUIRED_INCLUDES ${wxWidgets_INCLUDE_DIRS})
  15. set(CMAKE_REQUIRED_FLAGS ${wxWidgets_CXX_FLAGS})
  16. check_cxx_source_compiles("
  17. #include <wx/sysopt.h>
  18. #if (wxMINOR_VERSION < 9 && wxMAJOR_VERSION <= 2) || wxMAJOR_VERSION < 3
  19. #error
  20. #endif
  21. int main() {}"
  22. WX_REQUIRED_VERSION)
  23. if(NOT WX_REQUIRED_VERSION)
  24. message(SEND_ERROR "wxWidgets version 2.9 or later is required")
  25. endif()
  26. endfunction()
  27. wx_required_version()
  28. if(USE_STATIC_WX)
  29. #unpack -llib to static library names
  30. set(WX_LIBRARIES "")
  31. set(lib_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
  32. set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}
  33. ${CMAKE_DYNAMIC_LIBRARY_SUFFIX} ${CMAKE_SHARED_OBJECT_SUFFIX})
  34. foreach(lib ${wxWidgets_LIBRARIES})
  35. string(SUBSTRING ${lib} 0 2 _l)
  36. if(_l STREQUAL "-l")
  37. string(SUBSTRING ${lib} 2 -1 libname)
  38. find_library(lib_file NAMES ${libname}
  39. HINTS ${wxWidgets_LIBRARY_DIRS})
  40. if(lib_file)
  41. list(APPEND WX_LIBRARIES ${lib_file})
  42. else()
  43. list(APPEND WX_LIBRARIES ${lib})
  44. endif()
  45. unset(lib_file CACHE)
  46. else()
  47. list(APPEND WX_LIBRARIES ${lib})
  48. endif()
  49. endforeach()
  50. if(APPLE)
  51. find_library(lzma NAMES lzma)
  52. if(lzma)
  53. link_libraries(${lzma})
  54. endif()
  55. endif()
  56. set(CMAKE_FIND_LIBRARY_SUFFIXES ${lib_suffixes})
  57. unset(lib_suffixes)
  58. link_libraries(${WX_LIBRARIES})
  59. unset(WX_LIBRARIES)
  60. else()
  61. link_libraries(${wxWidgets_LIBRARIES})
  62. endif()
  63. include_directories(SYSTEM ${obs_SOURCE_DIR}/libobs)
  64. link_libraries(libobs)
  65. if(WIN32)
  66. set(obs_platform_src
  67. platform-windows.cpp)
  68. elseif(APPLE)
  69. set(obs_platform_src
  70. platform-osx.mm)
  71. elseif(UNIX)
  72. set(obs_platform_src
  73. platform-x11.cpp)
  74. endif()
  75. add_executable(obs
  76. window-basic-main.cpp
  77. window-basic-settings.cpp
  78. window-namedialog.cpp
  79. settings-basic.cpp
  80. settings-basic-general.cpp
  81. settings-basic-video.cpp
  82. wx-subclass.cpp
  83. wx-wrappers.cpp
  84. obs-app.cpp
  85. forms/OBSWindows.cpp
  86. ${obs_platform_src})
  87. if(APPLE)
  88. set_target_properties(obs PROPERTIES
  89. MACOSX_BUNDLE ${BUILD_APP_BUNDLE})
  90. if(BUILD_APP_BUNDLE)
  91. obs_add_core_lib_target(obs)
  92. obs_add_data_dir(/bin/obs.app/Contents/)
  93. endif()
  94. endif()
  95. obs_add_data_source(/data/obs-studio/locale
  96. ${obs_SOURCE_DIR}/build/data/obs-studio/locale/en.txt
  97. ${obs_SOURCE_DIR}/build/data/obs-studio/locale/ja.txt
  98. ${obs_SOURCE_DIR}/build/data/obs-studio/locale/locale.ini)