[CMake] Multiple libraries, same name...

Ryan C. Gordon icculus at icculus.org
Tue Feb 2 00:39:49 EST 2010


I'm trying to add bindings for various scripting languages to my library 
PhysicsFS ( http://icculus.org/physfs/ ), and I'm having some trouble.

Eventually I end up with something like this abbreviated example for the 
Perl bindings...

     # This is the actual main library, not the binding.
     ADD_LIBRARY(physfs SHARED whatever)

     # This is the binding.
     ADD_LIBRARY(physfs-perl SHARED "physfs-perl.c")
     TARGET_LINK_LIBRARIES(physfs-perl physfs)
     SET_TARGET_PROPERTIES(physfs-perl PROPERTIES OUTPUT_NAME "physfs")
     INSTALL(TARGETS physfs-perl LIBRARY DESTINATION "${_INSTALLPATH}")

...the problem is, of course, the OUTPUT_NAME. It ends up overwriting 
the libphysfs.so for the base library. The problem, though, is that you 
need this library name for Perl. I could keep the original name of 
physfs-perl, but that is awkward for actual usage in perl...

    # I assume the '-' confuses this, but you get the point.
    use physfs-perl;
    physfs-perl::init("");

...I'd rather that be the more concise "use physfs;" etc, but that 
requires the same library name as the base library, installed in a 
different path that Perl likes.

Is there some way to get cmake to store linker output somewhere else? 
Like, the physfs target puts its final shared libraries in 
CMakeFiles/physfs.dir, and the perl ones go in 
CMakeFiles/physfs-perl.dir? Currently they all go in the base of the 
binaries directory, even if this proves catastrophic. Perhaps they can 
have different file names but can be overridden in the INSTALL directive?

Specifying a path on OUTPUT_NAME confuses the build system, so that's 
not the right route, I think.

This is with CMake 2.8.0.

Thanks for any insight!

--ryan.



More information about the CMake mailing list