[CMake] Cross Compiling
Michael Wild
themiwi at gmail.com
Tue Jan 5 14:11:31 EST 2010
On 5. Jan, 2010, at 19:55 , Alexander Neundorf wrote:
> On Tuesday 05 January 2010, Michael Wild wrote:
>> On 4. Jan, 2010, at 19:15 , Alexander Neundorf wrote:
>> [snip]
>>
>>>> - There is no distinction between install prefixes for the target and
>>>> the host. Sometimes I'd like to put various build tools on the host
>>>> system at the same time as libs and binaries on the target root.
>>>
>>> In CMake one build tree uses one toolchain. So in one build tree you can
>>> only create executable which run either for the target, of for the host,
>>> not both in one go.
>>> So if you need first to create host build tools, and later on use them
>>> for the actual cross compile, you need two build trees. I would recommend
>>> to "export" the executable and "import" them again in the cross build.
>>>
>>> If this is not your problem, but really just the install location, you
>>> can set the install location of every install() command separately, this
>>> is completely independent from the cross compiling support.
>>
>> To automate this you can use the ExternalProject.cmake that comes with
>> CMake-2.8 to build the host tools.
>
> Maybe, I haven't tried to combine this yet.
>
>> You can then use add_executable(tool
>> IMPORTED) and set_target_properties(tool PROPERTIES IMPORTED_LOCATION ...)
>> to import the tool target into the cross-compiling project.
>
> That's not necessary to do manually. You can use the EXPORT feature for the
> necessary executables, something like this:
> If you don't want to install the project first, you can add an
> if(NOT CMAKE_CROSSCOMPILING)
> export(TARGETS ... )
> endif(NOT CMAKE_CROSSCOMPILING)
> to create such a export file in the buildtree.
>
> Alex
>
I thought of that too, but then you have to run CMake a second time after the first build failed because the export file won't be created until build-time. Chicken-egg thing again :-(
Michael
More information about the CMake
mailing list