@@ -8,7 +8,12 @@ project(${_name} VERSION ${_version})
88# Set default build type to RelWithDebInfo for local development
99# RelWithDebInfo provides optimized code with debug symbols (PDB files on Windows)
1010if (NOT CMAKE_BUILD_TYPE )
11- set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build (Debug, Release, or RelWithDebInfo)" FORCE)
11+ set (CMAKE_BUILD_TYPE
12+ "RelWithDebInfo"
13+ CACHE STRING
14+ "Choose the type of build (Debug, Release, or RelWithDebInfo)"
15+ FORCE
16+ )
1217endif ()
1318message (STATUS "Build type: ${CMAKE_BUILD_TYPE} " )
1419
@@ -20,29 +25,85 @@ include(helpers)
2025
2126# Read buildspec.json early for Qt configuration
2227file (READ "${CMAKE_SOURCE_DIR} /buildspec.json" buildspec)
23- string (JSON QT6_VERSION GET ${buildspec} dependencies qt6 version )
28+ string (
29+ JSON QT6_VERSION
30+ GET ${buildspec}
31+ dependencies
32+ qt6
33+ version
34+ )
2435
25- # Persistent dependency directory (survives cache clears)
26- if (WIN32 )
27- set (DEPS_DIR "${CMAKE_SOURCE_DIR} /_deps/${CMAKE_VS_PLATFORM_NAME} " )
28- else ()
29- set (DEPS_DIR "${CMAKE_SOURCE_DIR} /_deps" )
30- endif ()
36+ # Define architecture-specific dependency directory in the build directory
37+ # Use CMAKE_BINARY_DIR so it works with any configured build directory
38+ set (DEPS_DIR "${CMAKE_BINARY_DIR} /obs-deps" )
3139
32- # Qt paths for Windows builds
40+ # Configure Qt paths for cross-compilation on Windows
3341if (WIN32 )
3442 if (CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64" )
35- # ARM64 cross-compilation: use x64 Qt tools with ARM64 libraries
43+ # ARM64 Cross-compilation setup
44+ # x64 Qt host tools are in source-dir/_deps/x64 (persistent across builds)
3645 set (QT_HOST_PATH "${CMAKE_SOURCE_DIR} /_deps/x64/obs-deps-qt6-${QT6_VERSION} -x64" )
37- set (Qt6_DIR "${DEPS_DIR} /obs-deps-qt6-${QT6_VERSION} -ARM64/lib/cmake/Qt6" CACHE PATH "" FORCE)
38- set (Qt6CoreTools_DIR "${QT_HOST_PATH} /lib/cmake/Qt6CoreTools" CACHE PATH "" FORCE)
39- set (Qt6GuiTools_DIR "${QT_HOST_PATH} /lib/cmake/Qt6GuiTools" CACHE PATH "" FORCE)
40- set (Qt6WidgetsTools_DIR "${QT_HOST_PATH} /lib/cmake/Qt6WidgetsTools" CACHE PATH "" FORCE)
41- set (CMAKE_AUTOMOC_MOC_EXECUTABLE "${QT_HOST_PATH} /bin/moc.exe" CACHE FILEPATH "" FORCE)
42- set (CMAKE_AUTOUIC_UIC_EXECUTABLE "${QT_HOST_PATH} /bin/uic.exe" CACHE FILEPATH "" FORCE)
43- set (CMAKE_AUTORCC_RCC_EXECUTABLE "${QT_HOST_PATH} /bin/rcc.exe" CACHE FILEPATH "" FORCE)
46+ set (Qt6_DIR
47+ "${DEPS_DIR} /obs-deps-qt6-${QT6_VERSION} -ARM64/lib/cmake/Qt6"
48+ CACHE STRING
49+ "Qt6 ARM64 CMake directory"
50+ FORCE
51+ )
52+
53+ message (STATUS "ARM64 Cross-compilation detected" )
54+ message (STATUS "QT_HOST_PATH: ${QT_HOST_PATH} " )
55+ message (STATUS "Qt6_DIR: ${Qt6_DIR} " )
56+
57+ # Check if x64 Qt host tools exist
58+ if (EXISTS "${QT_HOST_PATH} /bin/moc.exe" )
59+ message (STATUS "Found x64 Qt host tools at: ${QT_HOST_PATH} " )
60+ else ()
61+ message (
62+ FATAL_ERROR
63+ "x64 Qt host tools not found at: ${QT_HOST_PATH} . ARM64 cross-compilation requires both x64 and ARM64 Qt dependencies."
64+ )
65+ endif ()
66+
67+ # Set Qt host tools for cross-compilation (use x64 tools for ARM64 builds)
68+ set (Qt6CoreTools_DIR "${QT_HOST_PATH} /lib/cmake/Qt6CoreTools" CACHE STRING "Qt6 x64 Core Tools" FORCE)
69+ set (Qt6GuiTools_DIR "${QT_HOST_PATH} /lib/cmake/Qt6GuiTools" CACHE STRING "Qt6 x64 GUI Tools" FORCE)
70+ set (Qt6WidgetsTools_DIR "${QT_HOST_PATH} /lib/cmake/Qt6WidgetsTools" CACHE STRING "Qt6 x64 Widget Tools" FORCE)
71+
72+ # Explicitly set tool executables that AUTOMOC/AUTOUIC/AUTORCC will use
73+ set (CMAKE_AUTOMOC_MOC_EXECUTABLE
74+ "${QT_HOST_PATH} /bin/moc.exe"
75+ CACHE FILEPATH
76+ "MOC executable for ARM64 cross-compilation"
77+ FORCE
78+ )
79+ set (CMAKE_AUTOUIC_UIC_EXECUTABLE
80+ "${QT_HOST_PATH} /bin/uic.exe"
81+ CACHE FILEPATH
82+ "UIC executable for ARM64 cross-compilation"
83+ FORCE
84+ )
85+ set (CMAKE_AUTORCC_RCC_EXECUTABLE
86+ "${QT_HOST_PATH} /bin/rcc.exe"
87+ CACHE FILEPATH
88+ "RCC executable for ARM64 cross-compilation"
89+ FORCE
90+ )
91+
92+ # Also set the legacy variables for compatibility
93+ set (QT_MOC_EXECUTABLE "${QT_HOST_PATH} /bin/moc.exe" )
94+ set (QT_RCC_EXECUTABLE "${QT_HOST_PATH} /bin/rcc.exe" )
95+ set (QT_UIC_EXECUTABLE "${QT_HOST_PATH} /bin/uic.exe" )
96+
97+ message (STATUS "Set CMAKE_AUTOMOC_MOC_EXECUTABLE to: ${CMAKE_AUTOMOC_MOC_EXECUTABLE} " )
4498 else ()
45- set (Qt6_DIR "${DEPS_DIR} /obs-deps-qt6-${QT6_VERSION} -x64/lib/cmake/Qt6" CACHE PATH "" FORCE)
99+ # x64 build - set paths to x64 Qt
100+ set (Qt6_DIR
101+ "${DEPS_DIR} /obs-deps-qt6-${QT6_VERSION} -x64/lib/cmake/Qt6"
102+ CACHE STRING
103+ "Qt6 x64 CMake directory"
104+ FORCE
105+ )
106+ message (STATUS "x64 build detected - using x64 Qt at: ${Qt6_DIR} " )
46107 endif ()
47108endif ()
48109
@@ -58,8 +119,19 @@ if(ENABLE_FRONTEND_API)
58119endif ()
59120
60121# Qt is always required for proper window parenting
61- find_package (Qt6 COMPONENTS Widgets Core REQUIRED)
62- target_link_libraries (${CMAKE_PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets)
122+ find_package (
123+ Qt6
124+ COMPONENTS
125+ Widgets
126+ Core
127+ REQUIRED
128+ )
129+ target_link_libraries (
130+ ${CMAKE_PROJECT_NAME}
131+ PRIVATE
132+ Qt6::Core
133+ Qt6::Widgets
134+ )
63135target_compile_definitions (${CMAKE_PROJECT_NAME} PRIVATE ENABLE_QT)
64136target_compile_options (
65137 ${CMAKE_PROJECT_NAME}
@@ -69,57 +141,86 @@ target_compile_options(
69141)
70142set_target_properties (
71143 ${CMAKE_PROJECT_NAME}
72- PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON
144+ PROPERTIES
145+ AUTOMOC
146+ ON
147+ AUTOUIC
148+ ON
149+ AUTORCC
150+ ON
73151)
74152
75153file (GLOB_RECURSE _sources CONFIGURE_DEPENDS src/*.cpp)
76154target_sources (${CMAKE_PROJECT_NAME} PRIVATE ${_sources} )
77155
78156set_target_properties_plugin(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name} )
79157
80- set_target_properties (${CMAKE_PROJECT_NAME} PROPERTIES CXX_STANDARD 23)
158+ set_target_properties (
159+ ${CMAKE_PROJECT_NAME}
160+ PROPERTIES
161+ CXX_STANDARD
162+ 23
163+ )
81164
82165add_subdirectory (lib/atkaudio)
83166
84167string (JSON PLUGIN_DISPLAY_NAME GET ${buildspec} displayName)
85168string (JSON PLUGIN_AUTHOR GET ${buildspec} author)
86- string (JSON PLUGIN_OBS_VERSION_REQUIRED GET ${buildspec} dependencies obs-studio version )
169+ string (
170+ JSON PLUGIN_OBS_VERSION_REQUIRED
171+ GET ${buildspec}
172+ dependencies
173+ obs-studio
174+ version
175+ )
87176string (TIMESTAMP PLUGIN_YEAR "%Y" )
88177set (PLUGIN_AUTHOR "${PLUGIN_AUTHOR} " )
89178
90179configure_file (src/config.h.in config.h @ONLY)
91180
92181include (./lib/atkaudio/cmake/cpack.cmake)
93182
94-
95183# Build tests
96184include (CTest)
97185add_subdirectory (tests)
98186
99187# Automatically run install after build (skip in CI or when installing to system directories without permissions)
100188if (NOT DEFINED ENV{CI} AND NOT DEFINED ENV{GITHUB_ACTIONS} AND NOT CMAKE_INSTALL_PREFIX MATCHES "^/usr" )
101- add_custom_command (TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
102- COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --config $<CONFIG> --component plugin
189+ add_custom_command (
190+ TARGET ${CMAKE_PROJECT_NAME}
191+ POST_BUILD
192+ COMMAND
193+ ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --config $<CONFIG> --component plugin
103194 COMMENT "Installing plugin after build..."
104195 )
105196endif ()
106197
107- # On non-CI Linux builds, copy plugin to user home directory after build
198+ # On non-CI Linux builds, copy plugin and scanner to user home directory after build
108199if (NOT DEFINED ENV{CI} AND NOT DEFINED ENV{GITHUB_ACTIONS} AND UNIX AND NOT APPLE )
109200 message (STATUS "Configuring post-build copy to ~/.config/obs-studio/plugins/" )
110201 if (CMAKE_SIZEOF_VOID_P EQUAL 8)
111202 set (_user_arch "64bit" )
112203 else ()
113204 set (_user_arch "32bit" )
114205 endif ()
115-
116- add_custom_command (TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
117- COMMAND ${CMAKE_COMMAND} -E make_directory "$ENV{HOME} /.config/obs-studio/plugins/${_name} /bin/${_user_arch} "
118- COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:${CMAKE_PROJECT_NAME} >" "$ENV{HOME} /.config/obs-studio/plugins/${_name} /bin/${_user_arch} /"
119- COMMAND ${CMAKE_COMMAND} -E make_directory "$ENV{HOME} /.config/obs-studio/plugins/${_name} /data"
120- COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR} /data" "$ENV{HOME} /.config/obs-studio/plugins/${_name} /data"
121- COMMENT "Copying ${_name} to user home OBS plugins directory..."
206+
207+ add_custom_command (
208+ TARGET ${CMAKE_PROJECT_NAME}
209+ POST_BUILD
210+ COMMAND
211+ ${CMAKE_COMMAND} -E make_directory "$ENV{HOME} /.config/obs-studio/plugins/${_name} /bin/${_user_arch} "
212+ COMMAND
213+ ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:${CMAKE_PROJECT_NAME} >"
214+ "$ENV{HOME} /.config/obs-studio/plugins/${_name} /bin/${_user_arch} /"
215+ COMMAND
216+ ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:${CMAKE_PROJECT_NAME} _scanner>"
217+ "$ENV{HOME} /.config/obs-studio/plugins/${_name} /bin/${_user_arch} /"
218+ COMMAND
219+ ${CMAKE_COMMAND} -E make_directory "$ENV{HOME} /.config/obs-studio/plugins/${_name} /data"
220+ COMMAND
221+ ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR} /data"
222+ "$ENV{HOME} /.config/obs-studio/plugins/${_name} /data"
223+ COMMENT "Copying ${_name} and scanner to user home OBS plugins directory..."
122224 VERBATIM
123225 )
124226endif ()
125-
0 commit comments