Skip to content

Commit adca7c5

Browse files
committed
DTNN-635 Fixed unit test cmakes, simplified top-level cmake with list of components
1 parent f4577e0 commit adca7c5

File tree

5 files changed

+55
-59
lines changed

5 files changed

+55
-59
lines changed

CMakeLists.txt

+26-16
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,28 @@ endif()
8888
add_subdirectory(cla)
8989
add_subdirectory(aa/as)
9090

91-
92-
# v7 implementation parts
93-
list(APPEND BPLIB_SRC
94-
$<TARGET_OBJECTS:bplib_cla>
95-
$<TARGET_OBJECTS:bplib_as>
91+
list(APPEND BPLIB_COMPONENTS
92+
bplib_cla
93+
bplib_as
9694
)
9795

98-
list(APPEND BPLIB_PRIVATE_INCLUDE_DIRS
99-
$<TARGET_PROPERTY:bplib_cla,INTERFACE_INCLUDE_DIRECTORIES>
100-
$<TARGET_PROPERTY:bplib_as,INTERFACE_INCLUDE_DIRECTORIES>
96+
foreach(COMPONENT ${BPLIB_COMPONENTS})
97+
list(APPEND BPLIB_SRC
98+
$<TARGET_OBJECTS:${COMPONENT}>
99+
)
100+
101+
list(APPEND BPLIB_PRIVATE_INCLUDE_DIRS
102+
$<TARGET_PROPERTY:${COMPONENT},INTERFACE_INCLUDE_DIRECTORIES>
103+
)
101104

102-
)
105+
endforeach()
106+
107+
# Link all stubs into single library
108+
add_library(coverage-bplib-stubs INTERFACE)
109+
110+
foreach(COMPONENT ${BPLIB_COMPONENTS})
111+
target_link_libraries(coverage-bplib-stubs INTERFACE ${COMPONENT}_stubs)
112+
endforeach()
103113

104114
# If building as part of CFE/CFS, then the "IS_CFS_ARCH_BUILD" should be set
105115
# this allows simply dropping this module into a CFS project
@@ -167,16 +177,16 @@ endif()
167177

168178
get_target_property(IS_PIC bplib POSITION_INDEPENDENT_CODE)
169179
if (IS_PIC)
170-
set_target_properties(
171-
bplib_cla bplib_as
172-
PROPERTIES POSITION_INDEPENDENT_CODE ${IS_PIC}
173-
)
180+
foreach(COMPONENT ${BPLIB_COMPONENTS})
181+
set_target_properties(${COMPONENT} PROPERTIES POSITION_INDEPENDENT_CODE ${IS_PIC})
182+
endforeach()
174183
endif()
175184

176185
# Set the standard compile options for all submodules (c99, full warnings)
177-
foreach(TGT bplib bplib_cla bplib_as)
178-
target_compile_features(${TGT} PRIVATE c_std_99)
179-
target_compile_options(${TGT} PRIVATE ${BPLIB_COMMON_COMPILE_OPTIONS})
186+
list(APPEND ${BPLIB_COMPONENTS} bplib)
187+
foreach(COMPONENT ${BPLIB_COMPONENTS})
188+
target_compile_features(${COMPONENT} PRIVATE c_std_99)
189+
target_compile_options(${COMPONENT} PRIVATE ${BPLIB_COMMON_COMPILE_OPTIONS})
180190
endforeach()
181191

182192
# Internal/private header files exist within the implementation directories

aa/as/unit-test/CMakeLists.txt

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
##################################################################
22
#
3-
# coverage test build recipe
3+
# Coverage test build recipe
44
#
55
# This CMake file contains the recipe for building the coverage tests.
66
# It is invoked from the parent directory when unit tests are enabled.
77
#
88
##################################################################
99

10+
# Create stubs (for external use)
11+
add_library(bplib_as_stubs STATIC
12+
stubs/bplib_as_stubs.c
13+
)
14+
15+
target_include_directories(bplib_as_stubs PUBLIC
16+
$<TARGET_PROPERTY:bplib_as,INTERFACE_INCLUDE_DIRECTORIES>
17+
)
18+
19+
target_link_libraries(bplib_as_stubs ut_assert ut_core_api_stubs)
20+
21+
# Create unit test object
1022
add_library(utobj_bplib_as OBJECT
1123
../src/bplib_as.c
1224
)
@@ -26,7 +38,7 @@ target_include_directories(utobj_bplib_as PRIVATE
2638
$<TARGET_PROPERTY:ut_coverage_compile,INTERFACE_INCLUDE_DIRECTORIES>
2739
)
2840

29-
# Add executable
41+
# Create test runner executable
3042
add_executable(coverage-bplib_as-testrunner
3143
utilities/bplib_as_test_utils.c
3244
bplib_as_test.c
@@ -35,8 +47,8 @@ add_executable(coverage-bplib_as-testrunner
3547

3648
target_include_directories(coverage-bplib_as-testrunner PRIVATE
3749
../src
38-
${CMAKE_CURRENT_SOURCE_DIR}/inc
3950
utilities/
51+
${CMAKE_CURRENT_SOURCE_DIR}/inc
4052
$<TARGET_PROPERTY:bplib_as,INTERFACE_INCLUDE_DIRECTORIES>
4153
)
4254

aa/as/unit-test/stubs/CMakeLists.txt

-19
This file was deleted.

cla/unit-test/CMakeLists.txt

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
##################################################################
22
#
3-
# coverage test build recipe
3+
# Coverage test build recipe
44
#
55
# This CMake file contains the recipe for building the coverage tests.
66
# It is invoked from the parent directory when unit tests are enabled.
77
#
88
##################################################################
99

10+
# Create stubs (for external use)
11+
add_library(bplib_cla_stubs STATIC
12+
stubs/bplib_cla_stubs.c
13+
)
14+
15+
target_include_directories(bplib_cla_stubs PUBLIC
16+
$<TARGET_PROPERTY:bplib_cla,INTERFACE_INCLUDE_DIRECTORIES>
17+
)
18+
19+
target_link_libraries(bplib_cla_stubs ut_assert ut_core_api_stubs)
20+
21+
# Create unit test object
1022
add_library(utobj_bplib_cla OBJECT
1123
../src/bplib_cla.c
1224
)
@@ -26,7 +38,7 @@ target_include_directories(utobj_bplib_cla PRIVATE
2638
$<TARGET_PROPERTY:ut_coverage_compile,INTERFACE_INCLUDE_DIRECTORIES>
2739
)
2840

29-
# Add executable
41+
# Create test runner executable
3042
add_executable(coverage-bplib_cla-testrunner
3143
utilities/bplib_cla_test_utils.c
3244
bplib_cla_test.c

cla/unit-test/stubs/CMakeLists.txt

-19
This file was deleted.

0 commit comments

Comments
 (0)