[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    [CMake] AIX exports, CMAKE_C_CREATE_SHARED_LIBRARY, custom commands and OBJECT_DIR property
From:       Brett Delle Grazie <brett.dellegrazie () gmail ! com>
Date:       2012-05-31 14:15:57
Message-ID: CACLD0=4+8FXnc-FGi+9cGne7Ozs+CQ39mVbiA+gjOm5Za+7LOg () mail ! gmail ! com
[Download RAW message or body]

Hi,

Is there any way to supplant / override the C
CMAKE_C_CREATE_SHARED_LIBRARY rule for a specific target (and only
that target) on AIX?
Or alternatively, is there any way to retrieve or construct the
OBJECT_DIR property of a library target (i.e. where the compiled .o
files wind up)
in a custom command?

Specifically:
On AIX we have an externally supplied static library that we are
converting into a shared library. We have:
the static library (sample.a)
a header file (sample.h)
an exports file (sample.exp)

PROJECT(sample)
cmake_minimum_required(VERSION 2.8)
set(USE_FOLDERS ON)

include(GNUInstallDirs)
include(GenerateExportHeader)
add_compiler_export_flags()

set(SAMPLE_SRCS
    sample.h)

# static library variant (supplied)
add_library( sample_static STATIC IMPORTED )
set_target_properties( sample_static PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_SOURCE_DIR}/sample.a )

# make the shared variant (explicitly supply the export as we don't
really have any sources apart from the headers)
add_library( polaris SHARED ${SAMPLE_SRCS} )
set_target_properties( sample PROPERTIES
    LINKER_LANGUAGE C
    PUBLIC_HEADER "${SAMPLE_SRCS}"
    LINK_FLAGS "-bE:${CMAKE_CURRENT_SOURCE_DIR}/sample.exp -bM:SRE -bnoentry"
    )

With just the above, the build will fail with a missing objects.exp.
This is a file generated by the CMAKE_C_CREATE_SHARED_LIBRARY on AIX
which includes an implicit call to CMAKE_XL_CreateExportList. Since we
don't actually compile any objects, the build fails.

I've tried to add a custom rule below to touch the objects.exp so that
it is supplied along with our actual sample.exp but I'm having trouble
locating the object directory where it looks for the objects.exp file.

# the custom rule below fails because OBJECT_DIR is not a recognised generator
add_custom_command( TARGET sample
                    PRE_LINK
                    COMMAND ${CMAKE_COMMAND} -E touch
$<OBJECT_DIR:sample>/objects.exp
                    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
                    VERBATIM)

Can anyone help with either the custom rule, a pointer on how to
override CMAKE_C_CREATE_SHARED_LIBRARY for just this target or a more
suitable technique?

Thanks,

-- 
Kind Regards,

Brett Delle Grazie
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic