[Cmake] Re: Building static libraries

Bill Hoffman bill . hoffman at kitware . com
Wed, 11 Jun 2003 11:54:19 -0400


I think the script is still wrong, the output should be something like this:

$ gcc -E CMakeTestGNU.c
# 1 "CMakeTestGNU.c"

void THIS_IS_GNU();


With no errors.

This error:
g++: CMakeTestGNU.o: No such file or directory

is what is causing your problem.

Once cmake is able to correctly determine that this is the gnu compiler,
it will stop using CXX instead of ar.    The native compiler on the sun,
CC must use CC -ar to create static libraries so that templates are instantiated
correctly.    If CMake is not able to determine that this is the gnu compiler,
it will assume that it is the native compiler.

-Bill

At 11:20 AM 6/11/2003, Zennard Sun wrote:
>Hi Bill,
>   In response to your question, mpiCC -E CMakeTestGNU.c gives me
>
># 1 "CMakeTestGNU.c"
># 1 "<built-in>"
># 1 "<command line>"
># 1 "CMakeTestGNU.c"
>
>void THIS_IS_GNU();
>g++: CMakeTestGNU.o: No such file or directory
>
>   So I think that the script does pass the arguments to gcc.
>
>   However, my second question (below) was more about how CMake decides when to use the archiver ar or mpiCC instead.  Why does CMake use the CXX compiler when building libraries instead of using ar?  Thanks.
>
>
>               Sincerely,
>               Zennard Sun
>
>Bill Hoffman wrote:
>
>>The best place for questions like this is the cmake mailing list,
>>so I have moved this discussion to the list.
>>
>>Looks like the problem is that cmake is not able to figure out that
>>mpicc is really the gnu compiler.
>>In ~/CMake/Modules, there is a file called CMakeTestGNU.c, if you run
>>mpicc -E CMakeTestGNU.c what happens?
>>
>>It should pre-process the file.   My guess is that your script does not
>>forward the -E option.
>>
>>
>>
>>-Bill
>>
>>At 10:19 AM 6/11/2003, you wrote:
>> 
>>
>>>Hi,
>>> I'm pretty new to CMake and I'm highly considering using CMake over Automake and Autoconf to manage our makefiles.  I think CMake seems to be a lot more intuitive, user-friendly, and more effcient, although the documentation leaves out a few things such as CMAKE_SYSTEM and CMAKE_COMPILER_IS_GNUXX (from the March 01 2002 post by Bill Hoffman).  
>>>I have two questions:
>>>
>>>1)  We use mpich, so I put mpiCC as the CXX compiler (essentially a script that eventually calls gcc).  However, under normal builds, CMake seems to add the options KPIC, which is unrecongnized.  I did not specify these options under normal builds or any of the other builds.
>>>
>>>ex:
>>>mpicc  -KPIC hello.o .........
>>>results in
>>>g++: unrecognized option `-KPIC'
>>>
>>>Is there a way I can get rid of these parameters from being passed in?
>>>
>>>2)  I am trying to also build a static library from a C++ file
>>>
>>>ADD_LIBRARY(zz STATIC hello/hello1.cc)
>>>
>>>but for some reason CMake runs mpiCC instead of the archiver ar
>>>
>>>mpiCC -xar -o libzt.a hello1.o
>>>
>>>It runs correctly (ar cr libzt.a  hello1.o) if I use gcc as the CXX compiler or if hello1 is a c file (hello1.c).  Is this a bug and how could I fix this?  Thank you very much.
>>>
>>>
>>>
>>>PS. please do not post this email adress on the web so spammers can find it.  Thanks!
>>>
>>>
>>>    Sincerely,
>>>    Zennard Sun
>>>   
>>
>>
>>
>> 
>
>
>_______________________________________________
>Cmake mailing list
>Cmake at public . kitware . com
>http://public . kitware . com/mailman/listinfo/cmake