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

Young Yang afe.young at gmail.com
Thu Jun 16 21:01:26 EDT 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160617/0f5ad1c5/attachment.html>


More information about the CMake mailing list