fix cmake code smell issues

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
This commit is contained in:
xuxin19 2023-09-04 11:04:29 +08:00 committed by Xiang Xiao
parent c57794fe1f
commit 2432a62ab6
11 changed files with 49 additions and 72 deletions

View File

@ -25,7 +25,8 @@ if(CONFIG_BENCHMARK_COREMARK)
# ############################################################################
set(COREMARKAPP_DIR ${CMAKE_CURRENT_LIST_DIR}/coremark)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/coremark)
if(NOT EXISTS ${COREMARKAPP_DIR})
FetchContent_Declare(
coremark_fetch
URL https://github.com/eembc/coremark/archive/main.zip SOURCE_DIR
@ -38,8 +39,6 @@ if(CONFIG_BENCHMARK_COREMARK)
if(NOT coremark_fetch_POPULATED)
FetchContent_Populate(coremark_fetch)
endif()
set(COREMARKAPP_DIR ${coremark_fetch_SOURCE_DIR})
endif()
if(CONFIG_COREMARK_MULTITHREAD_OVERRIDE)

View File

@ -26,7 +26,7 @@ if(CONFIG_CANUTILS_LELYCANOPEN)
set(LELYCANOPEN_DIR ${CMAKE_CURRENT_LIST_DIR}/lely-canopen)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/lely-canopen)
if(NOT EXISTS ${LELYCANOPEN_DIR})
FetchContent_Declare(
lelycanopen_fetch
URL ${CONFIG_CANUTILS_LELYCANOPEN_URL}/lely-core-${CONFIG_CANUTILS_LELYCANOPEN_VERSION}.tar.gz
@ -44,9 +44,6 @@ if(CONFIG_CANUTILS_LELYCANOPEN)
if(NOT lelycanopen_fetch_POPULATED)
FetchContent_Populate(lelycanopen_fetch)
endif()
set(LELYCANOPEN_DIR ${lelycanopen_fetch_SOURCE_DIR})
endif()
nuttx_add_library(lelycanopen STATIC)

View File

@ -26,7 +26,7 @@ if(CONFIG_CANUTILS_LIBDRONECAN)
set(LIBDRONECAN_DIR ${CMAKE_CURRENT_LIST_DIR}/libcanard)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libcanard)
if(NOT EXISTS ${LIBDRONECAN_DIR})
FetchContent_Declare(
libdronecan_fetch
URL ${CONFIG_LIBDRONECAN_URL}/${CONFIG_LIBDRONECAN_VERSION}.zip SOURCE_DIR
@ -40,8 +40,6 @@ if(CONFIG_CANUTILS_LIBDRONECAN)
if(NOT libdronecan_fetch_POPULATED)
FetchContent_Populate(libdronecan_fetch)
endif()
set(LIBDRONECAN_DIR ${libdronecan_fetch_SOURCE_DIR})
endif()
# ############################################################################

View File

@ -25,7 +25,7 @@ if(CONFIG_CANUTILS_LIBOPENCYPHAL)
# ############################################################################
set(LIBOPENCYPHAL_DIR ${CMAKE_CURRENT_LIST_DIR}/libcanard)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libcanard)
if(NOT EXISTS ${LIBOPENCYPHAL_DIR})
FetchContent_Declare(
libcanard_fetch
URL ${CONFIG_LIBOPENCYPHAL_URL}/${CONFIG_LIBOPENCYPHAL_VERSION}.zip
@ -37,11 +37,10 @@ if(CONFIG_CANUTILS_LIBOPENCYPHAL)
if(NOT libcanard_fetch_POPULATED)
FetchContent_Populate(libcanard_fetch)
endif()
set(LIBOPENCYPHAL_DIR ${libcanard_fetch_SOURCE_DIR})
endif()
set(O1HEAP_DIR ${CMAKE_CURRENT_LIST_DIR}/o1heap)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/o1heap)
if(NOT EXISTS ${O1HEAP_DIR})
FetchContent_Declare(
o1heap_fetch
URL ${CONFIG_O1HEAP_URL}/${CONFIG_O1HEAP_VERSION}.zip SOURCE_DIR
@ -53,7 +52,6 @@ if(CONFIG_CANUTILS_LIBOPENCYPHAL)
if(NOT o1heap_fetch_POPULATED)
FetchContent_Populate(o1heap_fetch)
endif()
set(O1HEAP_DIR ${o1heap_fetch_SOURCE_DIR})
endif()
# ############################################################################

View File

@ -23,11 +23,11 @@ if(CONFIG_LIBSODIUM)
# ############################################################################
# Config and Fetch libsodium lib
# ############################################################################
set(LIBSODIUM_URL https://github.com/jedisct1/libsodium/archive)
set(LIBSODIUM_DIR ${CMAKE_CURRENT_LIST_DIR}/libsodium)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libsodium)
if(NOT EXISTS ${LIBSODIUM_DIR})
set(LIBSODIUM_URL https://github.com/jedisct1/libsodium/archive)
FetchContent_Declare(
libsodium_fetch
URL ${LIBSODIUM_URL}/${CONFIG_LIBSODIUM_VERSION}.zip SOURCE_DIR
@ -46,8 +46,6 @@ if(CONFIG_LIBSODIUM)
if(NOT libsodium_fetch_POPULATED)
FetchContent_Populate(libsodium_fetch)
endif()
set(LIBSODIUM_DIR ${libsodium_fetch_SOURCE_DIR})
endif()
# ############################################################################

View File

@ -23,12 +23,11 @@ if(CONFIG_CRYPTO_LIBTOMCRYPT)
# ############################################################################
# Config and Fetch libtomcrypt
# ############################################################################
set(CONFIG_LIBTOMCRYPT_URL https://github.com/libtom/libtomcrypt/archive)
set(LIBTOMCRYPT_DIR ${CMAKE_CURRENT_LIST_DIR}/libtomcrypt)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libtomcrypt)
if(NOT EXISTS ${LIBTOMCRYPT_DIR})
set(CONFIG_LIBTOMCRYPT_URL https://github.com/libtom/libtomcrypt/archive)
FetchContent_Declare(
libtomcrypt_fetch
URL ${CONFIG_LIBTOMCRYPT_URL}/v${CONFIG_LIBTOMCRYPT_VERSION}.zip
@ -47,9 +46,6 @@ if(CONFIG_CRYPTO_LIBTOMCRYPT)
if(NOT libtomcrypt_fetch_POPULATED)
FetchContent_Populate(libtomcrypt_fetch)
endif()
set(LIBTOMCRYPT_DIR ${libtomcrypt_fetch_SOURCE_DIR})
endif()
nuttx_add_library(libtomcrypt STATIC)
@ -496,7 +492,7 @@ if(CONFIG_CRYPTO_LIBTOMCRYPT)
DEPENDS
libtomcrypt)
endif(CONFIG_LIBTOMCRYPT_LTCRYPT)
endif()
if(CONFIG_LIBTOMCRYPT_HASHSUM)
@ -514,9 +510,9 @@ if(CONFIG_CRYPTO_LIBTOMCRYPT)
DEPENDS
libtomcrypt)
endif(CONFIG_LIBTOMCRYPT_HASHSUM)
endif()
endif(CONFIG_LIBTOMCRYPT_DEMOS)
endif()
# ############################################################################
# Library Configuration

View File

@ -23,11 +23,11 @@ if(CONFIG_CRYPTO_MBEDTLS)
# ############################################################################
# Config and Fetch MbedTLS lib
# ############################################################################
set(MBEDTLS_URL https://github.com/ARMmbed/mbedtls/archive)
set(MBEDTLS_DIR ${CMAKE_CURRENT_LIST_DIR}/mbedtls)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/mbedtls)
if(NOT EXISTS ${MBEDTLS_DIR})
set(MBEDTLS_URL https://github.com/ARMmbed/mbedtls/archive)
FetchContent_Declare(
mbedtls_fetch
URL ${MBEDTLS_URL}/v${CONFIG_MBEDTLS_VERSION}.zip SOURCE_DIR
@ -41,7 +41,6 @@ if(CONFIG_CRYPTO_MBEDTLS)
if(NOT mbedtls_fetch_POPULATED)
FetchContent_Populate(mbedtls_fetch)
endif()
set(MBEDTLS_DIR ${mbedtls_fetch_SOURCE_DIR})
endif()
# ############################################################################
@ -51,7 +50,7 @@ if(CONFIG_CRYPTO_MBEDTLS)
set_source_files_properties(${MBEDTLS_DIR}/library/bignum.c
PROPERTIES COMPILE_FLAGS -fno-lto)
if(CONFIG_FRAME_POINTER STREQUAL y)
if(CONFIG_FRAME_POINTER)
if(CONFIG_DEBUG_OPTLEVEL STREQUAL -O3)
set_source_files_properties(${MBEDTLS_DIR}/library/sha246.c
PROPERTIES COMPILE_FLAGS -O2)
@ -74,14 +73,14 @@ if(CONFIG_CRYPTO_MBEDTLS)
# Library Configuration
# ############################################################################
nuttx_add_library(mbedtls_nuttx STATIC)
nuttx_add_library(mbedtls STATIC)
target_sources(mbedtls_nuttx PRIVATE ${CSRCS})
target_include_directories(mbedtls_nuttx PRIVATE ${INCDIR})
target_compile_definitions(mbedtls_nuttx PRIVATE __unix__)
target_sources(mbedtls PRIVATE ${CSRCS})
target_include_directories(mbedtls PRIVATE ${INCDIR})
target_compile_definitions(mbedtls PRIVATE __unix__)
if(CONFIG_ARCH_SIM STREQUAL y)
target_compile_options(mbedtls_nuttx PRIVATE -O0)
if(CONFIG_ARCH_SIM)
target_compile_options(mbedtls PRIVATE -O0)
endif()
# ############################################################################
@ -90,7 +89,7 @@ if(CONFIG_CRYPTO_MBEDTLS)
if(CONFIG_MBEDTLS_APPS)
if(CONFIG_MBEDTLS_APP_BENCHMARK STREQUAL y)
if(CONFIG_MBEDTLS_APP_BENCHMARK)
nuttx_add_application(
MODULE
${CONFIG_MBEDTLS_APPS}
@ -108,7 +107,7 @@ if(CONFIG_CRYPTO_MBEDTLS)
mbedtls_nuttx)
endif()
if(CONFIG_MBEDTLS_APP_SELFTEST STREQUAL y)
if(CONFIG_MBEDTLS_APP_SELFTEST)
nuttx_add_application(
MODULE
${CONFIG_MBEDTLS_APPS}
@ -126,6 +125,6 @@ if(CONFIG_CRYPTO_MBEDTLS)
mbedtls_nuttx)
endif()
endif(CONFIG_MBEDTLS_APPS)
endif()
endif()

View File

@ -23,16 +23,14 @@ if(CONFIG_TINYCRYPT)
# ############################################################################
# Config and Fetch tinycrypt
# ############################################################################
set(TINYCRYPT_VERSION ${CONFIG_TINYCRYPT_VERSION})
set(TINYCRYPT_URL
https://github.com/intel/tinycrypt/archive/refs/tags/v${TINYCRYPT_VERSION}.zip
)
set(TINYCRYPT_DIR ${CMAKE_CURRENT_LIST_DIR}/tinycrypt)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/tinycrypt)
if(NOT EXISTS ${TINYCRYPT_DIR})
set(TINYCRYPT_VERSION ${CONFIG_TINYCRYPT_VERSION})
set(TINYCRYPT_URL
https://github.com/intel/tinycrypt/archive/refs/tags/v${TINYCRYPT_VERSION}.zip
)
FetchContent_Declare(
tinycrypt_fetch
URL ${TINYCRYPT_URL} SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/tinycrypt
@ -48,8 +46,6 @@ if(CONFIG_TINYCRYPT)
if(NOT tinycrypt_fetch_POPULATED)
FetchContent_Populate(tinycrypt_fetch)
endif()
set(TINYCRYPT_DIR ${tinycrypt_fetch_SOURCE_DIR})
endif()
nuttx_add_library(tinycrypt STATIC)
@ -68,48 +64,48 @@ if(CONFIG_TINYCRYPT)
${TINYCRYPT_DIR}/lib/source/utils.c ${TINYCRYPT_DIR}/lib/source/ecc.c
${TINYCRYPT_DIR}/lib/source/ecc_platform_specific.c)
if(CONFIG_TINYCRYPT_ECC_DH STREQUAL y)
if(CONFIG_TINYCRYPT_ECC_DH)
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/ecc_dh.c)
endif()
if(CONFIG_TINYCRYPT_ECC_DSA STREQUAL y)
if(CONFIG_TINYCRYPT_ECC_DSA)
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/ecc_dsa.c)
endif()
if(CONFIG_TINYCRYPT_AES STREQUAL y)
if(CONFIG_TINYCRYPT_AES)
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/aes_encrypt.c
${TINYCRYPT_DIR}/lib/source/aes_decrypt.c)
endif()
if(CONFIG_TINYCRYPT_AES_CBC STREQUAL y)
if(CONFIG_TINYCRYPT_AES_CBC)
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/cbc_mode.c)
endif()
if(CONFIG_TINYCRYPT_AES_CTR STREQUAL y)
if(CONFIG_TINYCRYPT_AES_CTR)
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/ctr_mode.c)
endif()
if(CONFIG_TINYCRYPT_AES_CCM STREQUAL y)
if(CONFIG_TINYCRYPT_AES_CCM)
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/ccm_mode.c)
endif()
if(CONFIG_TINYCRYPT_AES_CMAC STREQUAL y)
if(CONFIG_TINYCRYPT_AES_CMAC)
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/cmac_mode.c)
endif()
if(CONFIG_TINYCRYPT_SHA256 STREQUAL y)
if(CONFIG_TINYCRYPT_SHA256)
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/sha256.c)
endif()
if(CONFIG_TINYCRYPT_SHA256_HMAC STREQUAL y)
if(CONFIG_TINYCRYPT_SHA256_HMAC)
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/hmac.c)
endif()
if(CONFIG_TINYCRYPT_SHA256_HMAC_PRNG STREQUAL y)
if(CONFIG_TINYCRYPT_SHA256_HMAC_PRNG)
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/hmac_prng.c)
endif()
if(CONFIG_TINYCRYPT_CTR_PRNG STREQUAL y)
if(CONFIG_TINYCRYPT_CTR_PRNG)
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/ctr_prng.c)
endif()
@ -117,7 +113,7 @@ if(CONFIG_TINYCRYPT)
# Applications Configuration
# ############################################################################
if(CONFIG_TINYCRYPT_TEST STREQUAL y)
if(CONFIG_TINYCRYPT_TEST)
list(APPEND CSRCS ${TINYCRYPT_DIR}/tests/test_ecc_utils.c)
list(APPEND INCDIR ${TINYCRYPT_DIR}/tests/include)
set(CFLAGS -Dhex2bin=ltp_hex2bin -DENABLE_TESTS)

