[CMake] AIX shared libraries

Rob Boehne robb at datalogics.com
Mon Dec 17 17:07:24 EST 2018


AIX supports two types of shared libraries, AIX-style, and System 5 (SYSV) compatibility libraries.  CMake is currently set up to exclusively work with SYSV-style (read the ld man pages for -brtl).
To do this I’m attempting to set the commands to override linking shared libraries.  The default setup forces generating an exports list, which also gives me problems because I explicitly provide one (that is then overridden by the generated list, which comes out empty in my case).  The set commands below almost work, one of the problems is that I can’t see any way to pass flags to commands like “/bin/ar”.  Under AIX, tools like ar, nm, etc. have a strict “object file mode” that can be altered with the -X command line argument.  I couldn’t find any place to pass -X64 or -X32 to /bin/ar, and setting CMAKE_AR with a space in it results in CMAKE_AR==”/bin/ar;-X64” which is not what I want.  Adding double quotes fails because they aren’t escaped, so the command ends up being  sent with argv[0]==”/bin/ar -X64” which fails.  Escaping the space like you see below results in the same behavior.   I don’t have any static archives in the project, but I’m pretty sure there would be problems with them.   I want to create the output of the first command to look like the target filename but with a file extension of “so” rather than “a” but I don’t see any way to do that.

    elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "AIX")
        if(${CMAKE_CXX_COMPILER_ID} STREQUAL "XL")
            if(CMAKE_SIZEOF_VOID_P MATCHES "8")
                set(CMAKE_AR /bin/ar\ -X64)
            else()
                set(CMAKE_AR /bin/ar\ -X32)
            endif()
            # override the broken commands cmake uses to build shared libs on AIX with XLC
            set(CMAKE_SHARED_LIBRARY_SUFFIX ".a")
            set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
            set(CMAKE_SHARED_LINKER_FLAGS_INIT "")
            set(CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES ".so")
            set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-bM:SRE -bnoentry")
            set(CMAKE_CXX_CREATE_SHARED_LIBRARY
                "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>  <SONAME_FLAG><TARGET_SONAME> -o <OBJECT_DIR>/shr.so <OBJECTS> <LINK_LIBRARIES>;<CMAKE_AR> -cru <TARGET> <OBJECT_DIR>/shr.so"
                 )



[cid:image002.png at 01D3D0E3.DCFE6710]

Rob Boehne
Senior Software Architect | Datalogics, Inc.
+1.312.853.8351<tel:(312)%20853-8351> | robb at datalogics.com<mailto:robb at datalogics.com>
datalogics.com<http://www.datalogics.com/> | blogs.datalogics.com<http://blogs.datalogics.com/>

Connect with us: Facebook<https://www.facebook.com/DatalogicsInc> | Twitter<https://twitter.com/DatalogicsInc> | LinkedIn<https://www.linkedin.com/company/datalogics?actionToken=p=p%3Dbiz-company-login%26c%3D3217e65a-bdc2-4b38-8f9c-13c982e8c529%26m%3Dcompany_feed%26n%3D0&t=a%3DisFolloweeOfPoster%253Dfalse%2526distanceFromActor%253D-1%2526actorType%253D%2526likedByUser%253Dfalse%2526targetId%253D%2526recentCommentUrns%253D%2526targetType%253D%2526sponsoredFlag%253DORGANIC%2526verbType%253Dlinkedin%25253Ashare%2526objectType%253Dlinkedin%25253Aarticle%2526totalShares%253D0%2526activityId%253Durn%25253Ali%25253Aactivity%25253A6263731876121362433%2526recentLikerUrns%253D%2526actorId%253Durn%25253Ali%25253Acompany%25253A14000%2526totalComments%253D0%2526relevanceScore%253D0.0%2526recentCommenterUrns%253D%2526isPublic%253Dtrue%2526time%253D-1%2526totalLikes%253D0%2526objectId%253Durn%25253Ali%25253Aarticle%25253A7793179909183391510%2526distanceFromNestedActor%253D-1%26s%3DORG> | YouTube<https://www.youtube.com/user/Datalogics>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181217/a2986157/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 124449 bytes
Desc: image001.png
URL: <https://cmake.org/pipermail/cmake/attachments/20181217/a2986157/attachment-0001.png>


More information about the CMake mailing list