cmake: Remove global include directories

Remove the declaration of ./include and ./library
as include directories for all targets.

Prefer being more local and declare include directories
at the target level using target_include_directories().

Note that there is no need to declare explicitely
./include as an include directory for tests as they
inherit it from the "mbed librairies".

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2020-05-15 17:20:47 +02:00
parent 67d4b555b8
commit 855274113a
2 changed files with 8 additions and 5 deletions

View File

@ -205,9 +205,6 @@ else()
set(LIB_INSTALL_DIR lib) set(LIB_INSTALL_DIR lib)
endif() endif()
include_directories(include/)
include_directories(library/)
if(ENABLE_ZLIB_SUPPORT) if(ENABLE_ZLIB_SUPPORT)
find_package(ZLIB) find_package(ZLIB)

View File

@ -48,7 +48,10 @@ function(add_test_suite suite_name)
add_executable(test_suite_${data_name} test_suite_${data_name}.c $<TARGET_OBJECTS:mbedtests>) add_executable(test_suite_${data_name} test_suite_${data_name}.c $<TARGET_OBJECTS:mbedtests>)
target_link_libraries(test_suite_${data_name} ${libs}) target_link_libraries(test_suite_${data_name} ${libs})
target_include_directories(test_suite_${data_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories(test_suite_${data_name}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../library)
if(${data_name} MATCHES ${SKIP_TEST_SUITES_REGEX}) if(${data_name} MATCHES ${SKIP_TEST_SUITES_REGEX})
message(STATUS "The test suite ${data_name} will not be executed.") message(STATUS "The test suite ${data_name} will not be executed.")
else() else()
@ -68,7 +71,10 @@ endif(MSVC)
file(GLOB MBEDTESTS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c) file(GLOB MBEDTESTS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)
add_library(mbedtests OBJECT ${MBEDTESTS_FILES}) add_library(mbedtests OBJECT ${MBEDTESTS_FILES})
target_include_directories(mbedtests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories(mbedtests
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../library)
add_test_suite(aes aes.cbc) add_test_suite(aes aes.cbc)
add_test_suite(aes aes.cfb) add_test_suite(aes aes.cfb)