Skip to content

Commit 2432a62

Browse files
xuxin930xiaoxiang781216
authored andcommitted
fix cmake code smell issues
Signed-off-by: xuxin19 <[email protected]>
1 parent c57794f commit 2432a62

File tree

11 files changed

+49
-72
lines changed

11 files changed

+49
-72
lines changed

benchmarks/coremark/CMakeLists.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ if(CONFIG_BENCHMARK_COREMARK)
2525
# ############################################################################
2626

2727
set(COREMARKAPP_DIR ${CMAKE_CURRENT_LIST_DIR}/coremark)
28-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/coremark)
28+
29+
if(NOT EXISTS ${COREMARKAPP_DIR})
2930
FetchContent_Declare(
3031
coremark_fetch
3132
URL https://github.com/eembc/coremark/archive/main.zip SOURCE_DIR
@@ -38,8 +39,6 @@ if(CONFIG_BENCHMARK_COREMARK)
3839
if(NOT coremark_fetch_POPULATED)
3940
FetchContent_Populate(coremark_fetch)
4041
endif()
41-
42-
set(COREMARKAPP_DIR ${coremark_fetch_SOURCE_DIR})
4342
endif()
4443

4544
if(CONFIG_COREMARK_MULTITHREAD_OVERRIDE)

canutils/lely-canopen/CMakeLists.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(CONFIG_CANUTILS_LELYCANOPEN)
2626

2727
set(LELYCANOPEN_DIR ${CMAKE_CURRENT_LIST_DIR}/lely-canopen)
2828

29-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/lely-canopen)
29+
if(NOT EXISTS ${LELYCANOPEN_DIR})
3030
FetchContent_Declare(
3131
lelycanopen_fetch
3232
URL ${CONFIG_CANUTILS_LELYCANOPEN_URL}/lely-core-${CONFIG_CANUTILS_LELYCANOPEN_VERSION}.tar.gz
@@ -44,9 +44,6 @@ if(CONFIG_CANUTILS_LELYCANOPEN)
4444
if(NOT lelycanopen_fetch_POPULATED)
4545
FetchContent_Populate(lelycanopen_fetch)
4646
endif()
47-
48-
set(LELYCANOPEN_DIR ${lelycanopen_fetch_SOURCE_DIR})
49-
5047
endif()
5148

5249
nuttx_add_library(lelycanopen STATIC)

canutils/libdronecan/CMakeLists.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(CONFIG_CANUTILS_LIBDRONECAN)
2626

2727
set(LIBDRONECAN_DIR ${CMAKE_CURRENT_LIST_DIR}/libcanard)
2828

29-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libcanard)
29+
if(NOT EXISTS ${LIBDRONECAN_DIR})
3030
FetchContent_Declare(
3131
libdronecan_fetch
3232
URL ${CONFIG_LIBDRONECAN_URL}/${CONFIG_LIBDRONECAN_VERSION}.zip SOURCE_DIR
@@ -40,8 +40,6 @@ if(CONFIG_CANUTILS_LIBDRONECAN)
4040
if(NOT libdronecan_fetch_POPULATED)
4141
FetchContent_Populate(libdronecan_fetch)
4242
endif()
43-
44-
set(LIBDRONECAN_DIR ${libdronecan_fetch_SOURCE_DIR})
4543
endif()
4644

4745
# ############################################################################

canutils/libopencyphal/CMakeLists.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if(CONFIG_CANUTILS_LIBOPENCYPHAL)
2525
# ############################################################################
2626

2727
set(LIBOPENCYPHAL_DIR ${CMAKE_CURRENT_LIST_DIR}/libcanard)
28-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libcanard)
28+
if(NOT EXISTS ${LIBOPENCYPHAL_DIR})
2929
FetchContent_Declare(
3030
libcanard_fetch
3131
URL ${CONFIG_LIBOPENCYPHAL_URL}/${CONFIG_LIBOPENCYPHAL_VERSION}.zip
@@ -37,11 +37,10 @@ if(CONFIG_CANUTILS_LIBOPENCYPHAL)
3737
if(NOT libcanard_fetch_POPULATED)
3838
FetchContent_Populate(libcanard_fetch)
3939
endif()
40-
set(LIBOPENCYPHAL_DIR ${libcanard_fetch_SOURCE_DIR})
4140
endif()
4241

4342
set(O1HEAP_DIR ${CMAKE_CURRENT_LIST_DIR}/o1heap)
44-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/o1heap)
43+
if(NOT EXISTS ${O1HEAP_DIR})
4544
FetchContent_Declare(
4645
o1heap_fetch
4746
URL ${CONFIG_O1HEAP_URL}/${CONFIG_O1HEAP_VERSION}.zip SOURCE_DIR
@@ -53,7 +52,6 @@ if(CONFIG_CANUTILS_LIBOPENCYPHAL)
5352
if(NOT o1heap_fetch_POPULATED)
5453
FetchContent_Populate(o1heap_fetch)
5554
endif()
56-
set(O1HEAP_DIR ${o1heap_fetch_SOURCE_DIR})
5755
endif()
5856

5957
# ############################################################################

crypto/libsodium/CMakeLists.txt

+3-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ if(CONFIG_LIBSODIUM)
2323
# ############################################################################
2424
# Config and Fetch libsodium lib
2525
# ############################################################################
26-
set(LIBSODIUM_URL https://github.com/jedisct1/libsodium/archive)
27-
2826
set(LIBSODIUM_DIR ${CMAKE_CURRENT_LIST_DIR}/libsodium)
2927

30-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libsodium)
28+
if(NOT EXISTS ${LIBSODIUM_DIR})
29+
set(LIBSODIUM_URL https://github.com/jedisct1/libsodium/archive)
30+
3131
FetchContent_Declare(
3232
libsodium_fetch
3333
URL ${LIBSODIUM_URL}/${CONFIG_LIBSODIUM_VERSION}.zip SOURCE_DIR
@@ -46,8 +46,6 @@ if(CONFIG_LIBSODIUM)
4646
if(NOT libsodium_fetch_POPULATED)
4747
FetchContent_Populate(libsodium_fetch)
4848
endif()
49-
set(LIBSODIUM_DIR ${libsodium_fetch_SOURCE_DIR})
50-
5149
endif()
5250

5351
# ############################################################################

crypto/libtomcrypt/CMakeLists.txt

+6-10
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ if(CONFIG_CRYPTO_LIBTOMCRYPT)
2323
# ############################################################################
2424
# Config and Fetch libtomcrypt
2525
# ############################################################################
26-
27-
set(CONFIG_LIBTOMCRYPT_URL https://github.com/libtom/libtomcrypt/archive)
28-
2926
set(LIBTOMCRYPT_DIR ${CMAKE_CURRENT_LIST_DIR}/libtomcrypt)
3027

31-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libtomcrypt)
28+
if(NOT EXISTS ${LIBTOMCRYPT_DIR})
29+
set(CONFIG_LIBTOMCRYPT_URL https://github.com/libtom/libtomcrypt/archive)
30+
3231
FetchContent_Declare(
3332
libtomcrypt_fetch
3433
URL ${CONFIG_LIBTOMCRYPT_URL}/v${CONFIG_LIBTOMCRYPT_VERSION}.zip
@@ -47,9 +46,6 @@ if(CONFIG_CRYPTO_LIBTOMCRYPT)
4746
if(NOT libtomcrypt_fetch_POPULATED)
4847
FetchContent_Populate(libtomcrypt_fetch)
4948
endif()
50-
51-
set(LIBTOMCRYPT_DIR ${libtomcrypt_fetch_SOURCE_DIR})
52-
5349
endif()
5450

5551
nuttx_add_library(libtomcrypt STATIC)
@@ -496,7 +492,7 @@ if(CONFIG_CRYPTO_LIBTOMCRYPT)
496492
DEPENDS
497493
libtomcrypt)
498494

499-
endif(CONFIG_LIBTOMCRYPT_LTCRYPT)
495+
endif()
500496

501497
if(CONFIG_LIBTOMCRYPT_HASHSUM)
502498

@@ -514,9 +510,9 @@ if(CONFIG_CRYPTO_LIBTOMCRYPT)
514510
DEPENDS
515511
libtomcrypt)
516512

517-
endif(CONFIG_LIBTOMCRYPT_HASHSUM)
513+
endif()
518514

519-
endif(CONFIG_LIBTOMCRYPT_DEMOS)
515+
endif()
520516

521517
# ############################################################################
522518
# Library Configuration

crypto/mbedtls/CMakeLists.txt

+12-13
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ if(CONFIG_CRYPTO_MBEDTLS)
2323
# ############################################################################
2424
# Config and Fetch MbedTLS lib
2525
# ############################################################################
26-
set(MBEDTLS_URL https://github.com/ARMmbed/mbedtls/archive)
2726

2827
set(MBEDTLS_DIR ${CMAKE_CURRENT_LIST_DIR}/mbedtls)
2928

30-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/mbedtls)
29+
if(NOT EXISTS ${MBEDTLS_DIR})
30+
set(MBEDTLS_URL https://github.com/ARMmbed/mbedtls/archive)
3131
FetchContent_Declare(
3232
mbedtls_fetch
3333
URL ${MBEDTLS_URL}/v${CONFIG_MBEDTLS_VERSION}.zip SOURCE_DIR
@@ -41,7 +41,6 @@ if(CONFIG_CRYPTO_MBEDTLS)
4141
if(NOT mbedtls_fetch_POPULATED)
4242
FetchContent_Populate(mbedtls_fetch)
4343
endif()
44-
set(MBEDTLS_DIR ${mbedtls_fetch_SOURCE_DIR})
4544
endif()
4645

4746
# ############################################################################
@@ -51,7 +50,7 @@ if(CONFIG_CRYPTO_MBEDTLS)
5150
set_source_files_properties(${MBEDTLS_DIR}/library/bignum.c
5251
PROPERTIES COMPILE_FLAGS -fno-lto)
5352

54-
if(CONFIG_FRAME_POINTER STREQUAL y)
53+
if(CONFIG_FRAME_POINTER)
5554
if(CONFIG_DEBUG_OPTLEVEL STREQUAL -O3)
5655
set_source_files_properties(${MBEDTLS_DIR}/library/sha246.c
5756
PROPERTIES COMPILE_FLAGS -O2)
@@ -74,14 +73,14 @@ if(CONFIG_CRYPTO_MBEDTLS)
7473
# Library Configuration
7574
# ############################################################################
7675

77-
nuttx_add_library(mbedtls_nuttx STATIC)
76+
nuttx_add_library(mbedtls STATIC)
7877

79-
target_sources(mbedtls_nuttx PRIVATE ${CSRCS})
80-
target_include_directories(mbedtls_nuttx PRIVATE ${INCDIR})
81-
target_compile_definitions(mbedtls_nuttx PRIVATE __unix__)
78+
target_sources(mbedtls PRIVATE ${CSRCS})
79+
target_include_directories(mbedtls PRIVATE ${INCDIR})
80+
target_compile_definitions(mbedtls PRIVATE __unix__)
8281

83-
if(CONFIG_ARCH_SIM STREQUAL y)
84-
target_compile_options(mbedtls_nuttx PRIVATE -O0)
82+
if(CONFIG_ARCH_SIM)
83+
target_compile_options(mbedtls PRIVATE -O0)
8584
endif()
8685

8786
# ############################################################################
@@ -90,7 +89,7 @@ if(CONFIG_CRYPTO_MBEDTLS)
9089

9190
if(CONFIG_MBEDTLS_APPS)
9291

93-
if(CONFIG_MBEDTLS_APP_BENCHMARK STREQUAL y)
92+
if(CONFIG_MBEDTLS_APP_BENCHMARK)
9493
nuttx_add_application(
9594
MODULE
9695
${CONFIG_MBEDTLS_APPS}
@@ -108,7 +107,7 @@ if(CONFIG_CRYPTO_MBEDTLS)
108107
mbedtls_nuttx)
109108
endif()
110109

111-
if(CONFIG_MBEDTLS_APP_SELFTEST STREQUAL y)
110+
if(CONFIG_MBEDTLS_APP_SELFTEST)
112111
nuttx_add_application(
113112
MODULE
114113
${CONFIG_MBEDTLS_APPS}
@@ -126,6 +125,6 @@ if(CONFIG_CRYPTO_MBEDTLS)
126125
mbedtls_nuttx)
127126
endif()
128127

129-
endif(CONFIG_MBEDTLS_APPS)
128+
endif()
130129

131130
endif()

crypto/tinycrypt/CMakeLists.txt

+18-22
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ if(CONFIG_TINYCRYPT)
2323
# ############################################################################
2424
# Config and Fetch tinycrypt
2525
# ############################################################################
26-
27-
set(TINYCRYPT_VERSION ${CONFIG_TINYCRYPT_VERSION})
28-
29-
set(TINYCRYPT_URL
30-
https://github.com/intel/tinycrypt/archive/refs/tags/v${TINYCRYPT_VERSION}.zip
31-
)
32-
3326
set(TINYCRYPT_DIR ${CMAKE_CURRENT_LIST_DIR}/tinycrypt)
3427

35-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/tinycrypt)
28+
if(NOT EXISTS ${TINYCRYPT_DIR})
29+
set(TINYCRYPT_VERSION ${CONFIG_TINYCRYPT_VERSION})
30+
31+
set(TINYCRYPT_URL
32+
https://github.com/intel/tinycrypt/archive/refs/tags/v${TINYCRYPT_VERSION}.zip
33+
)
3634
FetchContent_Declare(
3735
tinycrypt_fetch
3836
URL ${TINYCRYPT_URL} SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/tinycrypt
@@ -48,8 +46,6 @@ if(CONFIG_TINYCRYPT)
4846
if(NOT tinycrypt_fetch_POPULATED)
4947
FetchContent_Populate(tinycrypt_fetch)
5048
endif()
51-
set(TINYCRYPT_DIR ${tinycrypt_fetch_SOURCE_DIR})
52-
5349
endif()
5450

5551
nuttx_add_library(tinycrypt STATIC)
@@ -68,56 +64,56 @@ if(CONFIG_TINYCRYPT)
6864
${TINYCRYPT_DIR}/lib/source/utils.c ${TINYCRYPT_DIR}/lib/source/ecc.c
6965
${TINYCRYPT_DIR}/lib/source/ecc_platform_specific.c)
7066

71-
if(CONFIG_TINYCRYPT_ECC_DH STREQUAL y)
67+
if(CONFIG_TINYCRYPT_ECC_DH)
7268
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/ecc_dh.c)
7369
endif()
7470

75-
if(CONFIG_TINYCRYPT_ECC_DSA STREQUAL y)
71+
if(CONFIG_TINYCRYPT_ECC_DSA)
7672
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/ecc_dsa.c)
7773
endif()
7874

79-
if(CONFIG_TINYCRYPT_AES STREQUAL y)
75+
if(CONFIG_TINYCRYPT_AES)
8076
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/aes_encrypt.c
8177
${TINYCRYPT_DIR}/lib/source/aes_decrypt.c)
8278
endif()
8379

84-
if(CONFIG_TINYCRYPT_AES_CBC STREQUAL y)
80+
if(CONFIG_TINYCRYPT_AES_CBC)
8581
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/cbc_mode.c)
8682
endif()
8783

