Skip to content

Commit

Permalink
Add tentative support for XC32.
Browse files Browse the repository at this point in the history
This hasn't been tested all the way to a device, but it at least
gets as far as invoking the compiler successfully.
  • Loading branch information
Elemecca committed Jun 18, 2016
1 parent f4bd932 commit ffa84f3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Modules/MicrochipPathSearch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

function(MICROCHIP_PATH_SEARCH outvar target)
set(options)
list(APPEND oneValueArgs "CACHE")
list(APPEND oneValueArgs CACHE STORE_VERSION)
set(multiValueArgs BAD_VERSIONS)
cmake_parse_arguments(SEARCH
"${options}" "${oneValueArgs}" "${multiValueArgs}"
Expand Down Expand Up @@ -87,8 +87,10 @@ function(MICROCHIP_PATH_SEARCH outvar target)

if(best_good_path)
set(result "${best_good_path}")
set(result_version "${best_good_version}")
elseif(best_bad_path)
set(result "${best_bad_path}")
set(result_version "${best_good_version}")

message(WARNING
"Version ${best_bad_version} of ${target} is known"
Expand All @@ -97,6 +99,7 @@ function(MICROCHIP_PATH_SEARCH outvar target)
)
else()
set(result "${outvar}-NOTFOUND")
set(result_version "${SEARCH_STORE_VERSION}-NOTFOUND")
endif()

string(APPEND msg
Expand All @@ -115,4 +118,8 @@ function(MICROCHIP_PATH_SEARCH outvar target)
)
endif()
set(${outvar} "${result}" PARENT_SCOPE)

if(SEARCH_STORE_VERSION)
set(${SEARCH_STORE_VERSION} "${result_version}" PARENT_SCOPE)
endif()
endfunction()
41 changes: 41 additions & 0 deletions Modules/Platform/MicrochipMCU-C-XC32.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#=============================================================================
# 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-C`
# 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
)

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(CMAKE_C_COMPILER xc32-gcc)
set(MICROCHIP_C_COMPILER_ID XC32)

add_compile_options(
"-mprocessor=${MICROCHIP_MCU_MODEL}"
)
string(APPEND CMAKE_C_LINK_FLAGS
" -mprocessor=${MICROCHIP_MCU_MODEL}"
)
2 changes: 2 additions & 0 deletions Modules/Platform/MicrochipMCU-C.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

if(CMAKE_SYSTEM_PROCESSOR STREQUAL "PIC_16")
include(Platform/MicrochipMCU-C-XC16)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "PIC_32")
include(Platform/MicrochipMCU-C-XC32)
else()
message(FATAL_ERROR
"No C compiler for '${CMAKE_SYSTEM_PROCESSOR}'"
Expand Down

0 comments on commit ffa84f3

Please sign in to comment.