Conversation
…default PATHs, else FATAL_ERROR (cherry picked from commit 59217734eada4e8661736ed994b44ae184bea5b8)
(cherry picked from commit 8246a97f86830396fde9d16e285089ff6da135c3)
|
After further investigation on 1
2
This is further backed up by Professional CMake 9th Ed which says on page 316:
There are three possible behaviors for
I assume that |
|
Final Comments: CMake documentation recommends using My final suggestion so to revert the FATAL_ERROR to WARNING and allow FindPackageHandleStandardArgs to handle the errors accordingly.
This doesn't change behavior or tests, but does indicate to users the cause of the failure / error. |
…an handle pkg_FOUND
atsju
left a comment
There was a problem hiding this comment.
Thank you for the explanations, this is all very clear.
We discussed with @Hish15 and your final proposal seems to be best choice:
For find_package(package),find_package(package REQUIRED), and find_package(package COMPONENTS REQUIRED) it will silently fail on non-existent paths, but the build will succeed if atleast one exists.
To recap find_package(package REQUIRED) will fail only if no package is found and will success if at least one package is found.
cmake/FindCMSIS.cmake
Outdated
| @@ -77,9 +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}") | |||
There was a problem hiding this comment.
here the idea of #232 is to check if the path exists before using default.
…ere not necessary.
|
Hello @BenArtes Sorry for delay. |
Resolves #232
Implementation Details: For REQUIRED COMPONENTS listed in a project's
find_package, the existence of paths are checked after all possible ENV or default substitutions.Background: BSP, CMSIS, FreeRTOS, and HAL support are implemented as CMake modules that are found using CMake's
find_package. Thefind_packagecall specifies whether the package and any listed components are REQUIRED. The list of components is passed to the module using the<package>_FIND_COMPONENTSvariable, and whether they are required can be checked using the<package>_FIND_REQUIRED_<component>variable.The first commits implemented just the existence check, which broke the tests in
/test. The readme suggests the following usage of COMPONENTS:Details about
find_packageand COMPONENTS:find_package(package)- All components are included by default and set to OPTIONALfind_pacakge(package COMPONENTS REQUIRED)- All components are included by default and set to OPTIONAL; This seems weird as the package is marked as required but the path isn't checked for existence because there aren't any components to be checked / they are optional by default?find_package(package COMPONENTS STM32... REQUIRED)- Listed Components are marked as REQUIRED and the existence of _PATHS is checked.Checklist:
find_package(package REQUIRED)?find_package(package COMPONENTS REQUIRED)?List of Paths checked:
STM32_CUBE_${FAMILY}_PATHSTM32_CMSIS_${FAMILY}_PATHSTM32_CUBE_${FAMILY}_PATHFREERTOS_PATHSTM32_HAL_${FAMILY}_PATHSTM32_CUBE_${FAMILY}_PATHRisks with this PR: Due to previous silent failing and usage of REQUIRED in
find_packagethis PR could break previously working user code.