diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..4cfbbb1c5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 2.8) + +project(obs) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE RelWithDebInfo) +endif() + +set(CMAKE_COMPILER_IS_CLANG ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) + option(USE_LIBC++ "Use libc++ instead of libstdc++" ${APPLE}) + if(USE_LIBC++) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + add_definitions(-Wall -Wmissing-prototypes -Wshadow) +endif() + +if(UNIX) + if(APPLE) + set(CMAKE_MACOSX_RPATH TRUE) + set(CMAKE_INSTALL_RPATH + "${CMAKE_INSTALL_RPATH};@loader_path/;@executable_path/") + option(BUILD_APP_BUNDLE "Build app bundle" false) + #TODO: figure out distribution options + mark_as_advanced(BUILD_APP_BUNDLE) + endif() + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +endif() + + +set(LIBRARY_OUTPUT_PATH ${obs_BINARY_DIR}/bin) +set(RUNTIME_OUTPUT_PATH ${obs_BINARY_DIR}/bin) +add_subdirectory(libobs) +add_subdirectory(libobs-opengl) +if(WIN32) + add_subdirectory(libobs-d3d11) + add_subdirectory(libobs-d3d9) +endif() + +set(LIBRARY_OUTPUT_PATH ${obs_BINARY_DIR}/plugins) +set(RUNTIME_OUTPUT_PATH ${obs_BINARY_DIR}/plugins) +add_subdirectory(obs) + +add_subdirectory(test) diff --git a/cmake/FindLibavutil.cmake b/cmake/FindLibavutil.cmake new file mode 100644 index 000000000..b33a9d262 --- /dev/null +++ b/cmake/FindLibavutil.cmake @@ -0,0 +1,20 @@ +find_package(PkgConfig) + +pkg_check_modules(PC_LIBAVUTIL QUIET libavutil) +set(LIBAVUTIL_DEFINITIONS ${PC_LIBAVUTIL_CFLAGS_OTHER}) + +find_path(LIBAVUTIL_INCLUDE_DIR libavutil/avutil.h + HINTS ${PC_LIBAVUTIL_INCLUDEDIR} ${PC_LIBAVUTIL_INCLUDE_DIRS} + PATH_SUFFIXES libavutil) + +find_library(LIBAVUTIL_LIBRARY NAMES libavutil avutil + HINTS ${PC_LIBAVUTIL_LIBDIR} ${PC_LIBAVUTIL_LIBRARY_DIRS}) + +set(LIBAVUTIL_INCLUDE_DIRS ${LIBAVUTIL_INCLUDE_DIR}) +set(LIBAVUTIL_LIBRARIES ${LIBAVUTIL_LIBRARY}) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(Libavutil DEFAULT_MSG + LIBAVUTIL_INCLUDE_DIR LIBAVUTIL_LIBRARY) +mark_as_advanced(LIBAVUTIL_INCLUDE_DIR LIBAVUTIL_LIBRARY) diff --git a/cmake/FindLibswresample.cmake b/cmake/FindLibswresample.cmake new file mode 100644 index 000000000..5134cc71c --- /dev/null +++ b/cmake/FindLibswresample.cmake @@ -0,0 +1,20 @@ +find_package(PkgConfig) + +pkg_check_modules(PC_LIBSWRESAMPLE QUIET libswresample) +set(LIBSWRESAMPLE_DEFINITIONS ${PC_LIBSWRESAMPLE_CFLAGS_OTHER}) + +find_path(LIBSWRESAMPLE_INCLUDE_DIR libswresample/swresample.h + HINTS ${PC_LIBSWRESAMPLE_INCLUDEDIR} ${PC_LIBSWRESAMPLE_INCLUDE_DIRS} + PATH_SUFFIXES libswresample) + +find_library(LIBSWRESAMPLE_LIBRARY NAMES libswresample swresample + HINTS ${PC_LIBSWRESAMPLE_LIBDIR} ${PC_LIBSWRESAMPLE_LIBRARY_DIRS}) + +set(LIBSWRESAMPLE_INCLUDE_DIRS ${LIBSWRESAMPLE_INCLUDE_DIR}) +set(LIBSWRESAMPLE_LIBRARIES ${LIBSWRESAMPLE_LIBRARY}) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(Libswresample DEFAULT_MSG + LIBSWRESAMPLE_INCLUDE_DIR LIBSWRESAMPLE_LIBRARY) +mark_as_advanced(LIBSWRESAMPLE_INCLUDE_DIR LIBSWRESAMPLE_LIBRARY) diff --git a/libobs-opengl/CMakeLists.txt b/libobs-opengl/CMakeLists.txt new file mode 100644 index 000000000..174289755 --- /dev/null +++ b/libobs-opengl/CMakeLists.txt @@ -0,0 +1,54 @@ +if(WIN32) + set(libobs_opengl_platform_src + gl-windows.c) +elseif(APPLE AND UNIX) + set(libobs_opengl_platform_objc_src gl-cocoa.m) + set_source_files_properties(${libobs_opengl_platform_objc_src} + PROPERTIES LANGUAGE C) + set(libobs_opengl_platform_src ${libobs_opengl_platform_objc_src}) + find_library(COCOA Cocoa) + include_directories(${COCOA}) + link_libraries(${COCOA}) +else() +endif() + +option(USE_STATIC_GLEW "Build using bundled GLEW" ${WIN32}) + +include_directories(${obs_SOURCE_DIR}/libobs) + +find_package(OpenGL REQUIRED) +include_directories(${OPENGL_INCLUDE_DIRS}) + +add_definitions(-DGLEW_NO_GLU) + +if(NOT USE_STATIC_GLEW) + find_package(GLEW REQUIRED) + include_directories(${GLEW_INCLUDE_DIRS}) + set(GLEW_SRC) +else() + include_directories(glew/include) + add_definitions(-DGLEW_STATIC) + set(GLEW_SRC glew/src/glew.c) +endif() + +add_library(libobs-opengl MODULE + gl-helpers.c + gl-indexbuffer.c + gl-shader.c + gl-shaderparser.c + gl-stagesurf.c + gl-subsystem.c + gl-texture2d.c + gl-texturecube.c + gl-vertexbuffer.c + gl-zstencil.c + ${libobs_opengl_platform_src} + ${GLEW_SRC}) + +set_target_properties(libobs-opengl + PROPERTIES OUTPUT_NAME obs-opengl) + +target_link_libraries(libobs-opengl + libobs + ${OPENGL_LIBRARIES} + ${GLEW_LIBRARIES}) diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt new file mode 100644 index 000000000..ce80cccff --- /dev/null +++ b/libobs/CMakeLists.txt @@ -0,0 +1,72 @@ +if(WIN32) + set(libobs_platform_src + obs-windows.c + util/platform-windows.c) +elseif(APPLE AND UNIX) + set(libobs_platform_src + obs-cocoa.c + util/platform-cocoa.c) + add_definitions("-DHAVE_STRTOLL") + find_library(COCOA Cocoa) + mark_as_advanced(COCOA) + include_directories(${COCOA}) + link_libraries(${COCOA}) +else() +endif() + +find_package(Libavutil REQUIRED) +include_directories(${LIBAVUTIL_INCLUDE_DIRS}) + +find_package(Libswresample REQUIRED) +include_directories(${LIBSWRESAMPLE_INCLUDE_DIRS}) + +add_library(libobs SHARED + obs.c + obs-display.c + obs-module.c + obs-output.c + obs-scene.c + obs-source.c + obs-video.c + util/base.c + util/bmem.c + util/cf-lexer.c + util/cf-parser.c + util/config-file.c + util/dstr.c + util/lexer.c + util/platform.c + util/text-lookup.c + util/utf8.c + media-io/audio-io.c + media-io/format-conversion.c + media-io/audio-resampler-ffmpeg.c + media-io/media-io.c + media-io/video-io.c + graphics/axisang.c + graphics/bounds.c + graphics/effect.c + graphics/effect-parser.c + graphics/graphics.c + graphics/graphics-imports.c + graphics/math-extra.c + graphics/matrix3.c + graphics/matrix4.c + graphics/plane.c + graphics/quat.c + graphics/shader-parser.c + graphics/texture-render.c + graphics/vec2.c + graphics/vec3.c + graphics/vec4.c + ${libobs_platform_src}) + +set_target_properties(libobs + PROPERTIES OUTPUT_NAME obs) + +target_link_libraries(libobs + ${LIBAVUTIL_LIBRARIES} + ${LIBSWRESAMPLE_LIBRARIES}) + +file(COPY ${obs_SOURCE_DIR}/build/libobs/default.effect DESTINATION + ${obs_BINARY_DIR}/libobs/) diff --git a/obs/CMakeLists.txt b/obs/CMakeLists.txt new file mode 100644 index 000000000..a64a67ca4 --- /dev/null +++ b/obs/CMakeLists.txt @@ -0,0 +1,39 @@ +find_package(wxWidgets COMPONENTS core base REQUIRED) + +include("${wxWidgets_USE_FILE}") + +function(wx_required_version) + include(CheckCXXSourceCompiles) + set(WX_CHECK_DEFINITIONS "") + foreach(wxw_def ${wxWidgets_DEFINITIONS}) + set(WX_CHECK_DEFINITIONS "${WX_CHECK_DEFINITIONS} -D${wxw_def}") + endforeach() + set(CMAKE_REQUIRED_DEFINITIONS ${WX_CHECK_DEFINITIONS}) + set(CMAKE_REQUIRED_INCLUDES ${wxWidgets_INCLUDE_DIRS}) + check_cxx_source_compiles(" + #include + #if (wxMINOR_VERSION < 9 && wxMAJOR_VERSION <= 2) || wxMAJOR_VERSION < 3 + #error + #endif + int main() {}" + WX_REQUIRED_VERSION) + + if(NOT WX_REQUIRED_VERSION) + message(SEND_ERROR "wxWidgets version 2.9 or later is required") + endif() +endfunction() +wx_required_version() + + +link_libraries(${wxWidgets_LIBRARIES}) + +add_executable(obs + window-obs-basic.cpp + window-subclass.cpp + obs.cpp + OBSWindows.cpp) + +if(APPLE) + set_target_properties(obs PROPERTIES + MACOSX_BUNDLE ${BUILD_APP_BUNDLE}) +endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 000000000..e12259aff --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,6 @@ +add_subdirectory(test-input) +if(WIN32) + add_subdirectory(win) +elseif(APPLE AND UNIX) + add_subdirectory(osx) +endif() diff --git a/test/osx/CMakeLists.txt b/test/osx/CMakeLists.txt new file mode 100644 index 000000000..cf860eb59 --- /dev/null +++ b/test/osx/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(${obs_SOURCE_DIR}/libobs) + +find_library(COCOA Cocoa) +include_directories(${COCOA}) + +link_libraries(libobs ${COCOA}) + +add_executable(test test.mm) diff --git a/test/test-input/CMakeLists.txt b/test/test-input/CMakeLists.txt new file mode 100644 index 000000000..adf655316 --- /dev/null +++ b/test/test-input/CMakeLists.txt @@ -0,0 +1,14 @@ +include_directories(${obs_SOURCE_DIR}/libobs) + +add_library(test-input MODULE + test-filter.c + test-input.c + test-random.c) + +target_link_libraries(test-input + libobs) + +file(COPY + ${obs_SOURCE_DIR}/build/data/test-input/draw.effect + ${obs_SOURCE_DIR}/build/data/test-input/test.effect + DESTINATION ${obs_BINARY_DIR}/data/test-input/)