|
| 1 | +#============================================================================= |
| 2 | +# Copyright 2016 Sam Hanes |
| 3 | +# |
| 4 | +# Distributed under the OSI-approved BSD License (the "License"); |
| 5 | +# see accompanying file COPYING.txt for details. |
| 6 | +# |
| 7 | +# This software is distributed WITHOUT ANY WARRANTY; without even the |
| 8 | +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 9 | +# See the License for more information. |
| 10 | +#============================================================================= |
| 11 | +# (To distribute this file outside of CMake-Microchip, |
| 12 | +# substitute the full License text for the above reference.) |
| 13 | + |
| 14 | +# this module is called by `Platform/MicrochipMCU-C` |
| 15 | +# to provide information specific to the XC32 compiler |
| 16 | + |
| 17 | +include(MicrochipPathSearch) |
| 18 | +MICROCHIP_PATH_SEARCH(MICROCHIP_XC32_PATH xc32 |
| 19 | + CACHE "the path to a Microchip XC32 installation" |
| 20 | + STORE_VERSION MICROCHIP_C_COMPILER_VERSION |
| 21 | +) |
| 22 | + |
| 23 | +if(NOT MICROCHIP_XC32_PATH) |
| 24 | + message(FATAL_ERROR |
| 25 | + "No Microchip XC32 compiler was found. Please provide the path" |
| 26 | + " to an XC32 installation on the command line, for example:\n" |
| 27 | + "cmake -DMICROCHIP_XC32_PATH=/opt/microchip/xc32/v1.42 ." |
| 28 | + ) |
| 29 | +endif() |
| 30 | + |
| 31 | +set(CMAKE_FIND_ROOT_PATH ${MICROCHIP_XC32_PATH}) |
| 32 | + |
| 33 | +set(CMAKE_C_COMPILER xc32-gcc) |
| 34 | +set(MICROCHIP_C_COMPILER_ID XC32) |
| 35 | + |
| 36 | +add_compile_options( |
| 37 | + "-mprocessor=${MICROCHIP_MCU_MODEL}" |
| 38 | +) |
| 39 | +string(APPEND CMAKE_C_LINK_FLAGS |
| 40 | + " -mprocessor=${MICROCHIP_MCU_MODEL}" |
| 41 | +) |
0 commit comments