diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ef1ce3c --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* diff --git a/Modules/MicrochipBin2Hex.cmake b/Modules/MicrochipBin2Hex.cmake index e9912e4..a229863 100644 --- a/Modules/MicrochipBin2Hex.cmake +++ b/Modules/MicrochipBin2Hex.cmake @@ -12,14 +12,14 @@ # substitute the full License text for the above reference.) -function(bin2hex target) +function(add_bin2hex_target target) find_program(MICROCHIP_BIN2HEX NAMES ${_CMAKE_TOOLCHAIN_PREFIX}bin2hex bin2hex HINTS ${_CMAKE_TOOLCHAIN_LOCATION} ) if(NOT MICROCHIP_BIN2HEX) - message(SEND_ERROR "No bin2hex program was found") + message(SEND_ERROR "No bin2hex program was found. _CMAKE_TOOLCHAIN_PREFIX=${_CMAKE_TOOLCHAIN_PREFIX}") endif() function(get_target_property_fallback var target) @@ -48,12 +48,25 @@ function(bin2hex target) set(out_f "${out_f}.hex") add_custom_command( - TARGET ${target} POST_BUILD + #TARGET ${target} POST_BUILD + OUTPUT ${dir}/${out_f} + DEPENDS ${target} WORKING_DIRECTORY ${dir} COMMAND "${MICROCHIP_BIN2HEX}" "${in_f}" - BYPRODUCTS ${dir}/${out_f} VERBATIM ) + add_custom_target(bin2hex_${target} + DEPENDS ${dir}/${out_f} + ) + + if(NOT TARGET bin2hex) + add_custom_target(bin2hex ALL) + #message(STATUS "bin2hex not exits") + endif() + + add_dependencies(bin2hex + bin2hex_${target} + ) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES diff --git a/Modules/MicrochipIPE.cmake b/Modules/MicrochipIPE.cmake new file mode 100644 index 0000000..52a0c05 --- /dev/null +++ b/Modules/MicrochipIPE.cmake @@ -0,0 +1,90 @@ + +include(MicrochipPathSearch) + +find_package(Java COMPONENTS Runtime) + + +set(PROGRAMER "ICD3" CACHE STRING "programador a utilizar") +set_property(CACHE PROGRAMER PROPERTY STRINGS ICD3 ICD4 PK3 PK4 PM3 PKOB) + +#set(IPECMD ${Java_JAVA_EXECUTABLE} -jar "/opt/microchip/mplabx/v3.35/mplab_ipe/ipecmd.jar") +set(IPE_LOG MPLABXLog.xml MPLABXLog.xml.0 MPLABXLog.xml.1 MPLABXLog.xml.2 MPLABXLog.xml.3 MPLABXLog.xml.4 MPLABXLog.xml.5 MPLABXLog.xml.6 MPLABXLog.xml.7) + +function(finMPLABX) + MICROCHIP_PATH_SEARCH(MICROCHIP_MPLABX_PATH mplabx + CACHE "the path to a Microchip MPLABX installation" + ) + + + if(NOT MICROCHIP_MPLABX_PATH) + message(FATAL_ERROR + "No Microchip MPLABX was found. Please provide the path" + " to an MPLABX installation on the command line, for example:\n" + "cmake -DMICROCHIP_MPLABX_PATH=/opt/microchip/mplabx/v1.42 ." + ) + endif() +endfunction() +function(add_ipe_deploit_target target) + + finMPLABX() + + find_program(MICROCHIP_IPECMD + NAMES mplab_ipe/ipecmd.jar + HINTS ${MICROCHIP_MPLABX_PATH} + ) + + if(NOT MICROCHIP_IPECMD) + message(SEND_ERROR "No ipecmd.jar program was found") + endif() + set(IPECMD ${Java_JAVA_EXECUTABLE} -jar ${MICROCHIP_IPECMD}) + + add_custom_command( + DEPENDS ${target}.hex + COMMAND ${IPECMD} -f${target}.hex -M -P${MICROCHIP_MCU_MODEL} -TP${PROGRAMER} -Y + OUTPUT log.0 + BYPRODUCTS ${IPE_LOG} + COMMENT "Deploit to pic32" + VERBATIM + ) + add_custom_target(deploit DEPENDS log.0) +endfunction() + +function(ipeRestar target) + finMPLABX() + + find_program(MICROCHIP_IPECMD + NAMES mplab_ipe/ipecmd.jar + HINTS ${MICROCHIP_MPLABX_PATH} + ) + + if(NOT MICROCHIP_IPECMD) + message(SEND_ERROR "No ipecmd.jar program was found") + endif() + set(IPECMD ${Java_JAVA_EXECUTABLE} -jar ${MICROCHIP_IPECMD}) + + add_custom_target(restart DEPENDS deploit + COMMAND ${IPECMD} -f${target}.hex -P${MICROCHIP_MCU_MODEL} -TP${PROGRAMER} -Y + VERBATIM + ) +endfunction() + +function(ipeRun target device) + finMPLABX() + + find_program(MICROCHIP_IPECMD + NAMES mplab_ipe/ipecmd.jar + HINTS ${MICROCHIP_MPLABX_PATH} + ) + + if(NOT MICROCHIP_IPECMD) + message(SEND_ERROR "No ipecmd.jar program was found") + endif() + + set(IPECMD ${Java_JAVA_EXECUTABLE} -jar ${MICROCHIP_IPECMD}) + + add_custom_target(run DEPENDS deploit + #COMMAND sh -c "cat ${device} | sed '/^\\s*$/d'" + COMMAND sh -c "cat ${device}" + VERBATIM + ) +endfunction() diff --git a/Modules/MicrochipPathSearch.cmake b/Modules/MicrochipPathSearch.cmake index 0f859e6..0402e2c 100644 --- a/Modules/MicrochipPathSearch.cmake +++ b/Modules/MicrochipPathSearch.cmake @@ -11,6 +11,7 @@ # (To distribute this file outside of CMake-Microchip, # substitute the full License text for the above reference.) +cmake_policy(SET CMP0057 NEW) function(MICROCHIP_PATH_SEARCH outvar target) set(options) list(APPEND oneValueArgs CACHE STORE_VERSION) diff --git a/Modules/Platform/MicrochipMCU-C-XC32.cmake b/Modules/Platform/MicrochipMCU-C-XC32.cmake index 9addb1e..ae0c882 100644 --- a/Modules/Platform/MicrochipMCU-C-XC32.cmake +++ b/Modules/Platform/MicrochipMCU-C-XC32.cmake @@ -15,10 +15,46 @@ # to provide information specific to the XC32 compiler include(MicrochipPathSearch) -MICROCHIP_PATH_SEARCH(MICROCHIP_XC32_PATH xc32 - CACHE "the path to a Microchip XC32 installation" - STORE_VERSION MICROCHIP_C_COMPILER_VERSION -) + +set(_CMAKE_TOOLCHAIN_PREFIX "xc32-") + +if(NOT MICROCHIP_XC32_PATH) + MICROCHIP_PATH_SEARCH(MICROCHIP_XC32_PATH xc32 + CACHE "the path to a Microchip XC32 installation" + STORE_VERSION MICROCHIP_C_COMPILER_VERSION + ) +endif() + + +function(_xc32_get_version) + execute_process( + COMMAND "${CMAKE_C_COMPILER}" "--version" + OUTPUT_VARIABLE output + ERROR_VARIABLE output + RESULT_VARIABLE result + ) + + if(result) + message(FATAL_ERROR + "Calling '${CMAKE_C_COMPILER} --version' failed." + ) + endif() + + if(output MATCHES "([0-9]+(\.[0-9]+)+).* MPLAB XC32 Compiler .*v([0-9]+(\.[0-9]+)+)") + set(gnu_version ${CMAKE_MATCH_1}) + set(xc32_version ${CMAKE_MATCH_3}) + else() + message(FATAL_ERROR + "Failed to parse output of '${CMAKE_C_COMPILER} --version'." + ) + endif() + + string(REPLACE "_" "." gnu_version ${gnu_version}) + string(REPLACE "_" "." xc32_version ${xc32_version}) + + set(CMAKE_C_COMPILER_VERSION ${gnu_version} PARENT_SCOPE) + set(MICROCHIP_C_COMPILER_VERSION ${xc32_version} PARENT_SCOPE) +endfunction() if(NOT MICROCHIP_XC32_PATH) message(FATAL_ERROR @@ -30,12 +66,62 @@ endif() set(CMAKE_FIND_ROOT_PATH ${MICROCHIP_XC32_PATH}) -set(CMAKE_C_COMPILER xc32-gcc) +find_program(CMAKE_ASM_COMPILER "xc32-gcc") +find_program(CMAKE_C_COMPILER "xc32-gcc") +find_program(CMAKE_CXX_COMPILER "xc32-g++") + set(MICROCHIP_C_COMPILER_ID XC32) -add_compile_options( - "-mprocessor=${MICROCHIP_MCU_MODEL}" +set(CMAKE_C_STANDARD_COMPUTED_DEFAULT 90) +set(CMAKE_CXX_COMPILER_FORCED ON) + +if(MICROCHIP_MCU_FAMILY STREQUAL "PIC32MX") + set(lib_directory pic32mx) +else() + set(lib_directory pic32-libs) +endif() +include_directories(SYSTEM ${MICROCHIP_XC32_PATH}/${lib_directory}/include) + +set(link_flags "") +set(compile_flags "") + +list(APPEND compile_flags + "-mprocessor=${MICROCHIP_MCU_MODEL}" ) +string(APPEND link_flags + " -mprocessor=${MICROCHIP_MCU_MODEL}" +) +if(MICROCHIP_LINK_SCRIPT OR MICROCHIP_MIN_HEAP_SIZE) + string(APPEND link_flags + " -Wl" + ) + if(MICROCHIP_LINK_SCRIPT) + string(APPEND link_flags + ",--script=\"${MICROCHIP_LINK_SCRIPT}\"" + ) + endif() + if(MICROCHIP_MIN_HEAP_SIZE) + string(APPEND link_flags + ",--defsym=_min_heap_size=${MICROCHIP_MIN_HEAP_SIZE}" + ) + endif() + if(MICROCHIP_MAP_FILE) + string(APPEND link_flags + ",-Map=\"${MICROCHIP_MAP_FILE}\"" + ) + set_property(DIRECTORY APPEND + PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + "${MICROCHIP_MAP_FILE}" + ) + endif() +endif() string(APPEND CMAKE_C_LINK_FLAGS - " -mprocessor=${MICROCHIP_MCU_MODEL}" + ${link_flags} +) +add_compile_options( + ${compile_flags} ) + +if(CMAKE_C_COMPILER) + _xc32_get_version() +endif() diff --git a/Modules/Platform/MicrochipMCU-CXX-XC32.cmake b/Modules/Platform/MicrochipMCU-CXX-XC32.cmake new file mode 100644 index 0000000..8aa707f --- /dev/null +++ b/Modules/Platform/MicrochipMCU-CXX-XC32.cmake @@ -0,0 +1,46 @@ +#============================================================================= +# Copyright 2016 Sam Hanes +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file COPYING.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake-Microchip, +# substitute the full License text for the above reference.) + +# this module is called by `Platform/MicrochipMCU-CXX` +# to provide information specific to the XC32 compiler + +include(MicrochipPathSearch) +if(NOT MICROCHIP_XC32_PATH) + MICROCHIP_PATH_SEARCH(MICROCHIP_XC32_PATH xc32 + CACHE "the path to a Microchip XC32 installation" + STORE_VERSION MICROCHIP_CXX_COMPILER_VERSION + ) +endif() + +if(NOT MICROCHIP_XC32_PATH) + message(FATAL_ERROR + "No Microchip XC32 compiler was found. Please provide the path" + " to an XC32 installation on the command line, for example:\n" + "cmake -DMICROCHIP_XC32_PATH=/opt/microchip/xc32/v1.42 ." + ) +endif() + +set(CMAKE_FIND_ROOT_PATH ${MICROCHIP_XC32_PATH}) + +set(OS_SUFFIX "") +if(WIN32) + string(APPEND OS_SUFFIX ".exe") +endif() + +set(CMAKE_CXX_COMPILER ${MICROCHIP_XC32_PATH}/bin/xc32-g++${OS_SUFFIX} CACHE STRING "" FORCE) +set(MICROCHIP_CXX_COMPILER_ID XC32) + +set(CMAKE_CXX_FLAGS "-mprocessor=${MICROCHIP_MCU_MODEL}" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_DEBUG "-g" CACHE STRING "" FORCE) +set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf" CACHE STRING "" FORCE) diff --git a/Modules/Platform/MicrochipMCU-CXX.cmake b/Modules/Platform/MicrochipMCU-CXX.cmake new file mode 100644 index 0000000..ebf18e8 --- /dev/null +++ b/Modules/Platform/MicrochipMCU-CXX.cmake @@ -0,0 +1,31 @@ +#============================================================================= +# Copyright 2016 Sam Hanes +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file COPYING.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake-Microchip, +# substitute the full License text for the above reference.) + +# This module is loaded during the search for a CXX compiler +# to provide the information necessary to find one. + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL "PIC_32") + include(Platform/MicrochipMCU-CXX-XC32) +else() + message(FATAL_ERROR + "No CXX compiler for '${CMAKE_SYSTEM_PROCESSOR}'" + " is supported yet." + ) +endif() + +if(MICROCHIP_CXX_COMPILER_ID) + message(STATUS + "Using Microchip CXX compiler ${MICROCHIP_CXX_COMPILER_ID}" + " ${MICROCHIP_CXX_COMPILER_VERSION}" + ) +endif() diff --git a/Modules/Platform/MicrochipMCU-GNU-C.cmake b/Modules/Platform/MicrochipMCU-GNU-C.cmake index 4fc430f..a20b89a 100644 --- a/Modules/Platform/MicrochipMCU-GNU-C.cmake +++ b/Modules/Platform/MicrochipMCU-GNU-C.cmake @@ -16,6 +16,7 @@ # for XC16, inject properties that may have been missed # see `Platform/MicrochipMCU-C-XC16` for explanation + if(MICROCHIP_C_COMPILER_ID STREQUAL "XC16") if(NOT CMAKE_C_COMPILE_FEATURES) set(CMAKE_C_COMPILE_FEATURES "c_function_prototypes;c_restrict;c_variadic_macros") @@ -32,3 +33,20 @@ if(MICROCHIP_C_COMPILER_ID STREQUAL "XC16") set(CMAKE_C_COMPILER_ABI ELF) endif() endif() + +if(MICROCHIP_C_COMPILER_ID STREQUAL "XC32") + if(NOT CMAKE_C_COMPILE_FEATURES) + set(CMAKE_C_COMPILE_FEATURES "c_function_prototypes;c_restrict;c_variadic_macros") + set(CMAKE_C90_COMPILE_FEATURES "c_function_prototypes") + set(CMAKE_C99_COMPILE_FEATURES "c_restrict;c_variadic_macros") + set(CMAKE_C11_COMPILE_FEATURES "") + endif() + + if(NOT CMAKE_C_SIZEOF_DATA_PTR) + set(CMAKE_C_SIZEOF_DATA_PTR 4) + endif() + + if(NOT CMAKE_C_COMPILER_ABI) + set(CMAKE_C_COMPILER_ABI ELF) + endif() +endif() diff --git a/Modules/Platform/MicrochipMCU-GNU-CXX.cmake b/Modules/Platform/MicrochipMCU-GNU-CXX.cmake new file mode 100644 index 0000000..36fa706 --- /dev/null +++ b/Modules/Platform/MicrochipMCU-GNU-CXX.cmake @@ -0,0 +1,28 @@ +#============================================================================= +# Copyright 2016 Sam Hanes +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file COPYING.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake-Microchip, +# substitute the full License text for the above reference.) + +# this module is called after the compiler has been determined +# to set up information specific to Microchip GNU CXX compilers + +# for XC32, inject properties that may have been missed +# see `Platform/MicrochipMCU-CXX-XC32` for explanation + +if(MICROCHIP_CXX_COMPILER_ID STREQUAL "XC32") + if(NOT CMAKE_CXX_SIZEOF_DATA_PTR) + set(CMAKE_CXX_SIZEOF_DATA_PTR 4) + endif() + + if(NOT CMAKE_CXX_COMPILER_ABI) + set(CMAKE_CXX_COMPILER_ABI ELF) + endif() +endif() diff --git a/Modules/Platform/MicrochipMCU-Initialize.cmake b/Modules/Platform/MicrochipMCU-Initialize.cmake index 71eac34..64ef6e4 100644 --- a/Modules/Platform/MicrochipMCU-Initialize.cmake +++ b/Modules/Platform/MicrochipMCU-Initialize.cmake @@ -21,3 +21,4 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +set(CMAKE_CXX_COMPILER_FORCED ON) diff --git a/Modules/Platform/MicrochipMCU.cmake b/Modules/Platform/MicrochipMCU.cmake index ebd1bdd..8cdf3be 100644 --- a/Modules/Platform/MicrochipMCU.cmake +++ b/Modules/Platform/MicrochipMCU.cmake @@ -23,3 +23,4 @@ set(CMAKE_SYSTEM_LIBRARY_PATH /lib) set(CMAKE_SYSTEM_PROGRAM_PATH /bin) include(MicrochipBin2Hex) +include(MicrochipIPE) diff --git a/README.rst b/README.rst index ca4edfb..2fe8668 100644 --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ CMake for the Microchip Toolchain This project provides toolchains and other support modules to enable using `CMake`_ with the `Microchip compilers`_, although presently only -XC16 is supported. +XC16 and XC32 is supported. .. _CMake: https://cmake.org/ .. _Microchip compilers: http://www.microchip.com/mplab/compilers @@ -16,7 +16,7 @@ First, you need to somehow get a copy of this project as a subdirectory of your project named ``external/cmake-microchip``. If you use git, the easiest way is to add a submodule:: - git submodule add git://github.com/Elemecca/cmake-microchip.git external/cmake-microchip + git submodule add git://github.com/juanAngel/cmake-microchip.git external/cmake-microchip Then add this snippet at the very top of your ``CMakeLists.txt``:: @@ -25,11 +25,18 @@ Then add this snippet at the very top of your ``CMakeLists.txt``:: # set the default MCU model set(MICROCHIP_MCU PIC24FJ32GB002) +This code fragment must be placed before "project" command to have effect + +``MICROCHIP_MIN_HEAP_SIZE`` sets the heap size + +``MICROCHIP_MAP_FILE`` allows you to generate a map file The target MCU is set by the ``MICROCHIP_MCU`` variable. It can be set in ``CMakeLists.txt`` as above or on the CMake command line like so:: cmake -DMICROCHIP_MCU=PIC24FJ256GB004 . + +You can set the variable "MICROCHIP_LINK_SCRIPT" to specify a linked script Copying ======= diff --git a/toolchain.cmake b/toolchain.cmake index 86a1429..a642ecc 100644 --- a/toolchain.cmake +++ b/toolchain.cmake @@ -23,7 +23,6 @@ # CMP0057 (IN_LIST operator) since 3.3 cmake_minimum_required(VERSION 3.3) - # record the directory containing this script # it will be used as the base for finding our other files set(MICROCHIP_ROOT ${CMAKE_CURRENT_LIST_DIR}) @@ -49,6 +48,10 @@ set(CMAKE_SYSTEM_NAME "MicrochipMCU") # # that makes it possible to set a per-project default model in # CMakeLists.txt that can still be overridden on the command line +include(MicrochipBin2Hex) +include(MicrochipIPE) +include(MicrochipPathSearch) + if(NOT MICROCHIP_MCU) set(MICROCHIP_MCU "generic16") endif() @@ -98,15 +101,18 @@ elseif(MICROCHIP_MCU STREQUAL "generic32") set(CMAKE_SYSTEM_PROCESSOR "PIC_32") elseif(MICROCHIP_MCU MATCHES "^(dsPIC|PIC)(32M[XZ]|[0-9]+[A-Z])([A-Z0-9]+)$") - set(MICROCHIP_MCU_FAMILY "${CMAKE_MATCH_1}${CMAKE_MATCH_2}") - set(MICROCHIP_MCU_MODEL "${CMAKE_MATCH_2}${CMAKE_MATCH_3}") + set(MICROCHIP_MCU_FAMILY "${CMAKE_MATCH_1}${CMAKE_MATCH_2}" CACHE STRING "Familia de chip") + set(MICROCHIP_MCU_MODEL "${CMAKE_MATCH_2}${CMAKE_MATCH_3}" CACHE STRING "Modelo de chip") if(MICROCHIP_MCU_FAMILY IN_LIST MICROCHIP_FAMILIES_8) set(CMAKE_SYSTEM_PROCESSOR "PIC_8") + add_definitions(-D__${MICROCHIP_MCU_FAMILY}__ -D__${MICROCHIP_MCU_MODEL}__) elseif(MICROCHIP_MCU_FAMILY IN_LIST MICROCHIP_FAMILIES_16) set(CMAKE_SYSTEM_PROCESSOR "PIC_16") + add_definitions(-D__${MICROCHIP_MCU_FAMILY}__ -D__${MICROCHIP_MCU_MODEL}__) elseif(MICROCHIP_MCU_FAMILY IN_LIST MICROCHIP_FAMILIES_32) set(CMAKE_SYSTEM_PROCESSOR "PIC_32") + add_definitions(-D__${MICROCHIP_MCU_FAMILY}__ -D__${MICROCHIP_MCU_MODEL}__) else() message(FATAL_ERROR "Unsupported MCU family '${MICROCHIP_MCU_FAMILY}'." @@ -118,3 +124,59 @@ else() "Invalid MICROCHIP_MCU value '${MICROCHIP_MCU}'." ) endif() + +#En caso de estar ya configurado el compilador, restauro los flags +message(STATUS "microchip toolchain") +if(MICROCHIP_XC32_PATH) + set(link_flags "") + set(compile_flags "") + + if(MICROCHIP_MCU_FAMILY STREQUAL "PIC32MX") + set(lib_directory pic32mx) + else() + set(lib_directory pic32-libs) + endif() + + include_directories(SYSTEM ${MICROCHIP_XC32_PATH}/${lib_directory}/include) + + list(APPEND compile_flags + "-mprocessor=${MICROCHIP_MCU_MODEL}" + ) + string(APPEND link_flags + " -mprocessor=${MICROCHIP_MCU_MODEL}" + ) + if(MICROCHIP_LINK_SCRIPT OR MICROCHIP_MIN_HEAP_SIZE) + string(APPEND link_flags + " -Wl" + ) + if(MICROCHIP_LINK_SCRIPT) + string(APPEND link_flags + ",--script=\"${MICROCHIP_LINK_SCRIPT}\"" + ) + endif() + if(MICROCHIP_MIN_HEAP_SIZE) + string(APPEND link_flags + ",--defsym=_min_heap_size=${MICROCHIP_MIN_HEAP_SIZE}" + ) + endif() + if(MICROCHIP_MAP_FILE) + string(APPEND link_flags + ",-Map=\"${MICROCHIP_MAP_FILE}\"" + ) + set_property(DIRECTORY APPEND + PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + "${MICROCHIP_MAP_FILE}" + ) + endif() + endif() + string(APPEND CMAKE_C_LINK_FLAGS + ${link_flags} + ) + add_compile_options( + ${compile_flags} + ) + add_compile_options( + "$<$:-DNDEBUG>" + "$<$:-g>" + ) +endif()