@@ -95,3 +95,93 @@ function(ppc_configure_subproject SUBDIR)
9595 "${CMAKE_CURRENT_SOURCE_DIR} /${SUBDIR} " )
9696 endforeach ()
9797endfunction ()
98+
99+ # Function to configure single subproject as static library
100+ function (ppc_configure_single_subproject SUBDIR )
101+ if (NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR} /${SUBDIR} "
102+ OR SUBDIR STREQUAL "common" )
103+ return ()
104+ endif ()
105+
106+ message (STATUS " ${SUBDIR} " )
107+
108+ # Create individual library for this task
109+ set (TASK_LIB_NAME "ppc_task_${SUBDIR} " )
110+ set (TASK_HAS_SOURCES FALSE )
111+ set (ALL_TASK_SOURCES)
112+ set (ALL_TASK_INCLUDE_DIRS)
113+
114+ # Module-specific compile-time definitions
115+ add_compile_definitions (
116+ PPC_SETTINGS_${SUBDIR}= "${CMAKE_CURRENT_SOURCE_DIR} /${SUBDIR} /settings.json"
117+ PPC_ID_${SUBDIR}= "${SUBDIR} " )
118+
119+ # Switch project context to the subproject
120+ project (${SUBDIR} )
121+
122+ # Register functional and performance test runners
123+ set (TEST_DIR "${CMAKE_CURRENT_SOURCE_DIR} /${SUBDIR} /tests" )
124+ set (TEST_EXECUTABLES "" )
125+ add_tests (USE_FUNC_TESTS ${FUNC_TEST_EXEC} functional )
126+ add_tests (USE_PERF_TESTS ${PERF_TEST_EXEC} performance )
127+
128+ # Collect test sources
129+ if (EXISTS "${TEST_DIR} /functional" )
130+ file (GLOB_RECURSE FUNC_TEST_SOURCES "${TEST_DIR} /functional/*.cpp" )
131+ if (FUNC_TEST_SOURCES)
132+ list (APPEND ALL_TASK_SOURCES ${FUNC_TEST_SOURCES} )
133+ set (TASK_HAS_SOURCES TRUE )
134+ endif ()
135+ endif ()
136+
137+ if (EXISTS "${TEST_DIR} /performance" )
138+ file (GLOB_RECURSE PERF_TEST_SOURCES "${TEST_DIR} /performance/*.cpp" )
139+ if (PERF_TEST_SOURCES)
140+ list (APPEND ALL_TASK_SOURCES ${PERF_TEST_SOURCES} )
141+ set (TASK_HAS_SOURCES TRUE )
142+ endif ()
143+ endif ()
144+
145+ # Collect implementation sources
146+ foreach (IMPL IN LISTS PPC_IMPLEMENTATIONS)
147+ set (IMP_DIR "${CMAKE_CURRENT_SOURCE_DIR} /${SUBDIR} /${IMPL} " )
148+ if (EXISTS "${IMP_DIR} " )
149+ file (GLOB_RECURSE IMPL_SOURCES "${IMP_DIR} /src/*.cpp" )
150+ if (IMPL_SOURCES)
151+ list (APPEND ALL_TASK_SOURCES ${IMPL_SOURCES} )
152+ list (APPEND ALL_TASK_INCLUDE_DIRS "${IMP_DIR} /include" )
153+ set (TASK_HAS_SOURCES TRUE )
154+ endif ()
155+ endif ()
156+ endforeach ()
157+
158+ # Create library only if we have sources
159+ if (TASK_HAS_SOURCES)
160+ add_library (${TASK_LIB_NAME} STATIC ${ALL_TASK_SOURCES} )
161+
162+ # Set include directories
163+ if (ALL_TASK_INCLUDE_DIRS)
164+ list (REMOVE_DUPLICATES ALL_TASK_INCLUDE_DIRS)
165+ target_include_directories (${TASK_LIB_NAME}
166+ PUBLIC ${ALL_TASK_INCLUDE_DIRS} )
167+ endif ()
168+
169+ # Set task-specific definitions
170+ target_compile_definitions (
171+ ${TASK_LIB_NAME}
172+ PRIVATE
173+ PPC_SETTINGS_${SUBDIR}= "${CMAKE_CURRENT_SOURCE_DIR} /${SUBDIR} /settings.json"
174+ PPC_ID_${SUBDIR}= "${SUBDIR} " )
175+
176+ # Link core module
177+ target_link_libraries (${TASK_LIB_NAME} PUBLIC core_module_lib )
178+
179+ # Link to main executables
180+ if (USE_FUNC_TESTS)
181+ target_link_libraries (${FUNC_TEST_EXEC} PUBLIC ${TASK_LIB_NAME} )
182+ endif ()
183+ if (USE_PERF_TESTS)
184+ target_link_libraries (${PERF_TEST_EXEC} PUBLIC ${TASK_LIB_NAME} )
185+ endif ()
186+ endif ()
187+ endfunction ()
0 commit comments