<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"DejaVu Sans Mono";
        panose-1:2 11 6 9 3 8 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:10.0pt'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>I'm working on an embedded project using a Microchip microcontroller. I want to use Cmake to do the configuration so that I can store the project and build settings under change control, as well as have the configuration compatible with development windows machines, and an automated build system on a linux server.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>Microchip provides a modified gcc suite for their compiler, so I figured I could use a cross-platform toolchain file. The compiler directory is put in the PATH on install, so I just use &quot;pic30-gcc&quot; in said toolchain file. Long story short, using the MinGW MSYS environment, I can get cmake to configure the project and use the MSYS make utility to build it, which works beautifully.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>I wanted to then try some other generators so I can for example, make Code::Blocks projects. However, when I went to use the MinGW generator, I ran into a problem:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>C:\Users\dmitri.kourennyi\Documents\Development\testing\mingw&gt;cmake -G &quot;MinGW Makefiles&quot; ..<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>-- The C compiler identification is unknown<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>-- The CXX compiler identification is GNU<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>-- Check for working C compiler: C:/Program Files (x86)/Microchip/mplabc30/v3.30c/bin/pic30-gcc.exe<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>-- Check for working C compiler: C:/Program Files (x86)/Microchip/mplabc30/v3.30c/bin/pic30-gcc.exe -- broken<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; The C compiler &quot;C:/Program Files<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; (x86)/Microchip/mplabc30/v3.30c/bin/pic30-gcc.exe&quot; is not able to compile a<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; simple test program.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; It fails with the following output:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp;&nbsp; Change Dir: C:/Users/dmitri.kourennyi/Documents/Development/testing/mingw/CMakeFiles/CMakeTmp<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; Run Build Command:C:/MinGW/bin/mingw32-make.exe &quot;cmTryCompileExec/fast&quot;<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTryCompileExec.dir\build.make<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; CMakeFiles/cmTryCompileExec.dir/build<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; mingw32-make.exe[1]: Entering directory<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; `C:/Users/dmitri.kourennyi/Documents/Development/testing/mingw/CMakeFiles/CMakeTmp'<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; &quot;C:\Program Files (x86)\CMake 2.8\bin\cmake.exe&quot; -E cmake_progress_report<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; C:\Users\dmitri.kourennyi\Documents\Development\testing\mingw\CMakeFiles\CMakeTmp\CMakeFiles<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; 1<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; C:\PROGRA~2\MICROC~1\mplabc30\v3.30c\bin\PIC30-~4.EXE -o<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; CMakeFiles\cmTryCompileExec.dir\testCCompiler.c.obj -c<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; C:\Users\dmitri.kourennyi\Documents\Development\testing\mingw\CMakeFiles\CMakeTmp\testCCompiler.c<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; mingw32-make.exe[1]: ***<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; [CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj] Error 255<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; mingw32-make.exe[1]: Leaving directory<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; `C:/Users/dmitri.kourennyi/Documents/Development/testing/mingw/CMakeFiles/CMakeTmp'<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; mingw32-make.exe: *** [cmTryCompileExec/fast] Error 2<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; CMake will not be able to correctly generate this project.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>Call Stack (most recent call first):<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>&nbsp; CMakeLists.txt:5 (PROJECT)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>-- Configuring incomplete, errors occurred!<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>After troubleshooting it for a while, including using the --debug-trycompile option, I was able to determine that the following command is the problem:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>C:\PROGRA~2\MICROC~1\mplabc30\v3.30c\bin\PIC30-~4.EXE<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>Pasting this line into the command prompt does nothing, even though it should say that no input file was specified.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>In order to confirm this, I edited the CMakeCache.txt file and set CMAKE_C_COMPILER_WORKS:INTERNAL to TRUE, then replaced all instances of C:\PROGRA~2\MICROC~1\mplabc30\v3.30c\bin\PIC30-~4.EXE with &quot;C:/Program Files (x86)/Microchip/mplabc30/v3.30c/bin/pic30-gcc.exe&quot; (quotes included). With this configuration the make procedure works fine.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>I tried using CMAKE_FORCE_C_COMPILER, which does bypass the compiler check, but the make still fails because the 8.3 path is still used in the Makefiles.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>To summarize, for whatever reason the compiler refuses to run when invoked using the 8.3 naming conventions. I can work around it by bypassing the compiler check and reconverting the 8.3 path to the fully qualified path manually. Is there any way I can avoid this problem so the cmake generation procedure stays automatic and easy? Or is this a bug in the compiler/MinGW, or other issue altogether?<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>-Dmitri<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>Toolchain file (C30.cmake):<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'># this one is important<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>SET(CMAKE_SYSTEM_NAME Generic)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>#this one not so much<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>SET(CMAKE_SYSTEM_VERSION 1)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'># specify the cross compiler<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>SET(CMAKE_C_COMPILER&nbsp;&nbsp; pic30-gcc)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'># where is the target environment <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>SET(CMAKE_FIND_ROOT_PATH&nbsp; &quot;C:/Program Files (x86)/Microchip/mplabc30/v3.30c&quot;)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'># search for programs in the build host directories<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'># for libraries and headers in the target directories<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)</span><span style='font-size:10.0pt'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>Project file (CMakeLists.txt):<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>SET(CMAKE_TOOLCHAIN_FILE C30.cmake)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>CMAKE_MINIMUM_REQUIRED(VERSION 2.8)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>PROJECT(MicrochipCMakeTest)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>SET(CMAKE_C_FLAGS &quot;-Wall -Os&quot;)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>SET(CMAKE_EXE_LINKER_FLAGS &quot;-Wl,--report-mem&quot;)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>##### Create cof binary<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"DejaVu Sans Mono"'>ADD_EXECUTABLE(hikari01.cof main.c)<o:p></o:p></span></p></div></body></html>