mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-05-11 09:22:05 +08:00
Fix build errors in CMake
tests/src/ssl_helpers.c depends on functions defined in library/*.c. If it's complied as an OBJECT with other c files, cmake complains undefined reference in link stage under programs/. Therefore, tests/src/test_helpers/ is created to hold c files with dependency of library/*.c. Besides, tests/src/test_helper/*.c is separated into another OBJECT, mbedtls_test_helpers, as sources to build all test suite executables. In addition, everest header directory is included in case MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED is enabled. Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
parent
1fca4de942
commit
b458b8c0ec
@ -280,12 +280,23 @@ add_subdirectory(library)
|
|||||||
# to define the test executables.
|
# to define the test executables.
|
||||||
#
|
#
|
||||||
if(ENABLE_TESTING OR ENABLE_PROGRAMS)
|
if(ENABLE_TESTING OR ENABLE_PROGRAMS)
|
||||||
file(GLOB MBEDTLS_TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/src/*.c ${CMAKE_CURRENT_SOURCE_DIR}/tests/src/drivers/*.c)
|
file(GLOB MBEDTLS_TEST_FILES
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/tests/src/*.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/tests/src/drivers/*.c)
|
||||||
add_library(mbedtls_test OBJECT ${MBEDTLS_TEST_FILES})
|
add_library(mbedtls_test OBJECT ${MBEDTLS_TEST_FILES})
|
||||||
target_include_directories(mbedtls_test
|
target_include_directories(mbedtls_test
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests/include
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests/include
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/library)
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/library)
|
||||||
|
|
||||||
|
file(GLOB MBEDTLS_TEST_HELPER_FILES
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/tests/src/test_helpers/*.c)
|
||||||
|
add_library(mbedtls_test_helpers OBJECT ${MBEDTLS_TEST_HELPER_FILES})
|
||||||
|
target_include_directories(mbedtls_test_helpers
|
||||||
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests/include
|
||||||
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/library
|
||||||
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/everest/include)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_PROGRAMS)
|
if(ENABLE_PROGRAMS)
|
||||||
|
@ -237,7 +237,9 @@ function(add_test_suite suite_name)
|
|||||||
test_suite_${data_name}.datax
|
test_suite_${data_name}.datax
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(test_suite_${data_name} test_suite_${data_name}.c $<TARGET_OBJECTS:mbedtls_test>)
|
add_executable(test_suite_${data_name} test_suite_${data_name}.c
|
||||||
|
$<TARGET_OBJECTS:mbedtls_test>
|
||||||
|
$<TARGET_OBJECTS:mbedtls_test_helpers>)
|
||||||
add_dependencies(test_suite_${data_name} ${dependency})
|
add_dependencies(test_suite_${data_name} ${dependency})
|
||||||
target_link_libraries(test_suite_${data_name} ${libs})
|
target_link_libraries(test_suite_${data_name} ${libs})
|
||||||
# Include test-specific header files from ./include and private header
|
# Include test-specific header files from ./include and private header
|
||||||
|
@ -160,7 +160,7 @@ all: $(BINARIES)
|
|||||||
$(MBEDLIBS):
|
$(MBEDLIBS):
|
||||||
$(MAKE) -C ../library
|
$(MAKE) -C ../library
|
||||||
|
|
||||||
MBEDTLS_TEST_OBJS=$(patsubst %.c,%.o,$(wildcard src/*.c src/drivers/*.c))
|
MBEDTLS_TEST_OBJS=$(patsubst %.c,%.o,$(wildcard src/*.c src/drivers/*.c src/test_helpers/*.c))
|
||||||
|
|
||||||
mbedtls_test: $(MBEDTLS_TEST_OBJS)
|
mbedtls_test: $(MBEDTLS_TEST_OBJS)
|
||||||
|
|
||||||
@ -181,6 +181,10 @@ src/drivers/%.o : src/drivers/%.c
|
|||||||
echo " CC $<"
|
echo " CC $<"
|
||||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
|
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
src/test_helpers/%.o : src/test_helpers/%.c
|
||||||
|
echo " CC $<"
|
||||||
|
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
C_FILES := $(addsuffix .c,$(APPS))
|
C_FILES := $(addsuffix .c,$(APPS))
|
||||||
c: $(C_FILES)
|
c: $(C_FILES)
|
||||||
|
|
||||||
@ -217,7 +221,7 @@ $(BINARIES): %$(EXEXT): %.c $(MBEDLIBS) $(TEST_OBJS_DEPS) $(MBEDTLS_TEST_OBJS)
|
|||||||
clean:
|
clean:
|
||||||
ifndef WINDOWS
|
ifndef WINDOWS
|
||||||
rm -rf $(BINARIES) *.c *.datax
|
rm -rf $(BINARIES) *.c *.datax
|
||||||
rm -f src/*.o src/drivers/*.o src/libmbed*
|
rm -f src/*.o src/drivers/*.o src/test_helpers/*.o src/libmbed*
|
||||||
rm -f include/test/instrument_record_status.h
|
rm -f include/test/instrument_record_status.h
|
||||||
rm -f include/alt-extra/*/*_alt.h
|
rm -f include/alt-extra/*/*_alt.h
|
||||||
rm -rf libtestdriver1
|
rm -rf libtestdriver1
|
||||||
@ -228,6 +232,7 @@ else
|
|||||||
if exist *.datax del /Q /F *.datax
|
if exist *.datax del /Q /F *.datax
|
||||||
if exist src/*.o del /Q /F src/*.o
|
if exist src/*.o del /Q /F src/*.o
|
||||||
if exist src/drivers/*.o del /Q /F src/drivers/*.o
|
if exist src/drivers/*.o del /Q /F src/drivers/*.o
|
||||||
|
if exist src/test_helpers/*.o del /Q /F src/test_helpers/*.o
|
||||||
if exist src/libmbed* del /Q /F src/libmed*
|
if exist src/libmbed* del /Q /F src/libmed*
|
||||||
if exist include/test/instrument_record_status.h del /Q /F include/test/instrument_record_status.h
|
if exist include/test/instrument_record_status.h del /Q /F include/test/instrument_record_status.h
|
||||||
endif
|
endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user