Skip to content

Commit bbd2ed8

Browse files
committed
ENH: Refactor CMakeLists to explicitly define public headers and source files
Replaced `file(GLOB)` usage with explicit lists for source and public header files. Improved clarity and maintainability of project structure in CMake configuration.
1 parent 11c251a commit bbd2ed8

File tree

1 file changed

+61
-7
lines changed

1 file changed

+61
-7
lines changed

src/CMakeLists.txt

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ project(Core LANGUAGES CXX)
22

33
set(CMAKE_AUTOMOC ON)
44

5-
file(GLOB SOURCES *.h *.cpp)
65

76
if(BUILD_SHARED_LIBS)
87
add_library(${PROJECT_NAME} SHARED)
@@ -12,20 +11,75 @@ else()
1211
target_compile_definitions(${PROJECT_NAME} PUBLIC PYTHONQT_STATIC)
1312
endif()
1413

14+
# The sources are private, the headers are added publicly
15+
# explicitly set the source files the same as from
16+
# src.pri
17+
set(Core_SOURCES
18+
gui/PythonQtScriptingConsole.cpp
19+
PythonQt.cpp
20+
PythonQtBoolResult.cpp
21+
PythonQtClassInfo.cpp
22+
PythonQtClassWrapper.cpp
23+
PythonQtConversion.cpp
24+
PythonQtImporter.cpp
25+
PythonQtInstanceWrapper.cpp
26+
PythonQtMethodInfo.cpp
27+
PythonQtMisc.cpp
28+
PythonQtObjectPtr.cpp
29+
PythonQtProperty.cpp
30+
PythonQtQFileImporter.cpp
31+
PythonQtSignal.cpp
32+
PythonQtSignalReceiver.cpp
33+
PythonQtSlot.cpp
34+
PythonQtSlotDecorator.cpp
35+
PythonQtStdDecorators.cpp
36+
PythonQtStdIn.cpp
37+
PythonQtStdOut.cpp
38+
PythonQtThreadSupport.cpp
39+
)
1540
target_sources(${PROJECT_NAME} PRIVATE
16-
${SOURCES}
41+
${Core_SOURCES}
1742
${PYTHONQT_WRAPPER_CORE_BUILTIN_SOURCES}
1843
${PYTHONQT_WRAPPER_GUI_BUILTIN_SOURCES}
1944
)
45+
unset(Core_SOURCES)
2046

21-
add_dependencies(${PROJECT_NAME} PythonQtWrapper)
22-
23-
file(GLOB PUBLIC_HEADER *.h)
24-
47+
set(Core_PUBLIC_HEADER
48+
PythonQt.h
49+
PythonQtStdDecorators.h
50+
PythonQtClassInfo.h
51+
PythonQtImporter.h
52+
PythonQtObjectPtr.h
53+
PythonQtProperty.h
54+
PythonQtSignal.h
55+
PythonQtSlot.h
56+
PythonQtSlotDecorator.h
57+
PythonQtStdIn.h
58+
PythonQtStdOut.h
59+
PythonQtMisc.h
60+
PythonQtMethodInfo.h
61+
PythonQtImportFileInterface.h
62+
PythonQtConversion.h
63+
PythonQtSignalReceiver.h
64+
PythonQtInstanceWrapper.h
65+
PythonQtClassWrapper.h
66+
PythonQtCppWrapperFactory.h
67+
PythonQtQFileImporter.h
68+
PythonQtQFileImporter.h
69+
PythonQtVariants.h
70+
gui/PythonQtScriptingConsole.h
71+
PythonQtSystem.h
72+
PythonQtUtils.h
73+
PythonQtBoolResult.h
74+
PythonQtThreadSupport.h
75+
)
2576
set_target_properties(${PROJECT_NAME} PROPERTIES
2677
OUTPUT_NAME PythonQt-${PYTHONQT_SUFFIX}
27-
PUBLIC_HEADER "${PUBLIC_HEADER}"
78+
PUBLIC_HEADER ${Core_PUBLIC_HEADER}
2879
)
80+
unset(Core_PUBLIC_HEADER)
81+
82+
add_dependencies(${PROJECT_NAME} PythonQtWrapper)
2983

3084
target_link_libraries(${PROJECT_NAME} PUBLIC
3185
Qt${QT_VERSION_MAJOR}::Core

0 commit comments

Comments
 (0)