Skip to content

Commit ffa84f3

Browse files
committed
Add tentative support for XC32.
This hasn't been tested all the way to a device, but it at least gets as far as invoking the compiler successfully.
1 parent f4bd932 commit ffa84f3

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

Modules/MicrochipPathSearch.cmake

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
function(MICROCHIP_PATH_SEARCH outvar target)
1515
set(options)
16-
list(APPEND oneValueArgs "CACHE")
16+
list(APPEND oneValueArgs CACHE STORE_VERSION)
1717
set(multiValueArgs BAD_VERSIONS)
1818
cmake_parse_arguments(SEARCH
1919
"${options}" "${oneValueArgs}" "${multiValueArgs}"
@@ -87,8 +87,10 @@ function(MICROCHIP_PATH_SEARCH outvar target)
8787

8888
if(best_good_path)
8989
set(result "${best_good_path}")
90+
set(result_version "${best_good_version}")
9091
elseif(best_bad_path)
9192
set(result "${best_bad_path}")
93+
set(result_version "${best_good_version}")
9294

9395
message(WARNING
9496
"Version ${best_bad_version} of ${target} is known"
@@ -97,6 +99,7 @@ function(MICROCHIP_PATH_SEARCH outvar target)
9799
)
98100
else()
99101
set(result "${outvar}-NOTFOUND")
102+
set(result_version "${SEARCH_STORE_VERSION}-NOTFOUND")
100103
endif()
101104

102105
string(APPEND msg
@@ -115,4 +118,8 @@ function(MICROCHIP_PATH_SEARCH outvar target)
115118
)
116119
endif()
117120
set(${outvar} "${result}" PARENT_SCOPE)
121+
122+
if(SEARCH_STORE_VERSION)
123+
set(${SEARCH_STORE_VERSION} "${result_version}" PARENT_SCOPE)
124+
endif()
118125
endfunction()
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
)

Modules/Platform/MicrochipMCU-C.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "PIC_16")
1818
include(Platform/MicrochipMCU-C-XC16)
19+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "PIC_32")
20+
include(Platform/MicrochipMCU-C-XC32)
1921
else()
2022
message(FATAL_ERROR
2123
"No C compiler for '${CMAKE_SYSTEM_PROCESSOR}'"

0 commit comments

Comments
 (0)