-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check path existence #246
base: master
Are you sure you want to change the base?
Check path existence #246
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here the idea of #232 is to check if the path exists before using default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
…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_package
call specifies whether the package and any listed components are REQUIRED. The list of components is passed to the module using the<package>_FIND_COMPONENTS
variable, 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_package
and 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}_PATH
STM32_CMSIS_${FAMILY}_PATH
STM32_CUBE_${FAMILY}_PATH
FREERTOS_PATH
STM32_HAL_${FAMILY}_PATH
STM32_CUBE_${FAMILY}_PATH
Risks with this PR: Due to previous silent failing and usage of REQUIRED in
find_package
this PR could break previously working user code.