[CMake] Problem with cygwin and CodeSourcery's ARM Toolchain
Hendrik Sattler
post at hendrik-sattler.de
Thu May 7 13:53:17 EDT 2009
Am Donnerstag 07 Mai 2009 18:15:40 schrieb Thomas Kindler:
> Hendrik Sattler wrote:
> > Zitat von Thomas Kindler <mail+cmake at t-kindler.de>:
> >> cmake tries to use cygwin-style absolute "/home/tkindler.." paths,
> >> which arm-none-eabi-gcc doesn't seem to like (being a native win32
> >> program).
> >>
> >> My old makefile used relative paths to invoke the compiler. How can I
> >> do this in cmake generated makefiles?!
> >>
> >> Prepending "c:/cygwin/" to all paths should also solve the problem.
> >
> > If you have a native compiler, use the native compiled cmake. If you
> > have a compiler/tool that depends on cygwin, use the cygwin-compiled
> > cmake. Living in both worlds (native vs. cygwin) is a major pain. Just
> > don't.
>
> Ok.. that part seems to work after installing the native windows cmake.
>
> The resulting binary is still not usable -- cmake inserts an "-fPIC"
> linker flag.
>
> arm-none-eabi-gcc.exe -fPIC $(stm32test_OBJECTS) [..]
>
> How can I switch that off?
$ cmake --help-property ENABLE_EXPORTS
[...]
ENABLE_EXPORTS
Specify whether an executable exports symbols for loadable modules.
Normally an executable does not export any symbols because it is the
final program. It is possible for an executable to export symbols to
be used by loadable modules. When this property is set to true CMake
will allow other targets to "link" to the executable with the
TARGET_LINK_LIBRARIES command. On all platforms a target-level
dependency on the executable is created for targets that link to it.
For non-DLL platforms the link rule is simply ignored since the
dynamic loader will automatically bind symbols when the module is
loaded. For DLL platforms an import library will be created for the
exported symbols and then used for linking. All Windows-based systems
including Cygwin are DLL platforms.
I guess that the default is true, contrary to the help message. I think this
is a bug. Setting it to false should get rid of the -fPIC, maybe.
> I also need to specify a special linker script for my target. In my
> plain old makefile I just added -Tstm32f10x.ld to my linker command line.
Use the LINK_FLAGS/LINK_FLAGS_<CONFIG> target properties. Or actually better,
this obviously belongs to the toolchain file. Try
SET ( CMAKE_EXE_LINKER_FLAGS_INIT -T/an/absolute/path/to/stm32f10x.ld )
And yes, the path must be absolute.
> What's the official cmake way to add custom linker flags?!
>
> Adding it to target_link_libraries( .. ) seems to work, but feels wrong.
>
> Also: Right now, I have to invoke cmake by this lengthy command:
>
> cmake -DCMAKE_TOOLCHAIN_FILE=CodeSourcery.cmake -G"Unix Makefiles" .
>
> when compiling the project for the first time. How can I specify a
> default toolchain and generator in the CMakeLists.txt itself?
No. But you can write a small batch file and give it a good name. Good old
methods never die.
HS
More information about the CMake
mailing list