Skip to content

Commit 8685588

Browse files
author
Rait Rääk
committed
CXX
1 parent de389e7 commit 8685588

5 files changed

+110
-4
lines changed

Modules/Platform/MicrochipMCU-C-XC32.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
# to provide information specific to the XC32 compiler
1616

1717
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-
)
18+
if(NOT MICROCHIP_XC32_PATH)
19+
MICROCHIP_PATH_SEARCH(MICROCHIP_XC32_PATH xc32
20+
CACHE "the path to a Microchip XC32 installation"
21+
STORE_VERSION MICROCHIP_C_COMPILER_VERSION
22+
)
23+
endif()
2224

2325
if(NOT MICROCHIP_XC32_PATH)
2426
message(FATAL_ERROR
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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-CXX`
15+
# to provide information specific to the XC32 compiler
16+
17+
include(MicrochipPathSearch)
18+
if(NOT MICROCHIP_XC32_PATH)
19+
MICROCHIP_PATH_SEARCH(MICROCHIP_XC32_PATH xc32
20+
CACHE "the path to a Microchip XC32 installation"
21+
STORE_VERSION MICROCHIP_CXX_COMPILER_VERSION
22+
)
23+
endif()
24+
25+
if(NOT MICROCHIP_XC32_PATH)
26+
message(FATAL_ERROR
27+
"No Microchip XC32 compiler was found. Please provide the path"
28+
" to an XC32 installation on the command line, for example:\n"
29+
"cmake -DMICROCHIP_XC32_PATH=/opt/microchip/xc32/v1.42 ."
30+
)
31+
endif()
32+
33+
set(CMAKE_FIND_ROOT_PATH ${MICROCHIP_XC32_PATH})
34+
35+
set(OS_SUFFIX "")
36+
if(WIN32)
37+
string(APPEND OS_SUFFIX ".exe")
38+
endif()
39+
40+
set(CMAKE_CXX_COMPILER ${MICROCHIP_XC32_PATH}/bin/xc32-g++${OS_SUFFIX} CACHE STRING "" FORCE)
41+
set(MICROCHIP_CXX_COMPILER_ID XC32)
42+
43+
set(CMAKE_CXX_FLAGS "-mprocessor=${MICROCHIP_MCU_MODEL}" CACHE STRING "" FORCE)
44+
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf" CACHE STRING "" FORCE)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 loaded during the search for a CXX compiler
15+
# to provide the information necessary to find one.
16+
17+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "PIC_32")
18+
include(Platform/MicrochipMCU-CXX-XC32)
19+
else()
20+
message(FATAL_ERROR
21+
"No CXX compiler for '${CMAKE_SYSTEM_PROCESSOR}'"
22+
" is supported yet."
23+
)
24+
endif()
25+
26+
if(MICROCHIP_CXX_COMPILER_ID)
27+
message(STATUS
28+
"Using Microchip CXX compiler ${MICROCHIP_CXX_COMPILER_ID}"
29+
" ${MICROCHIP_CXX_COMPILER_VERSION}"
30+
)
31+
endif()

Modules/Platform/MicrochipMCU-GNU-C.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
# for XC16, inject properties that may have been missed
1818
# see `Platform/MicrochipMCU-C-XC16` for explanation
19+
1920
if(MICROCHIP_C_COMPILER_ID STREQUAL "XC16")
2021
if(NOT CMAKE_C_COMPILE_FEATURES)
2122
set(CMAKE_C_COMPILE_FEATURES "c_function_prototypes;c_restrict;c_variadic_macros")
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 after the compiler has been determined
15+
# to set up information specific to Microchip GNU CXX compilers
16+
17+
# for XC32, inject properties that may have been missed
18+
# see `Platform/MicrochipMCU-CXX-XC32` for explanation
19+
20+
if(MICROCHIP_CXX_COMPILER_ID STREQUAL "XC32")
21+
if(NOT CMAKE_CXX_SIZEOF_DATA_PTR)
22+
set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
23+
endif()
24+
25+
if(NOT CMAKE_CXX_COMPILER_ABI)
26+
set(CMAKE_CXX_COMPILER_ABI ELF)
27+
endif()
28+
endif()

0 commit comments

Comments
 (0)