88-
if(CONFIG_TINYCRYPT_AES_CTR STREQUAL y)
84+
if(CONFIG_TINYCRYPT_AES_CTR)
8985
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/ctr_mode.c)
9086
endif()
9187

92-
if(CONFIG_TINYCRYPT_AES_CCM STREQUAL y)
88+
if(CONFIG_TINYCRYPT_AES_CCM)
9389
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/ccm_mode.c)
9490
endif()
9591

96-
if(CONFIG_TINYCRYPT_AES_CMAC STREQUAL y)
92+
if(CONFIG_TINYCRYPT_AES_CMAC)
9793
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/cmac_mode.c)
9894
endif()
9995

100-
if(CONFIG_TINYCRYPT_SHA256 STREQUAL y)
96+
if(CONFIG_TINYCRYPT_SHA256)
10197
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/sha256.c)
10298
endif()
10399

104-
if(CONFIG_TINYCRYPT_SHA256_HMAC STREQUAL y)
100+
if(CONFIG_TINYCRYPT_SHA256_HMAC)
105101
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/hmac.c)
106102
endif()
107103

108-
if(CONFIG_TINYCRYPT_SHA256_HMAC_PRNG STREQUAL y)
104+
if(CONFIG_TINYCRYPT_SHA256_HMAC_PRNG)
109105
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/hmac_prng.c)
110106
endif()
111107

