Skip to content

Commit

Permalink
Implement in-tree build
Browse files Browse the repository at this point in the history
- Adds branches by checking CMAKE_SOURCE_DIR.
  - Avoids finding packages such as libobs and obs-frontend-api.
  - Does not create installer files.
- Replaces CMAKE_PROJECT_NAME with PROJECT_NAME.
  • Loading branch information
norihiro committed Mar 22, 2023
1 parent 01963d5 commit 62e967b
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,73 @@ set(MACOS_INSTALLER_UUID "D42A28A8-FCE7-45F4-901B-5F333C2ABC94")
set(LINUX_MAINTAINER_EMAIL "[email protected]")
# NOTE: Also edit ci/plugin.spec for RPM when creating a new plugin.

find_package(libobs REQUIRED)
find_package(obs-frontend-api REQUIRED)
include(cmake/ObsPluginHelpers.cmake)
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
find_package(libobs REQUIRED)
find_package(obs-frontend-api REQUIRED)
include(cmake/ObsPluginHelpers.cmake)
else()
add_library(OBS::obs-frontend-api ALIAS obs-frontend-api)
endif()

configure_file(
plugin-macros.h.in
plugin-macros.generated.h
)

configure_file(
installer/installer-Windows.iss.in
../installer/installer-Windows.generated.iss
)

configure_file(
ci/ci_includes.sh.in
../ci/ci_includes.generated.sh
)
configure_file(
ci/ci_includes.cmd.in
../ci/ci_includes.generated.cmd
)

set(PLUGIN_SOURCES
obs-command-source.c
)

add_library(${CMAKE_PROJECT_NAME} MODULE ${PLUGIN_SOURCES})
add_library(${PROJECT_NAME} MODULE ${PLUGIN_SOURCES})

target_link_libraries(${CMAKE_PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
OBS::libobs
OBS::obs-frontend-api
)

target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

if(OS_WINDOWS)
# Enable Multicore Builds and disable FH4 (to not depend on VCRUNTIME140_1.DLL when building with VS2019)
if (MSVC)
add_definitions(/MP /d2FH4-)
endif()

target_link_libraries(${CMAKE_PROJECT_NAME} OBS::w32-pthreads)
target_link_libraries(${PROJECT_NAME} OBS::w32-pthreads)
endif()

if(OS_LINUX)
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Wextra)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra)
endif()

if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fvisibility=default")

set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
set(MACOSX_PLUGIN_GUI_IDENTIFIER "${MACOS_BUNDLEID}")
set(MACOSX_PLUGIN_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION}")
set(MACOSX_PLUGIN_SHORT_VERSION_STRING "1")
endif()

setup_plugin_target(${CMAKE_PROJECT_NAME})

configure_file(installer/installer-macOS.pkgproj.in installer-macOS.generated.pkgproj)
setup_plugin_target(${PROJECT_NAME})

if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
configure_file(
installer/installer-Windows.iss.in
../installer/installer-Windows.generated.iss
)

configure_file(
ci/ci_includes.sh.in
../ci/ci_includes.generated.sh
)
configure_file(
ci/ci_includes.cmd.in
../ci/ci_includes.generated.cmd
)

configure_file(
installer/installer-macOS.pkgproj.in
installer-macOS.generated.pkgproj
)
endif()

0 comments on commit 62e967b

Please sign in to comment.