diff --git a/CMakeLists.txt b/CMakeLists.txt index 62e458f9b..e54bceecf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,13 +32,11 @@ project(openthread) option(OT_BUILD_EXECUTABLES "Build executables" ON) option(OT_BUILTIN_MBEDTLS "Enable builtin mbedTLS" ON) -set(OT_ROOT_DIR ${PROJECT_SOURCE_DIR} CACHE INTERNAL "OpenThread source root.") - -include("${OT_ROOT_DIR}/etc/cmake/checks.cmake") -include("${OT_ROOT_DIR}/etc/cmake/options.cmake") +include("${PROJECT_SOURCE_DIR}/etc/cmake/checks.cmake") +include("${PROJECT_SOURCE_DIR}/etc/cmake/options.cmake") execute_process( - COMMAND "${OT_ROOT_DIR}/third_party/nlbuild-autotools/repo/scripts/mkversion" "-b" "`cat .default-version`" "." + COMMAND "${PROJECT_SOURCE_DIR}/third_party/nlbuild-autotools/repo/scripts/mkversion" "-b" "`cat .default-version`" "." OUTPUT_VARIABLE __version OUTPUT_STRIP_TRAILING_WHITESPACE ) set(OT_VERSION "${__version}") @@ -52,7 +50,7 @@ set(OT_PLATFORM "none" CACHE STRING "Target platform chosen by the user at confi function(ot_get_platforms arg_platforms) set(result "none") - set(platforms_dir "${OT_ROOT_DIR}/examples/platforms") + set(platforms_dir "${PROJECT_SOURCE_DIR}/examples/platforms") file(GLOB platforms RELATIVE "${platforms_dir}" "${platforms_dir}/*") foreach(platform IN LISTS platforms) if(IS_DIRECTORY "${platforms_dir}/${platform}") @@ -69,19 +67,19 @@ if(NOT OT_PLATFORM IN_LIST OT_EXAMPLE_PLATFORMS) message(FATAL_ERROR "Platform unknown: ${OT_PLATFORM}") endif() -list(APPEND OT_PUBLIC_INCLUDES ${OT_ROOT_DIR}/etc/cmake) -list(APPEND OT_PUBLIC_INCLUDES ${OT_ROOT_DIR}/include) +list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_SOURCE_DIR}/etc/cmake) +list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_SOURCE_DIR}/include) if(NOT OT_PLATFORM MATCHES "none") - list(APPEND OT_PRIVATE_INCLUDES ${OT_ROOT_DIR}/examples/platforms/${OT_PLATFORM}) - include("${OT_ROOT_DIR}/examples/platforms/${OT_PLATFORM}/platform.cmake") + list(APPEND OT_PRIVATE_INCLUDES ${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM}) + include("${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM}/platform.cmake") endif() list(APPEND OT_PRIVATE_DEFINES ${OT_PLATFORM_DEFINES}) if(OT_BUILTIN_MBEDTLS) - list(APPEND OT_PRIVATE_INCLUDES ${OT_ROOT_DIR}/third_party/mbedtls) - list(APPEND OT_PRIVATE_INCLUDES ${OT_ROOT_DIR}/third_party/mbedtls/repo/include) + list(APPEND OT_PRIVATE_INCLUDES ${PROJECT_SOURCE_DIR}/third_party/mbedtls) + list(APPEND OT_PRIVATE_INCLUDES ${PROJECT_SOURCE_DIR}/third_party/mbedtls/repo/include) list(APPEND OT_PRIVATE_DEFINES "MBEDTLS_CONFIG_FILE=\"mbedtls-config.h\"" diff --git a/examples/apps/cli/CMakeLists.txt b/examples/apps/cli/CMakeLists.txt index 9f756883f..dac2bc2b9 100644 --- a/examples/apps/cli/CMakeLists.txt +++ b/examples/apps/cli/CMakeLists.txt @@ -37,8 +37,8 @@ add_executable(ot-cli-mtd set(COMMON_INCLUDES ${OT_PUBLIC_INCLUDES} ${OT_PRIVATE_INCLUDES} - ${OT_ROOT_DIR}/examples/platforms - ${OT_ROOT_DIR}/src/core + ${PROJECT_SOURCE_DIR}/examples/platforms + ${PROJECT_SOURCE_DIR}/src/core ) target_include_directories(ot-cli-ftd PRIVATE ${COMMON_INCLUDES}) diff --git a/examples/apps/ncp/CMakeLists.txt b/examples/apps/ncp/CMakeLists.txt index 5ac8658ac..50278505b 100644 --- a/examples/apps/ncp/CMakeLists.txt +++ b/examples/apps/ncp/CMakeLists.txt @@ -41,8 +41,8 @@ add_executable(ot-rcp set(COMMON_INCLUDES ${OT_PUBLIC_INCLUDES} ${OT_PRIVATE_INCLUDES} - ${OT_ROOT_DIR}/examples/platforms - ${OT_ROOT_DIR}/src/core + ${PROJECT_SOURCE_DIR}/examples/platforms + ${PROJECT_SOURCE_DIR}/src/core ) target_include_directories(ot-ncp-ftd PRIVATE ${COMMON_INCLUDES}) diff --git a/examples/platforms/cc2538/CMakeLists.txt b/examples/platforms/cc2538/CMakeLists.txt index 27cf447ed..9b928c037 100644 --- a/examples/platforms/cc2538/CMakeLists.txt +++ b/examples/platforms/cc2538/CMakeLists.txt @@ -47,6 +47,6 @@ target_compile_definitions(openthread-cc2538 PUBLIC ${OT_PLATFORM_DEFINES}) target_include_directories(openthread-cc2538 PRIVATE ${OT_PUBLIC_INCLUDES} ${OT_PRIVATE_INCLUDES} - ${OT_ROOT_DIR}/examples/platforms - ${OT_ROOT_DIR}/src/core + ${PROJECT_SOURCE_DIR}/examples/platforms + ${PROJECT_SOURCE_DIR}/src/core ) diff --git a/examples/platforms/posix/CMakeLists.txt b/examples/platforms/posix/CMakeLists.txt index 55f933323..76bad0e1f 100644 --- a/examples/platforms/posix/CMakeLists.txt +++ b/examples/platforms/posix/CMakeLists.txt @@ -55,6 +55,6 @@ target_compile_definitions(openthread-posix PUBLIC ${OT_PLATFORM_DEFINES}) target_include_directories(openthread-posix PRIVATE ${OT_PUBLIC_INCLUDES} ${OT_PRIVATE_INCLUDES} - ${OT_ROOT_DIR}/examples/platforms - ${OT_ROOT_DIR}/src/core + ${PROJECT_SOURCE_DIR}/examples/platforms + ${PROJECT_SOURCE_DIR}/src/core ) diff --git a/examples/platforms/utils/CMakeLists.txt b/examples/platforms/utils/CMakeLists.txt index 2adb8525c..0526e3745 100644 --- a/examples/platforms/utils/CMakeLists.txt +++ b/examples/platforms/utils/CMakeLists.txt @@ -42,10 +42,10 @@ target_compile_definitions(openthread-platform-utils PRIVATE target_include_directories(openthread-platform-utils PRIVATE ${OT_PUBLIC_INCLUDES} ${OT_PRIVATE_INCLUDES} - ${OT_ROOT_DIR}/examples/platforms - ${OT_ROOT_DIR}/examples/platforms/utils - ${OT_ROOT_DIR}/src/core - ${OT_ROOT_DIR}/third_party/jlink/SEGGER_RTT_V640/RTT + ${PROJECT_SOURCE_DIR}/examples/platforms + ${PROJECT_SOURCE_DIR}/examples/platforms/utils + ${PROJECT_SOURCE_DIR}/src/core + ${PROJECT_SOURCE_DIR}/third_party/jlink/SEGGER_RTT_V640/RTT ) # Provide a static library implementation of platform-utils for non-cmake platforms diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 765312a9d..33c9d9ec5 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -41,8 +41,8 @@ target_compile_definitions(openthread-cli-mtd PRIVATE set(COMMON_INCLUDES ${OT_PRIVATE_INCLUDES} - ${OT_ROOT_DIR}/src - ${OT_ROOT_DIR}/src/core + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/src/core ) set(COMMON_SOURCES diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index cc5634ec4..99c58cdea 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -47,7 +47,7 @@ target_compile_definitions(openthread-radio PRIVATE set(COMMON_INCLUDES ${OT_PRIVATE_INCLUDES} - ${OT_ROOT_DIR}/src/core + ${PROJECT_SOURCE_DIR}/src/core ) set(COMMON_SOURCES diff --git a/src/ncp/CMakeLists.txt b/src/ncp/CMakeLists.txt index 3b05b8e3a..e45ffb040 100644 --- a/src/ncp/CMakeLists.txt +++ b/src/ncp/CMakeLists.txt @@ -50,8 +50,8 @@ target_compile_definitions(openthread-rcp PRIVATE set(COMMON_INCLUDES ${OT_PRIVATE_INCLUDES} - ${OT_ROOT_DIR}/src - ${OT_ROOT_DIR}/src/core + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/src/core ) set(COMMON_SOURCES diff --git a/third_party/mbedtls/CMakeLists.txt b/third_party/mbedtls/CMakeLists.txt index 026145441..00ca41610 100644 --- a/third_party/mbedtls/CMakeLists.txt +++ b/third_party/mbedtls/CMakeLists.txt @@ -35,7 +35,7 @@ target_compile_definitions(mbedcrypto PRIVATE target_include_directories(mbedcrypto PRIVATE ${OT_PUBLIC_INCLUDES} ${OT_PRIVATE_INCLUDES} - ${OT_ROOT_DIR}/src/core + ${PROJECT_SOURCE_DIR}/src/core ) target_sources(mbedcrypto PRIVATE