112-
if(CONFIG_TINYCRYPT_CTR_PRNG STREQUAL y)
108+
if(CONFIG_TINYCRYPT_CTR_PRNG)
113109
list(APPEND CSRCS ${TINYCRYPT_DIR}/lib/source/ctr_prng.c)
114110
endif()
115111

116112
# ############################################################################
117113
# Applications Configuration
118114
# ############################################################################
119115

120-
if(CONFIG_TINYCRYPT_TEST STREQUAL y)
116+
if(CONFIG_TINYCRYPT_TEST)
121117
list(APPEND CSRCS ${TINYCRYPT_DIR}/tests/test_ecc_utils.c)
122118
list(APPEND INCDIR ${TINYCRYPT_DIR}/tests/include)
123119
set(CFLAGS -Dhex2bin=ltp_hex2bin -DENABLE_TESTS)

fsutils/inih/CMakeLists.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if(CONFIG_FSUTILS_INIH)
2525
# ############################################################################
2626
set(INIH_DIR ${CMAKE_CURRENT_LIST_DIR}/inih-r42)
2727

28-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/inih-r42)
28+
if(NOT EXISTS ${INIH_DIR})
2929
set(INIH_URL https://github.com/benhoyt/inih/archive/r42.tar.gz)
3030
FetchContent_Declare(
3131
inih_fetch
@@ -38,8 +38,6 @@ if(CONFIG_FSUTILS_INIH)
3838
if(NOT inih_fetch_POPULATED)
3939
FetchContent_Populate(inih_fetch)
4040
endif()
41-
42-
set(INIH_DIR ${inih_fetch_SOURCE_DIR})
4341
endif()
4442

4543
# ############################################################################

fsutils/libtinycbor/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if(CONFIG_FSUTILS_TINYCBOR_LIB)
2525
# ############################################################################
2626
set(TINYCBOR_DIR ${CMAKE_CURRENT_LIST_DIR}/tinycbor)
2727

28-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/tinycbor)
28+
if(NOT EXISTS ${TINYCBOR_DIR})
2929
set(TINYCBOR_VERSION 3cba6b11aaa0f6f674cd56ebaa573c4b65f71ee7)
3030
set(TINYCBOR_URL
3131
https://github.com/intel/tinycbor/archive/${TINYCBOR_VERSION}.zip)

math/libtommath/CMakeLists.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ if(CONFIG_MATH_LIBTOMMATH)
2323
# ############################################################################
2424
# Config and Fetch Tommath lib
2525
# ############################################################################
26-
set(CONFIG_LIBTOMMATH_URL https://github.com/libtom/libtommath/archive)
2726

2827
set(LIBTOMMATH_DIR ${CMAKE_CURRENT_LIST_DIR}/libtommath)
2928

30-
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libtommath)
29+
if(NOT EXISTS ${LIBTOMMATH_DIR})
30+
set(CONFIG_LIBTOMMATH_URL https://github.com/libtom/libtommath/archive)
3131
FetchContent_Declare(
3232
libtommath_fetch
3333
URL ${CONFIG_LIBTOMMATH_URL}/v${CONFIG_LIBTOMMATH_VERSION}.zip SOURCE_DIR
@@ -40,8 +40,6 @@ if(CONFIG_MATH_LIBTOMMATH)
4040
if(NOT libtommath_fetch_POPULATED)
4141
FetchContent_Populate(libtommath_fetch)
4242
endif()
43-
44-
set(LIBTOMMATH_DIR ${libtommath_fetch_SOURCE_DIR})
4543
endif()
4644

4745
# ############################################################################

0 commit comments

Comments
 (0)