Target install path question
Sebastian Trüg
trueg at kde.org
Mon Sep 20 14:25:25 CEST 2010
On 09/20/2010 01:04 PM, Andreas Pakulat wrote:
> On 20.09.10 12:36:28, Sebastian Trüg wrote:
>> Hi,
>>
>> is there a way to get the exact path of a target install path?
>> If I have for example some installation rule like:
>>
>> install(TARGET foobar DESTINATION lib)
>>
>> I would like to use the path of the foobar lib in my FooBarConfig.cmake
>> to set a variable FOOBAR_LIBRARIES.
>> Is that possible without resorting to what the Akonadi version does, ie.
>> construct a different path for each architecture?
>
> I don't know what Akonadi does, but usually the config-files are installed
> to <prefix>/lib<suffix>/cmake/<yourmodule> so you can easily get at the lib
> or bin or share dir by using CMAKE_CURRENT_LIST_FILE variable and
> extracting the path from that. Then use a static relative path from that
> like "../../" (for lib<suffix>) or "../../bin|share" for bin/share.
>
> Using some 'heuristics' like guessing architecture and using that is not
> necessarily reliable as the person building the codebase can change all
> details of the target path by using global cmake variables.
>
> A quick look through the target properties list doesn't seem to indicate
> there is any to extract the final install location. Generally though if you
> have install(TARGET foobar DESTINATION lib) then it'll end up in
> DESTDIR/<prefix>/lib. But I guess you're using some pre-defined variable(s)
> which are platform-dependent?
no, I do not. But since the file extension differs between platforms I
would need to have some heuristic unless cmake provides the full path.
This is true for libs as well as for executables.
That is why Akonadi does the following which I would really like to avoid:
if(WIN32)
if(MINGW)
set(AKONADI_COMMON_LIBRARIES
"@AKONADI_LIB_DIR@/libakonadiprotocolinternals.dll.a")
else(MINGW)
set(AKONADI_COMMON_LIBRARIES
"@AKONADI_LIB_DIR@/akonadiprotocolinternals.lib")
endif(MINGW)
elseif(APPLE)
set(AKONADI_COMMON_LIBRARIES
"@AKONADI_LIB_DIR@/libakonadiprotocolinternals.dylib")
else()
set(AKONADI_COMMON_LIBRARIES
"@AKONADI_LIB_DIR@/libakonadiprotocolinternals.so")
endif()
Maybe I am missing something. I am trying to write a SopranoConfig.cmake
which creates variables for the libraries and also the executables that
are installed.
Cheers,
Sebastian
More information about the Kde-buildsystem
mailing list