diff --git a/CMakeLists.txt b/CMakeLists.txt index 350da80..1d2c74b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,11 +80,25 @@ if( "${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}" ) endif( "${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}" ) # configure avr-libcpp -set( AVRLIBCPP_SUPPRESS_SFR_MACROS ON CACHE INTERNAL "" ) +option( + PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP + "picolibrary-microchip-megaavr0: use parent project's avr-libcpp" + ON +) + +if( NOT ${PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP} ) + set( AVRLIBCPP_SUPPRESS_SFR_MACROS ON CACHE INTERNAL "" ) +endif( NOT ${PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP} ) + +if( NOT ${AVRLIBCPP_SUPPRESS_SFR_MACROS} ) + message( FATAL_ERROR "AVRLIBCPP_SUPPRESS_SFR_MACROS must be ON" ) +endif( NOT ${AVRLIBCPP_SUPPRESS_SFR_MACROS} ) -add_subdirectory( avr-libcpp ) +if( NOT ${PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP} ) + add_subdirectory( avr-libcpp ) -link_libraries( avr-libcpp ) + link_libraries( avr-libcpp ) +endif( NOT ${PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP} ) # configure picolibrary set( PICOLIBRARY_ENABLE_AUTOMATED_TESTING OFF CACHE INTERNAL "" ) diff --git a/configuration/release-atmega1608/CMakeLists.txt b/configuration/release-atmega1608/CMakeLists.txt index ed5a7d0..d65796d 100644 --- a/configuration/release-atmega1608/CMakeLists.txt +++ b/configuration/release-atmega1608/CMakeLists.txt @@ -21,6 +21,9 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_F_CPU "16000000UL" CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_MCU "atmega1608" CACHE INTERNAL "" ) +# avr-libcpp configuration +set( PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP OFF CACHE INTERNAL "" ) + # picolibrary configuration set( PICOLIBRARY_SUPPRESS_ASSERTION_FAILURE_LOCATION_INFORMATION OFF CACHE INTERNAL "" ) set( PICOLIBRARY_SUPPRESS_HUMAN_READABLE_ERROR_INFORMATION OFF CACHE INTERNAL "" ) diff --git a/configuration/release-atmega1609/CMakeLists.txt b/configuration/release-atmega1609/CMakeLists.txt index e9896ad..fc2fdcd 100644 --- a/configuration/release-atmega1609/CMakeLists.txt +++ b/configuration/release-atmega1609/CMakeLists.txt @@ -21,6 +21,9 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_F_CPU "16000000UL" CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_MCU "atmega1609" CACHE INTERNAL "" ) +# avr-libcpp configuration +set( PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP OFF CACHE INTERNAL "" ) + # picolibrary configuration set( PICOLIBRARY_SUPPRESS_ASSERTION_FAILURE_LOCATION_INFORMATION OFF CACHE INTERNAL "" ) set( PICOLIBRARY_SUPPRESS_HUMAN_READABLE_ERROR_INFORMATION OFF CACHE INTERNAL "" ) diff --git a/configuration/release-atmega3208/CMakeLists.txt b/configuration/release-atmega3208/CMakeLists.txt index a6fc9f3..b23f4ae 100644 --- a/configuration/release-atmega3208/CMakeLists.txt +++ b/configuration/release-atmega3208/CMakeLists.txt @@ -21,6 +21,9 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_F_CPU "16000000UL" CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_MCU "atmega3208" CACHE INTERNAL "" ) +# avr-libcpp configuration +set( PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP OFF CACHE INTERNAL "" ) + # picolibrary configuration set( PICOLIBRARY_SUPPRESS_ASSERTION_FAILURE_LOCATION_INFORMATION OFF CACHE INTERNAL "" ) set( PICOLIBRARY_SUPPRESS_HUMAN_READABLE_ERROR_INFORMATION OFF CACHE INTERNAL "" ) diff --git a/configuration/release-atmega3209/CMakeLists.txt b/configuration/release-atmega3209/CMakeLists.txt index 4dfe3a6..54c3aaf 100644 --- a/configuration/release-atmega3209/CMakeLists.txt +++ b/configuration/release-atmega3209/CMakeLists.txt @@ -21,6 +21,9 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_F_CPU "16000000UL" CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_MCU "atmega3209" CACHE INTERNAL "" ) +# avr-libcpp configuration +set( PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP OFF CACHE INTERNAL "" ) + # picolibrary configuration set( PICOLIBRARY_SUPPRESS_ASSERTION_FAILURE_LOCATION_INFORMATION OFF CACHE INTERNAL "" ) set( PICOLIBRARY_SUPPRESS_HUMAN_READABLE_ERROR_INFORMATION OFF CACHE INTERNAL "" ) diff --git a/configuration/release-atmega4808/CMakeLists.txt b/configuration/release-atmega4808/CMakeLists.txt index 8e541d6..db6d9e1 100644 --- a/configuration/release-atmega4808/CMakeLists.txt +++ b/configuration/release-atmega4808/CMakeLists.txt @@ -21,6 +21,9 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_F_CPU "16000000UL" CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_MCU "atmega4808" CACHE INTERNAL "" ) +# avr-libcpp configuration +set( PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP OFF CACHE INTERNAL "" ) + # picolibrary configuration set( PICOLIBRARY_SUPPRESS_ASSERTION_FAILURE_LOCATION_INFORMATION OFF CACHE INTERNAL "" ) set( PICOLIBRARY_SUPPRESS_HUMAN_READABLE_ERROR_INFORMATION OFF CACHE INTERNAL "" ) diff --git a/configuration/release-atmega4809/CMakeLists.txt b/configuration/release-atmega4809/CMakeLists.txt index 5aa8cc8..15af050 100644 --- a/configuration/release-atmega4809/CMakeLists.txt +++ b/configuration/release-atmega4809/CMakeLists.txt @@ -21,6 +21,9 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_F_CPU "16000000UL" CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_MCU "atmega4809" CACHE INTERNAL "" ) +# avr-libcpp configuration +set( PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP OFF CACHE INTERNAL "" ) + # picolibrary configuration set( PICOLIBRARY_SUPPRESS_ASSERTION_FAILURE_LOCATION_INFORMATION OFF CACHE INTERNAL "" ) set( PICOLIBRARY_SUPPRESS_HUMAN_READABLE_ERROR_INFORMATION OFF CACHE INTERNAL "" ) diff --git a/configuration/release-atmega808/CMakeLists.txt b/configuration/release-atmega808/CMakeLists.txt index 863b2b9..97705de 100644 --- a/configuration/release-atmega808/CMakeLists.txt +++ b/configuration/release-atmega808/CMakeLists.txt @@ -21,6 +21,9 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_F_CPU "16000000UL" CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_MCU "atmega808" CACHE INTERNAL "" ) +# avr-libcpp configuration +set( PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP OFF CACHE INTERNAL "" ) + # picolibrary configuration set( PICOLIBRARY_SUPPRESS_ASSERTION_FAILURE_LOCATION_INFORMATION OFF CACHE INTERNAL "" ) set( PICOLIBRARY_SUPPRESS_HUMAN_READABLE_ERROR_INFORMATION OFF CACHE INTERNAL "" ) diff --git a/configuration/release-atmega809/CMakeLists.txt b/configuration/release-atmega809/CMakeLists.txt index 0c33277..8eda913 100644 --- a/configuration/release-atmega809/CMakeLists.txt +++ b/configuration/release-atmega809/CMakeLists.txt @@ -21,6 +21,9 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_F_CPU "16000000UL" CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_MCU "atmega809" CACHE INTERNAL "" ) +# avr-libcpp configuration +set( PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP OFF CACHE INTERNAL "" ) + # picolibrary configuration set( PICOLIBRARY_SUPPRESS_ASSERTION_FAILURE_LOCATION_INFORMATION OFF CACHE INTERNAL "" ) set( PICOLIBRARY_SUPPRESS_HUMAN_READABLE_ERROR_INFORMATION OFF CACHE INTERNAL "" ) diff --git a/configuration/testing-interactive-atmega4809-arduino-nano-every/CMakeLists.txt b/configuration/testing-interactive-atmega4809-arduino-nano-every/CMakeLists.txt index 09ce8a2..6c9f05b 100644 --- a/configuration/testing-interactive-atmega4809-arduino-nano-every/CMakeLists.txt +++ b/configuration/testing-interactive-atmega4809-arduino-nano-every/CMakeLists.txt @@ -22,6 +22,9 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_F_CPU "16000000UL" CACHE INTERNAL "" ) set( PICOLIBRARY_MICROCHIP_MEGAAVR0_MCU "atmega4809" CACHE INTERNAL "" ) +# avr-libcpp configuration +set( PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP OFF CACHE INTERNAL "" ) + # picolibrary configuration set( PICOLIBRARY_SUPPRESS_ASSERTION_FAILURE_LOCATION_INFORMATION OFF CACHE INTERNAL "" ) set( PICOLIBRARY_SUPPRESS_HUMAN_READABLE_ERROR_INFORMATION OFF CACHE INTERNAL "" ) diff --git a/docs/usage.md b/docs/usage.md index 70dd53e..b6736b8 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -69,6 +69,13 @@ picolibrary-microchip-megaavr0 supports the following project configuration opti USART clock generator scaling factor (see [`include/picolibrary/testing/interactive/microchip/megaavr0/log.h`](https://github.com/apcountryman/picolibrary-microchip-megaavr0/blob/main/include/picolibrary/testing/interactive/microchip/megaavr0/log.h) for more information) +- `PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP` (defaults to `ON`): use + parent project's avr-libcpp + +### avr-libcpp Configuration Requirements +If `PICOLIBRARY_MICROCHIP_MEGAAVR0_USE_PARENT_PROJECT_AVRLIBCPP` is `ON`, avr-libcpp must +be configured as follows: +- `AVRLIBCPP_SUPPRESS_SFR_MACROS` must be `ON` ## Development The repository's Git `pre-commit` hook script is the simplest way to configure, and build