Skip to content

Commit 689f1e1

Browse files
authored
CMake: Limit scope of AUTOMOC (#449)
- Only set AUTOMOC property on library target - Only use the Qt headers in target_sources() - Make Qt headers PRIVATE sources, to avoid migration to other targets
1 parent 09e7760 commit 689f1e1

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/CMakeLists.txt

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
# Collect and display summary of options/dependencies
2828
include(FeatureSummary)
2929

30-
# Automatically process Qt classes with meta-object compiler
31-
set(CMAKE_AUTOMOC True)
3230

3331
################ WINDOWS ##################
3432
# Set some compiler options for Windows
@@ -190,9 +188,8 @@ set(QT_PLAYER_SOURCES
190188
Qt/VideoRenderer.cpp
191189
Qt/VideoRenderWidget.cpp)
192190

193-
194-
# Get list of headers
195-
file(GLOB_RECURSE headers ${CMAKE_SOURCE_DIR}/include/*.h)
191+
# Get list of MOC'able headers
192+
file(GLOB_RECURSE OPENSHOT_QT_HEADERS ${CMAKE_SOURCE_DIR}/include/Qt/*.h)
196193

197194
# Disable RPATH
198195
SET(CMAKE_MACOSX_RPATH 0)
@@ -201,19 +198,20 @@ SET(CMAKE_MACOSX_RPATH 0)
201198
# Create shared openshot library
202199
add_library(openshot SHARED)
203200

204-
target_sources(openshot
205-
PRIVATE
206-
${OPENSHOT_SOURCES} ${EFFECTS_SOURCES} ${QT_PLAYER_SOURCES}
207-
PUBLIC
208-
${headers})
201+
target_sources(openshot PRIVATE
202+
${OPENSHOT_SOURCES}
203+
${EFFECTS_SOURCES}
204+
${QT_PLAYER_SOURCES}
205+
${OPENSHOT_QT_HEADERS}
206+
)
209207

210208
# Set SONAME and other library properties
211-
set_target_properties(openshot
212-
PROPERTIES
213-
VERSION ${PROJECT_VERSION}
214-
SOVERSION ${PROJECT_SO_VERSION}
215-
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
216-
)
209+
set_target_properties(openshot PROPERTIES
210+
AUTOMOC ON
211+
VERSION ${PROJECT_VERSION}
212+
SOVERSION ${PROJECT_SO_VERSION}
213+
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
214+
)
217215

218216
# Add optional ImageMagic-dependent sources
219217
if(ImageMagick_FOUND)

0 commit comments

Comments
 (0)