From ed9a145f82cfd5cd9910cf0125707b92eeddea71 Mon Sep 17 00:00:00 2001 From: BenArtes Date: Thu, 22 Jul 2021 12:29:00 -0400 Subject: [PATCH 1/5] Adds EXISTS checks to BSP, CMSIS, FREERTOS, and HAL provided / ENV / default PATHs, else FATAL_ERROR (cherry picked from commit 59217734eada4e8661736ed994b44ae184bea5b8) --- cmake/FindBSP.cmake | 6 +++++- cmake/FindCMSIS.cmake | 4 ++++ cmake/FindFreeRTOS.cmake | 4 ++++ cmake/FindHAL.cmake | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cmake/FindBSP.cmake b/cmake/FindBSP.cmake index 951c6321..0ecefd83 100644 --- a/cmake/FindBSP.cmake +++ b/cmake/FindBSP.cmake @@ -270,7 +270,11 @@ foreach(COMP ${BSP_FIND_COMPONENTS}) set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}") message(STATUS "No STM32_CUBE_${FAMILY}_PATH specified using default: ${STM32_CUBE_${FAMILY}_PATH}") endif() - + + if (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH}) + message(FATAL_ERROR "STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' Does not Exist") + endif() + find_path(BSP_${FAMILY}_PATH NAMES Components/Common/io.h PATHS "${STM32_CUBE_${FAMILY}_PATH}/Drivers/BSP" diff --git a/cmake/FindCMSIS.cmake b/cmake/FindCMSIS.cmake index 3821538f..e88cb512 100644 --- a/cmake/FindCMSIS.cmake +++ b/cmake/FindCMSIS.cmake @@ -79,6 +79,10 @@ foreach(COMP ${CMSIS_FIND_COMPONENTS}) set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}") message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_CMSIS_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") endif() + + if ((NOT EXISTS ${STM32_CMSIS_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) + message(FATAL_ERROR "Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_CMSIS_${FAMILY}_PATH: '${STM32_CMSIS_${FAMILY}_PATH}' Exists") + endif() find_path(CMSIS_${FAMILY}${CORE_U}_CORE_PATH NAMES Include/cmsis_gcc.h diff --git a/cmake/FindFreeRTOS.cmake b/cmake/FindFreeRTOS.cmake index 0bd61010..aeb66271 100644 --- a/cmake/FindFreeRTOS.cmake +++ b/cmake/FindFreeRTOS.cmake @@ -16,6 +16,10 @@ if(NOT FREERTOS_PATH) message(STATUS "No FREERTOS_PATH specified using default: ${FREERTOS_PATH}") endif() +if (NOT EXISTS ${FREERTOS_PATH}) + message(FATAL_ERROR "FREERTOS_PATH: '${FREERTOS_PATH}' Does not Exist") +endif() + find_path(FreeRTOS_COMMON_INCLUDE NAMES FreeRTOS.h PATHS "${FREERTOS_PATH}" "${FREERTOS_PATH}/FreeRTOS" diff --git a/cmake/FindHAL.cmake b/cmake/FindHAL.cmake index 655d19e3..a3ba7f3d 100644 --- a/cmake/FindHAL.cmake +++ b/cmake/FindHAL.cmake @@ -246,6 +246,10 @@ foreach(COMP ${HAL_FIND_COMPONENTS_FAMILIES}) message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_HAL_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") endif() + if ((NOT EXISTS ${STM32_HAL_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) + message(FATAL_ERROR "Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_HAL_${FAMILY}_PATH: '${STM32_HAL_${FAMILY}_PATH}' Exists.") + endif() + #Checking HAL patch or release version unset(VERSION_INFO) find_file(PACKAGE_FILE NAMES package.xml PATHS ${STM32_CUBE_${FAMILY}_PATH}) From 7aae9f1919096c741bc99f833201e796d5bef70b Mon Sep 17 00:00:00 2001 From: BenArtes Date: Thu, 22 Jul 2021 18:39:36 -0400 Subject: [PATCH 2/5] Adds TEST_FAMILIES COMPONENTS to test/(bsp,cmsis,fetch,hal) (cherry picked from commit 8246a97f86830396fde9d16e285089ff6da135c3) --- tests/bsp/CMakeLists.txt | 10 +++++++--- tests/cmsis/CMakeLists.txt | 6 +++++- tests/fetch/CMakeLists.txt | 8 ++++++-- tests/hal/CMakeLists.txt | 8 ++++++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/tests/bsp/CMakeLists.txt b/tests/bsp/CMakeLists.txt index cf62092e..55f107fe 100644 --- a/tests/bsp/CMakeLists.txt +++ b/tests/bsp/CMakeLists.txt @@ -4,6 +4,7 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/stm32_gcc.cmake if(NOT TEST_FAMILIES) # Can't test H7 because it needs some non-free components set(TEST_FAMILIES F0 F1 F2 F3 F4 F7 G0 G4 L0 L1 L4) + message(STATUS "No Test Families, running with TEST_FAMILIES=[${TEST_FAMILIES}]") endif() # Nucleo boards can have different devices on it @@ -41,9 +42,12 @@ if(FETCH_ST_SOURCES) stm32_fetch_cube(${TEST_FAMILIES}) endif() -find_package(CMSIS REQUIRED) -find_package(HAL REQUIRED) -find_package(BSP REQUIRED) +set(COMP_LIST ${TEST_FAMILIES}) +list(TRANSFORM COMP_LIST PREPEND STM32) + +find_package(CMSIS COMPONENTS ${COMP_LIST} REQUIRED) +find_package(HAL COMPONENTS ${COMP_LIST} REQUIRED) +find_package(BSP COMPONENTS ${COMP_LIST} REQUIRED) set(SOURCES main.c) diff --git a/tests/cmsis/CMakeLists.txt b/tests/cmsis/CMakeLists.txt index 847d3440..7c375469 100644 --- a/tests/cmsis/CMakeLists.txt +++ b/tests/cmsis/CMakeLists.txt @@ -3,6 +3,7 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/stm32_gcc.cmake if(NOT TEST_FAMILIES) set(TEST_FAMILIES F0 F1 F2 F3 F4 F7 G0 G4 H7 L0 L1 L4 L5) + message(STATUS "No Test Families, running with TEST_FAMILIES=[${TEST_FAMILIES}]") endif() project(cmsis-test C ASM) @@ -11,7 +12,10 @@ if(FETCH_ST_SOURCES) stm32_fetch_cmsis(${TEST_FAMILIES}) endif() -find_package(CMSIS REQUIRED) +set(COMP_LIST ${TEST_FAMILIES}) +list(TRANSFORM COMP_LIST PREPEND STM32) + +find_package(CMSIS COMPONENTS ${COMP_LIST} REQUIRED) set(SOURCES main.c) diff --git a/tests/fetch/CMakeLists.txt b/tests/fetch/CMakeLists.txt index 66f4b807..5e9ed4dd 100644 --- a/tests/fetch/CMakeLists.txt +++ b/tests/fetch/CMakeLists.txt @@ -3,6 +3,7 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/stm32_gcc.cmake if(NOT TEST_FAMILIES) set(TEST_FAMILIES F0 F1 F2 F3 F4 F7 G0 G4 H7 L0 L1 L4 L5) + message(STATUS "No Test Families, running with TEST_FAMILIES=[${TEST_FAMILIES}]") endif() project(fetch-test C ASM) @@ -11,8 +12,11 @@ set(CMAKE_INCLUDE_CURRENT_DIR TRUE) stm32_fetch_cmsis(${TEST_FAMILIES}) stm32_fetch_hal(${TEST_FAMILIES}) -find_package(CMSIS REQUIRED) -find_package(HAL REQUIRED) +set(COMP_LIST ${TEST_FAMILIES}) +list(TRANSFORM COMP_LIST PREPEND STM32) + +find_package(CMSIS COMPONENTS ${COMP_LIST} REQUIRED) +find_package(HAL COMPONENTS ${COMP_LIST} REQUIRED) set(SOURCES main.c) diff --git a/tests/hal/CMakeLists.txt b/tests/hal/CMakeLists.txt index b28482ba..844cd87c 100644 --- a/tests/hal/CMakeLists.txt +++ b/tests/hal/CMakeLists.txt @@ -3,6 +3,7 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/stm32_gcc.cmake if(NOT TEST_FAMILIES) set(TEST_FAMILIES F0 F1 F2 F3 F4 F7 G0 G4 H7 L0 L1 L4 L5) + message(STATUS "No Test Families, running with TEST_FAMILIES=[${TEST_FAMILIES}]") endif() project(hal-test C ASM) @@ -13,8 +14,11 @@ if(FETCH_ST_SOURCES) stm32_fetch_hal(${TEST_FAMILIES}) endif() -find_package(CMSIS REQUIRED) -find_package(HAL REQUIRED) +set(COMP_LIST ${TEST_FAMILIES}) +list(TRANSFORM COMP_LIST PREPEND STM32) + +find_package(CMSIS COMPONENTS ${COMP_LIST} REQUIRED) +find_package(HAL COMPONENTS ${COMP_LIST} REQUIRED) set(SOURCES main.c) From 9206b2781d55836a01824bb036b0d2dacff3ad9c Mon Sep 17 00:00:00 2001 From: BenArtes Date: Fri, 23 Jul 2021 09:41:08 -0400 Subject: [PATCH 3/5] Only Check PATH Existence for REQUIRED COMPONENTS --- cmake/FindBSP.cmake | 4 ++-- cmake/FindCMSIS.cmake | 4 ++-- cmake/FindHAL.cmake | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/FindBSP.cmake b/cmake/FindBSP.cmake index 0ecefd83..9bba4c60 100644 --- a/cmake/FindBSP.cmake +++ b/cmake/FindBSP.cmake @@ -271,8 +271,8 @@ foreach(COMP ${BSP_FIND_COMPONENTS}) message(STATUS "No STM32_CUBE_${FAMILY}_PATH specified using default: ${STM32_CUBE_${FAMILY}_PATH}") endif() - if (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH}) - message(FATAL_ERROR "STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' Does not Exist") + if ((${BSP_FIND_REQUIRED_${COMP}}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH}_) + message(FATAL_ERROR "For REQUIRED COMPONENT: ${COMP}, STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' Does not Exist") endif() find_path(BSP_${FAMILY}_PATH diff --git a/cmake/FindCMSIS.cmake b/cmake/FindCMSIS.cmake index e88cb512..fab96a07 100644 --- a/cmake/FindCMSIS.cmake +++ b/cmake/FindCMSIS.cmake @@ -80,8 +80,8 @@ foreach(COMP ${CMSIS_FIND_COMPONENTS}) message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_CMSIS_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") endif() - if ((NOT EXISTS ${STM32_CMSIS_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) - message(FATAL_ERROR "Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_CMSIS_${FAMILY}_PATH: '${STM32_CMSIS_${FAMILY}_PATH}' Exists") + if ((${CMSIS_FIND_REQUIRED_${COMP}}) AND (NOT EXISTS ${STM32_CMSIS_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) + message(FATAL_ERROR "For REQUIRED COMPONENT: ${COMP}, Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_CMSIS_${FAMILY}_PATH: '${STM32_CMSIS_${FAMILY}_PATH}' Exists") endif() find_path(CMSIS_${FAMILY}${CORE_U}_CORE_PATH diff --git a/cmake/FindHAL.cmake b/cmake/FindHAL.cmake index a3ba7f3d..abc02cf1 100644 --- a/cmake/FindHAL.cmake +++ b/cmake/FindHAL.cmake @@ -246,8 +246,8 @@ foreach(COMP ${HAL_FIND_COMPONENTS_FAMILIES}) message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_HAL_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") endif() - if ((NOT EXISTS ${STM32_HAL_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) - message(FATAL_ERROR "Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_HAL_${FAMILY}_PATH: '${STM32_HAL_${FAMILY}_PATH}' Exists.") + if ((${HAL_FIND_REQUIRED_${COMP}}) AND (NOT EXISTS ${STM32_HAL_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) + message(FATAL_ERROR "For REQUIRED COMPONENT: ${COMP}, Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_HAL_${FAMILY}_PATH: '${STM32_HAL_${FAMILY}_PATH}' Exists.") endif() #Checking HAL patch or release version From 98628a361efcd616f342d8dc46a52bf3892b4d3b Mon Sep 17 00:00:00 2001 From: BenArtes Date: Fri, 23 Jul 2021 12:06:57 -0400 Subject: [PATCH 4/5] Revert FATAL_ERROR to WARNING so that FindPackageHandleStandardArgs can handle pkg_FOUND --- cmake/FindBSP.cmake | 4 ++-- cmake/FindCMSIS.cmake | 6 +++--- cmake/FindFreeRTOS.cmake | 2 +- cmake/FindHAL.cmake | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/FindBSP.cmake b/cmake/FindBSP.cmake index 9bba4c60..c262018c 100644 --- a/cmake/FindBSP.cmake +++ b/cmake/FindBSP.cmake @@ -271,8 +271,8 @@ foreach(COMP ${BSP_FIND_COMPONENTS}) message(STATUS "No STM32_CUBE_${FAMILY}_PATH specified using default: ${STM32_CUBE_${FAMILY}_PATH}") endif() - if ((${BSP_FIND_REQUIRED_${COMP}}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH}_) - message(FATAL_ERROR "For REQUIRED COMPONENT: ${COMP}, STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' Does not Exist") + if ((${BSP_FIND_REQUIRED_${COMP}}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) + message(WARNING "For REQUIRED COMPONENT: ${COMP}, STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' Does not Exist") endif() find_path(BSP_${FAMILY}_PATH diff --git a/cmake/FindCMSIS.cmake b/cmake/FindCMSIS.cmake index fab96a07..66514c26 100644 --- a/cmake/FindCMSIS.cmake +++ b/cmake/FindCMSIS.cmake @@ -77,13 +77,13 @@ foreach(COMP ${CMSIS_FIND_COMPONENTS}) if((NOT STM32_CMSIS_${FAMILY}_PATH) AND (NOT STM32_CUBE_${FAMILY}_PATH)) set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}") - message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_CMSIS_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") + message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_CMSIS_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") endif() if ((${CMSIS_FIND_REQUIRED_${COMP}}) AND (NOT EXISTS ${STM32_CMSIS_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) - message(FATAL_ERROR "For REQUIRED COMPONENT: ${COMP}, Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_CMSIS_${FAMILY}_PATH: '${STM32_CMSIS_${FAMILY}_PATH}' Exists") + message(WARNING "For REQUIRED COMPONENT: ${COMP}, Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_CMSIS_${FAMILY}_PATH: '${STM32_CMSIS_${FAMILY}_PATH}' Exists") endif() - + find_path(CMSIS_${FAMILY}${CORE_U}_CORE_PATH NAMES Include/cmsis_gcc.h PATHS "${STM32_CMSIS_PATH}" "${STM32_CUBE_${FAMILY}_PATH}/Drivers/CMSIS" diff --git a/cmake/FindFreeRTOS.cmake b/cmake/FindFreeRTOS.cmake index aeb66271..a0fbd6cd 100644 --- a/cmake/FindFreeRTOS.cmake +++ b/cmake/FindFreeRTOS.cmake @@ -17,7 +17,7 @@ if(NOT FREERTOS_PATH) endif() if (NOT EXISTS ${FREERTOS_PATH}) - message(FATAL_ERROR "FREERTOS_PATH: '${FREERTOS_PATH}' Does not Exist") + message(WARNING "FREERTOS_PATH: '${FREERTOS_PATH}' Does not Exist") endif() find_path(FreeRTOS_COMMON_INCLUDE diff --git a/cmake/FindHAL.cmake b/cmake/FindHAL.cmake index abc02cf1..c2574845 100644 --- a/cmake/FindHAL.cmake +++ b/cmake/FindHAL.cmake @@ -247,7 +247,7 @@ foreach(COMP ${HAL_FIND_COMPONENTS_FAMILIES}) endif() if ((${HAL_FIND_REQUIRED_${COMP}}) AND (NOT EXISTS ${STM32_HAL_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) - message(FATAL_ERROR "For REQUIRED COMPONENT: ${COMP}, Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_HAL_${FAMILY}_PATH: '${STM32_HAL_${FAMILY}_PATH}' Exists.") + message(WARNING "For REQUIRED COMPONENT: ${COMP}, Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_HAL_${FAMILY}_PATH: '${STM32_HAL_${FAMILY}_PATH}' Exists.") endif() #Checking HAL patch or release version From fb7e9b6dce328726034b8fc71b28280ebfb19bb4 Mon Sep 17 00:00:00 2001 From: BenArtes Date: Mon, 26 Jul 2021 10:44:53 -0400 Subject: [PATCH 5/5] Only sets default path if exists, and removes variable dereference where not necessary. --- cmake/FindBSP.cmake | 13 ++++++++++--- cmake/FindCMSIS.cmake | 13 ++++++++++--- cmake/FindFreeRTOS.cmake | 12 +++++++++--- cmake/FindHAL.cmake | 13 ++++++++++--- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/cmake/FindBSP.cmake b/cmake/FindBSP.cmake index c262018c..0089c8cf 100644 --- a/cmake/FindBSP.cmake +++ b/cmake/FindBSP.cmake @@ -267,11 +267,18 @@ foreach(COMP ${BSP_FIND_COMPONENTS}) endif() if(NOT STM32_CUBE_${FAMILY}_PATH) - set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}") - message(STATUS "No STM32_CUBE_${FAMILY}_PATH specified using default: ${STM32_CUBE_${FAMILY}_PATH}") + set(DEFAULT_STM32_CUBE_${FAMILY}_PATH "/opt/STM32Cube${FAMILY}") + if(EXISTS ${DEFAULT_STM32_CUBE_${FAMILY}_PATH}) + set(STM32_CUBE_${FAMILY}_PATH ${DEFAULT_STM32_CUBE_${FAMILY}_PATH} CACHE PATH "Path to STM32Cube${FAMILY}") + message(STATUS "No STM32_CUBE_${FAMILY}_PATH specified. " + "Using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") + else() + message(STATUS "No STM32_CUBE_${FAMILY}_PATH specified. " + "default STM32_CUBE_${FAMILY}_PATH: ${DEFAULT_STM32_CUBE_${FAMILY}_PATH} does not exist. Leaving empty.") + endif() endif() - if ((${BSP_FIND_REQUIRED_${COMP}}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) + if((BSP_FIND_REQUIRED_${COMP}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) message(WARNING "For REQUIRED COMPONENT: ${COMP}, STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' Does not Exist") endif() diff --git a/cmake/FindCMSIS.cmake b/cmake/FindCMSIS.cmake index 66514c26..db1db92b 100644 --- a/cmake/FindCMSIS.cmake +++ b/cmake/FindCMSIS.cmake @@ -76,11 +76,18 @@ foreach(COMP ${CMSIS_FIND_COMPONENTS}) endif() if((NOT STM32_CMSIS_${FAMILY}_PATH) AND (NOT STM32_CUBE_${FAMILY}_PATH)) - set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}") - message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_CMSIS_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") + set(DEFAULT_STM32_CUBE_${FAMILY}_PATH "/opt/STM32Cube${FAMILY}") + if(EXISTS ${DEFAULT_STM32_CUBE_${FAMILY}_PATH}) + set(STM32_CUBE_${FAMILY}_PATH ${DEFAULT_STM32_CUBE_${FAMILY}_PATH} CACHE PATH "Path to STM32Cube${FAMILY}") + message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_CMSIS_${FAMILY}_PATH specified." + "Using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") + else() + message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_CMSIS_${FAMILY}_PATH specified. " + "default STM32_CUBE_${FAMILY}_PATH: ${DEFAULT_STM32_CUBE_${FAMILY}_PATH} does not exist. Leaving empty.") + endif() endif() - if ((${CMSIS_FIND_REQUIRED_${COMP}}) AND (NOT EXISTS ${STM32_CMSIS_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) + if ((CMSIS_FIND_REQUIRED_${COMP}) AND (NOT EXISTS ${STM32_CMSIS_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH}})) message(WARNING "For REQUIRED COMPONENT: ${COMP}, Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_CMSIS_${FAMILY}_PATH: '${STM32_CMSIS_${FAMILY}_PATH}' Exists") endif() diff --git a/cmake/FindFreeRTOS.cmake b/cmake/FindFreeRTOS.cmake index a0fbd6cd..372092a4 100644 --- a/cmake/FindFreeRTOS.cmake +++ b/cmake/FindFreeRTOS.cmake @@ -12,11 +12,17 @@ if(NOT FREERTOS_PATH) endif() if(NOT FREERTOS_PATH) - set(FREERTOS_PATH /opt/FreeRTOS CACHE PATH "Path to FreeRTOS") - message(STATUS "No FREERTOS_PATH specified using default: ${FREERTOS_PATH}") + set(DEFAULT_FREERTOS_PATH "/opt/FreeRTOS") + if (EXISTS ${DEFAULT_FREERTOS_PATH}) + set(FREERTOS_PATH ${DEFAULT_FREERTOS_PATH} CACHE PATH "Path to FreeRTOS") + message(STATUS "No FREERTOS_PATH specified using default: ${FREERTOS_PATH}") + else() + message(STATUS "No FREERTOS_PATH specified." + "default FREERTOS_PATH: ${DEFAULT_FREERTOS_PATH} does not exist. Leaving Empty.") + endif() endif() -if (NOT EXISTS ${FREERTOS_PATH}) +if ((FREERTOS_FIND_REQUIRED) AND (NOT EXISTS ${FREERTOS_PATH})) message(WARNING "FREERTOS_PATH: '${FREERTOS_PATH}' Does not Exist") endif() diff --git a/cmake/FindHAL.cmake b/cmake/FindHAL.cmake index c2574845..b7f6c3ff 100644 --- a/cmake/FindHAL.cmake +++ b/cmake/FindHAL.cmake @@ -242,11 +242,18 @@ foreach(COMP ${HAL_FIND_COMPONENTS_FAMILIES}) endif() if((NOT STM32_HAL_${FAMILY}_PATH) AND (NOT STM32_CUBE_${FAMILY}_PATH)) - set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}") - message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_HAL_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") + set(DEFAULT_STM32_CUBE_${FAMILY}_PATH "/opt/STM32Cube${FAMILY}") + if(EXISTS ${DEFAULT_STM32_CUBE_${FAMILY}_PATH}) + set(STM32_CUBE_${FAMILY}_PATH ${DEFAULT_STM32_CUBE_${FAMILY}_PATH} CACHE PATH "Path to STM32Cube${FAMILY}") + message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_HAL_${FAMILY}_PATH specified." + "Using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") + elseif() + message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_HAL_${FAMILY}_PATH specified. " + "default STM32_CUBE_${FAMILY}_PATH: ${DEFAULT_STM32_CUBE_${FAMILY}_PATH} does not exist. Leaving empty.") + endif() endif() - if ((${HAL_FIND_REQUIRED_${COMP}}) AND (NOT EXISTS ${STM32_HAL_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) + if((HAL_FIND_REQUIRED_${COMP}) AND (NOT EXISTS ${STM32_HAL_${FAMILY}_PATH}) AND (NOT EXISTS ${STM32_CUBE_${FAMILY}_PATH})) message(WARNING "For REQUIRED COMPONENT: ${COMP}, Neither STM32_CUBE_${FAMILY}_PATH: '${STM32_CUBE_${FAMILY}_PATH}' nor STM32_HAL_${FAMILY}_PATH: '${STM32_HAL_${FAMILY}_PATH}' Exists.") endif()