[CMake] cmake install target doesn't run ldconfig after installing library

Young Yang afe.young at gmail.com
Sun Jun 19 21:16:11 EDT 2016


Thanks :)

I think there should be better solutions. But It's the best solution I know
so far.

On Fri, Jun 17, 2016 at 9:07 PM, Matthew Keeler <mkeeler at tenable.com> wrote:

> So I did some experimenting. It would seem there are a few rules to the
> order installs are executed
>
> 1 - installs are processed in the order the containing CMakeLists.txt
> files are
> 2 - within a CMakeLists.txt they seem to be ordered based on which comes
> first in the file.
>
> So a not so elegant workaround would be to create a post-install directory
> in your source tree and have the last line of your main CMakeLists.txt be
> to add_subdirectory(post-install). Then all your post-install logic can
> live in there.
>
> --
> Matt Keeler
>
>
> On June 16, 2016 at 21:01:46, Young Yang (afe.young at gmail.com) wrote:
>
> Thanks!
> This command really solve my problem.
>
> But I still get a problem about the command order now.
>
> I have some sub directories.
> For e.g. One of them is called "src" and there is also a CMakeLists.txt in
> it. And the shared library installation instructions are in it.
> So I have `ADD_SUBDIRECTORY(src)` in my main CMakeLists.txt.
>
> I put the command `install(CODE "execute_process(COMMAND ldconfig)")`
>  after `ADD_SUBDIRECTORY(src)` . But It still  run ldconfig before the
> installation of shared libraries in src sub folder.
>
>
>
> On Thu, Jun 16, 2016 at 9:02 PM, Matthew Keeler <mkeeler at tenable.com>
> wrote:
>
>> CMake won’t and in my opinion shouldn’t implicitly invoke ldconfig for
>> you. There are many scenarios and platforms where this is incorrect
>> behavior and some such as running install to prepare for packaging that
>> CMake wouldn’t reliably be able to detect.
>>
>> If you want to provide the functionality for your users you could add
>> something like the following to your CMakeLists.txt:
>>
>> install(CODE “execute_process(COMMAND ldconfig)”)
>>
>> This will need to run after your other installed targets. I can’t find
>> any way in the CMake documentation to force install ordering but it seems
>> like as long as CMake processes that install command last it will perform
>> it last. So at the very end of your top level CMakeLists.txt file should do
>> the trick.
>>
>> --
>> Matt Keeler
>>
>>
>> On June 15, 2016 at 22:12:09, Young Yang (afe.young at gmail.com) wrote:
>>
>> Hi,
>> I've encountered some problem when writing install target with cmake.
>>
>> I use `install (TARGETS <my_shared_library> DESTINATION lib)` to install
>> my shared_library.
>> However, when I run `make install`. It just install the .so to
>> /usr/local/lib and didn't run the ldconfig.
>>
>> I think it is strange and inconvenient to tell the user he should run
>> ldconfig by himself or herself.
>>
>> What is the best way to make the ldconfig run automatically?
>>
>>
>> Thanks in advance :)
>>
>> --
>> Best wishes,
>> Young Yang
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>>
>>
>
>
> --
> Best wishes,
> Young Yang
>
>


-- 
Best wishes,
Young Yang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160620/24a9f297/attachment.html>


More information about the CMake mailing list