CMake: Overriding Mac OS X naming convention libfoo.1.dylib with libfoo.so.1

We are trying to create shared libraries using CMake on Mac OS X using the shared library naming convention used by Linux, Solaris, etc., i.e. libfoo.so.1

instead of libfoo.1.dylib

. This is for internal deployment where we have an existing Linux deployment and want to simulate a Mac OS X deployment after it so that other tools don't need to change.

I can change .so

to .dylib

using

set_target_properties(OpenImageIO
                      PROPERTIES
                      SUFFIX .so)

      

However, I am unable to set up the order correctly. Attempt

set_target_properties(OpenImageIO
                      PROPERTIES
                      OUTPUT_NAME libOpenImageIO.so.${SOVERSION})

      

ends up build/macosx/libOpenImageIO/liblibOpenImageIO.so.32.1.2.0.so

which assumes that it OUTPUT_NAME

is only for the base part of the shared library, and CMake will always reorder SUFFIX and VERSION.

I've searched CMake source code and can't find where this code is installed.

+3


source to share


1 answer


The behavior of entering the version name before the suffix is .dylib

hardcoded for Mac OS X in a method cmTarget::ComputeVersionedName

(see CMake source file cmTarget.cxx).

However, you can use CMake to generate the desired name by setting the target properties like this:



if (APPLE)
    set_property(TARGET OpenImageIO PROPERTY PREFIX "lib")
    set_property(TARGET OpenImageIO PROPERTY OUTPUT_NAME "OpenImageIO.so")
    set_property(TARGET OpenImageIO PROPERTY SUFFIX "")
    set_property(TARGET OpenImageIO PROPERTY SOVERSION "32.1.2.0")
endif()

      

+5


source







All Articles