Skip to content
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

Added custom find_package_me cmake function #124

Merged
merged 5 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions utils/cmake/mikroeUtilsCommon.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
#############################################################################
## Function to find the packages with better error message handling.
#############################################################################
function(find_package_me PACKAGE_NAME)
# Set the default value of REQUIRED_FLAG to OPTIONAL
set(REQUIRED_FLAG "OPTIONAL")

# If a second argument is passed, treat it as REQUIRED_FLAG
if(ARGC GREATER 1)
set(REQUIRED_FLAG ${ARGV1})
endif()

# Attempt to find the package without the REQUIRED flag
find_package(${PACKAGE_NAME})

# If the package is not found, manually trigger an error with a detailed message
if (NOT ${PACKAGE_NAME}_FOUND AND ${REQUIRED_FLAG} STREQUAL "REQUIRED")
message(FATAL_ERROR "
****************************************************************************
!!! FATAL ERROR: Setup configuration is incorrect !!!
If you are using graphical project, ensure that your setup has a display.
If you are using CAN/DMA/USB/Ethernet/etc. project, ensure that the MCU
that you are using supports this module. Refer to this link:
https://github.com/MikroElektronika/mikrosdk_v2/blob/master/SUPPORTED_CHIP_LIST.md
****************************************************************************
")
endif()
endfunction()

#############################################################################
## Including this directory will ensure that all necessary support files
## are visible to any project.
Expand Down