[CMake] question about SHARED and MODULE

Philip Lowman philip at yhbt.com
Wed Jan 24 18:12:17 EST 2007


Marcin Gil wrote:
> Dnia środa, 24 stycznia 2007 22:43, napisałeś:
> 
>> That's my problem, I don't have a platform that supports this.  I was
>> wondering if anyone else had any experience with this.
> 
> So you have to use just one - because the resulting file will be exactly the 
> same for both.

If you use the MODULE option, CMake rightly complains if you try to link
a target against that library.

I can get away with the SHARED option but placing it in a gazillion
CMakeLists.txt files will mean that everything will work as expected
until one day I want to port to MacOS and use dylibs.

I was just wondering if there was a middle ground bearing in mind I'd
prefer to keep the target names all the same (since I'd like to use the
same target name everywhere instead of adding a hacked-up exception for
MacOS later).  ADD_LIBRARY(foo_module MODULE sources...) would probably
work but would cause a lot of uglyness not to mention adding exceptions
to make sure that the Linux and Windows build don't build the library twice.

Of course I'm probably not looking at this from the perspective of
setting values on the ADD_LIBRARY object and things like that.  It may
be fundamentally incapable of generating both a dylib and a normal
shared library at the same time.

Nevermind... I'm making a mountain out of a molehill. :)

>> Judging by behavior when I swap the ordering of ADD_LIBRARY(foo SHARED
>> ...) and ADD_LIBRARY(foo MODULE ...) I suspect that this is a bug.
>>
> I don't fully understand what you mean by saying "judging by behavior"..

I noticed when I swap the ordering of the two declarations the error
message I get when I try to link a library against a MODULE appears and
disappears as I swap the order (which leads me to believe that when
making two ADD_LIBRARY declarations for the same target either the first
declaration or the second declaration is being considered, but not both,
and no syntax error is thrown).

-- 
Philip Lowman
Simulation Development Engineer, Modeling and Simulation Technology
General Dynamics Land Systems
http://www.gdls.com


More information about the CMake mailing list