View File

@ -25,7 +25,7 @@ if(CONFIG_FSUTILS_INIH)
# ############################################################################
set(INIH_DIR ${CMAKE_CURRENT_LIST_DIR}/inih-r42)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/inih-r42)
if(NOT EXISTS ${INIH_DIR})
set(INIH_URL https://github.com/benhoyt/inih/archive/r42.tar.gz)
FetchContent_Declare(
inih_fetch
@ -38,8 +38,6 @@ if(CONFIG_FSUTILS_INIH)
if(NOT inih_fetch_POPULATED)
FetchContent_Populate(inih_fetch)
endif()
set(INIH_DIR ${inih_fetch_SOURCE_DIR})
endif()
# ############################################################################

View File

@ -25,7 +25,7 @@ if(CONFIG_FSUTILS_TINYCBOR_LIB)
# ############################################################################
set(TINYCBOR_DIR ${CMAKE_CURRENT_LIST_DIR}/tinycbor)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/tinycbor)
if(NOT EXISTS ${TINYCBOR_DIR})
set(TINYCBOR_VERSION 3cba6b11aaa0f6f674cd56ebaa573c4b65f71ee7)
set(TINYCBOR_URL
https://github.com/intel/tinycbor/archive/${TINYCBOR_VERSION}.zip)

View File

@ -23,11 +23,11 @@ if(CONFIG_MATH_LIBTOMMATH)
# ############################################################################
# Config and Fetch Tommath lib
# ############################################################################
set(CONFIG_LIBTOMMATH_URL https://github.com/libtom/libtommath/archive)
set(LIBTOMMATH_DIR ${CMAKE_CURRENT_LIST_DIR}/libtommath)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libtommath)
if(NOT EXISTS ${LIBTOMMATH_DIR})
set(CONFIG_LIBTOMMATH_URL https://github.com/libtom/libtommath/archive)
FetchContent_Declare(
libtommath_fetch
URL ${CONFIG_LIBTOMMATH_URL}/v${CONFIG_LIBTOMMATH_VERSION}.zip SOURCE_DIR
@ -40,8 +40,6 @@ if(CONFIG_MATH_LIBTOMMATH)
if(NOT libtommath_fetch_POPULATED)
FetchContent_Populate(libtommath_fetch)
endif()
set(LIBTOMMATH_DIR ${libtommath_fetch_SOURCE_DIR})
endif()
# ############################################################################