[cmake-developers] [Ninja] Status and roadmap

Nicolas Desprès nicolas.despres at gmail.com
Tue Apr 19 12:54:56 EDT 2011


2011/4/12 Nicolas Desprès <nicolas.despres at gmail.com>:
> 2011/4/11 Brad King <brad.king at kitware.com>:
>> On 04/11/2011 05:16 AM, Nicolas Desprès wrote:
>>> I have continued my work on the Ninja generator this weekend and I
>>
>> Great!  Thanks for working on this.
>>
>>> Here my roadmap:
>>> 1/ Configure and build an helloworld program with a shared library.

I have this one working now and I also support project with recursive
CMakeLists.txt.

However I had to overload:

void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
cmTarget& tgt, bool relink);

and I am the only generator doing it, so I think it may be a problem.
I need to do it because this method writes something like that:

-rdynamic libgreeting.so
-Wl,-rpath,/home/despre_n/src/test/helloworld-shared-cmake/_build-make

and my problem is that it is mixing dependencies and flags.

So my version write only:

-rdynamic -Wl,-rpath,/home/despre_n/build/test/helloworld-shared-cmake/_build

and I get the dependency list from another function. Actually I
extracted it from OutputLinkLibraries().

Here the differences in the generated command line:

Makefile:
/usr/bin/c++   -g   CMakeFiles/helloworld.dir/src/main.cc.o  -o
helloworld -rdynamic libgreeting.so
-Wl,-rpath,/home/despre_n/src/test/helloworld-shared-cmake/_build-make

Ninja:
/usr/bin/c++   -g   CMakeFiles/helloworld.dir/src/main.cc.o
libgreeting.so  -o helloworld -rdynamic
-Wl,-rpath,/home/despre_n/build/test/helloworld-shared-cmake/_build

I had to do that because I want to generate only one Ninja link rule
for a given language and target type. For example I generate this

# Rule for linking CXX shared library.
rule CXX_SHARED_LIBRARY_LINKER
  command = /usr/lib/ccache/g++  -fPIC $CXX_FLAGS $LDFLAGS -shared
-Wl,-soname,$SONAME -o $out $in $LDLIBS
  description = Linking CXX shared library $out

# Rule for linking CXX executable.
rule CXX_EXECUTABLE_LINKER
  command = /usr/lib/ccache/g++   $CXX_FLAGS  $LDFLAGS $in  -o $out $LDLIBS
  description = Linking CXX executable $out

The $in variables is automatically expanded by Ninja with the
dependencies and the other variables are set for each target build
statements:

# Link the shared library libgreeting.so
build libgreeting.so: CXX_SHARED_LIBRARY_LINKER
CMakeFiles/greeting.dir/src/greeting/greeting.cc.o
  CXX_FLAGS = -g
  SONAME = libgreeting.so

# Link the executable helloworld
build helloworld: CXX_EXECUTABLE_LINKER
CMakeFiles/helloworld.dir/src/main.cc.o libgreeting.so
  CXX_FLAGS = -g
  LDLIBS = -rdynamic
-Wl,-rpath,/home/despre_n/build/test/helloworld-shared-cmake/_build

It seems not to be an issue with g++ but It might break with other
compiler/language. I don't know. There are several workaround possible
to fix this. I will see when the time will come.

Also I dropped the generation of a "clean" target since I have
implemented a tool in Ninja doing the job with more feature and way
easier to implement.  It is waiting to be merged with the upstream:
https://github.com/polrop/ninja/commits/more-options-and-tools

[...]

-- 
Nicolas Desprès



More information about the cmake-developers mailing list