[CMake] Adding a new language for a multiple language project - CMAKE_AR problem(?)

fungos fungos at gmail.com
Mon Oct 27 21:36:13 EDT 2014


Hello,

I'm trying to create a simple exercise, a definition for a virtual language
"X" that will be used side-by-side with C and C++.
There are some restrictions on the level of compatibility with C/C++. For
instance, the objects of this language aren't directly compatible with C
and C++ but then there is a virtual application "X linker/librarian" that
is capable of converting X objects into C objects generating a standard C
lib (note the absence of a temporary objects in the C format, this is
important).

Now, the project is composed of a subproject of type language X, that
generate a lib, another subproject that generate another lib (a C one) and
then the base project that should link libc with libx to create an
executable.

proj/libx/CMakeLists.txt -> define: project(libx X) -> generate prefixlibx.a
proj/libc/CMakeLists.txt -> define: project(libc C) -> generate libc.a
proj/app/CMakeLists.txt -> define: project(app C) -> generate exec.elf that
links libc.a and prefixlibx.a

Everything _almost_ work the way I want, with exception of the
librarian/linker.
If I force in CMakeDetermineXCompiler.cmake the CMAKE_AR to "xar" and
"xranlib", it will use then to do the libx AND libc.
If I do not force CMAKE_AR and let find_program determine, it will use "ar"
for both libc AND libx.

Why can't I use CMAKE_AR as "xar" inside a X project that is inside a C
project?

I think that if something like CMAKE_<LANG>_AR and others existed, we would
be able to do more complex things for example (enabling the use of < >
variables).

All this is only hypothetical and I'm using this to understand better CMake
and try to map how I can _implement_ _new_ languages and toolsets to use
with our custom tools.

Here is a link to my repository where I added this cmake test:
https://github.com/fungos/cmake_langx

Thank you
Danny Grein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20141027/56a3e926/attachment.html>


More information about the CMake mailing list