From 855274113ac8b49a6d9d72e08d2f06e7d0c17b0a Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Fri, 15 May 2020 17:20:47 +0200 Subject: [PATCH] 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 --- CMakeLists.txt | 3 --- tests/CMakeLists.txt | 10 ++++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de50c72aa..61f149f46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,9 +205,6 @@ else() set(LIB_INSTALL_DIR lib) endif() -include_directories(include/) -include_directories(library/) - if(ENABLE_ZLIB_SUPPORT) find_package(ZLIB) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 39a7a2cd0..182109b51 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -48,7 +48,10 @@ function(add_test_suite suite_name) add_executable(test_suite_${data_name} test_suite_${data_name}.c $) 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}) message(STATUS "The test suite ${data_name} will not be executed.") else() @@ -68,7 +71,10 @@ endif(MSVC) file(GLOB MBEDTESTS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c) 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.cfb)