CPack install 3rd party shared libraries

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

CPack install 3rd party shared libraries

Roman Wüger
Hello,

I have a project which depends on a self compiled 3rd party project (boost)
Boost is here only an example, there are other 3rd party libraries too.

If I call the "install" command on the target, then it would be packaged.
But how could I add the shared libraries and especially the links for the shared libraries?

E.g.:
libboost_filesystem.so -> libboost_filesystem.so.1.48.0
libboost_filesystem.so.1.48.0

Thanks in advance

Best Regards
Roman
--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack install 3rd party shared libraries

Elvis Stansvik
2017-07-19 10:24 GMT+02:00 Roman Wüger <[hidden email]>:

> Hello,
>
> I have a project which depends on a self compiled 3rd party project (boost)
> Boost is here only an example, there are other 3rd party libraries too.
>
> If I call the "install" command on the target, then it would be packaged.
> But how could I add the shared libraries and especially the links for the shared libraries?
>
> E.g.:
> libboost_filesystem.so -> libboost_filesystem.so.1.48.0
> libboost_filesystem.so.1.48.0
>
> Thanks in advance

I think fixup_bundle() from BundleUtilities is what you want [1].

We're using it to make our Windows and macOS installs standalone, but
(I think) it should work on Linux as well.

[1] https://cmake.org/cmake/help/v3.8/module/BundleUtilities.html

>
> Best Regards
> Roman
> --
>
> 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
--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack install 3rd party shared libraries

Roman Wüger
The problem with BundleUtilities which Inder is that it doesn't support generator expressions.

Maybe I do something wrong?
But I need to specify the path to the executable (generator expression) and the paths where to look for dependencies. Right?

Please, could you give me a hint?

Regards
Roman

> Am 19.07.2017 um 12:40 schrieb Elvis Stansvik <[hidden email]>:
>
> 2017-07-19 10:24 GMT+02:00 Roman Wüger <[hidden email]>:
>> Hello,
>>
>> I have a project which depends on a self compiled 3rd party project (boost)
>> Boost is here only an example, there are other 3rd party libraries too.
>>
>> If I call the "install" command on the target, then it would be packaged.
>> But how could I add the shared libraries and especially the links for the shared libraries?
>>
>> E.g.:
>> libboost_filesystem.so -> libboost_filesystem.so.1.48.0
>> libboost_filesystem.so.1.48.0
>>
>> Thanks in advance
>
> I think fixup_bundle() from BundleUtilities is what you want [1].
>
> We're using it to make our Windows and macOS installs standalone, but
> (I think) it should work on Linux as well.
>
> [1] https://cmake.org/cmake/help/v3.8/module/BundleUtilities.html
>
>>
>> Best Regards
>> Roman
>> --
>>
>> 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

--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack install 3rd party shared libraries

Elvis Stansvik
2017-07-19 13:42 GMT+02:00 Roman Wüger <[hidden email]>:
> The problem with BundleUtilities which Inder is that it doesn't support generator expressions.
>
> Maybe I do something wrong?
> But I need to specify the path to the executable (generator expression) and the paths where to look for dependencies. Right?

You don't need to use a generator to fetch the executable path. You
will know the path, since you installed the executable with
install(..) :) I think most people essentially hardcode the executable
path in their call to fixup_bundle(..).

If you really want to, I think there is a way to use generator
expressions, and that is to put the fixup_bundle(..) call in a
separate file (say InstallStuff.cmake.in), and then process that file
with file(GENERATE OUTPUT ...) [1] to produce InstallStuff.cmake with
generator expressions evaluated and then use install(SCRIPT
InstallStuff.cmake). But that's much too complicated IMHO, and I would
avoid it.

I made a minimal example that links against zlib and also the Boost
library you mentioned:

cmake_minimum_required(VERSION 2.8)

project(bundletest)

find_package(ZLIB REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem)

add_executable(bundletest main.cpp)

target_include_directories(bundletest PRIVATE ${ZLIB_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS})

target_link_libraries(bundletest ${ZLIB_LIBRARIES} ${Boost_LIBRARIES})

install(TARGETS bundletest
    RUNTIME DESTINATION "bin"
)

install(CODE "
    function(gp_resolved_file_type_override resolved_file type_var)
       set(\${type_var} local PARENT_SCOPE)
    endfunction()
    include(BundleUtilities)
    fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/bin/bundletest\" \"\" \"\")
" COMPONENT Runtime)

main.cpp:

#include <iostream>
#include <zlib.h>
#include <boost/filesystem.hpp>

using namespace boost::filesystem;

int main (int argc, char *argv[]) {
    // Pretend we're using zlib and Boost
    deflateInit(0, 0);
    std::cout << file_size(argv[1]) << std::endl;
    return 0;
}

The overriding of the gp_resolved_file_type_override was necessary, to
make it treat all libraries as local (otherwise it skips "system"
libraries). See the docs for GetPrerequisites.

Building/installing this with

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=~/bundletest_install ..
make install

produces:

/home/estan/bundletest_install
/home/estan/bundletest_install/bin
/home/estan/bundletest_install/bin/bundletest
/home/estan/bundletest_install/bin/libm.so.6
/home/estan/bundletest_install/bin/libstdc++.so.6
/home/estan/bundletest_install/bin/libc.so.6
/home/estan/bundletest_install/bin/libz.so.1
/home/estan/bundletest_install/bin/libpthread.so.0
/home/estan/bundletest_install/bin/libboost_system.so.1.58.0
/home/estan/bundletest_install/bin/libgcc_s.so.1
/home/estan/bundletest_install/bin/libboost_filesystem.so.1.58.0

I did the build on Ubuntu, and tested that it also runs in a clean
Fedora 24 Docker container.

Hope that helps some.

Elvis

[1] https://cmake.org/cmake/help/v3.9/command/file.html

>
> Please, could you give me a hint?
>
> Regards
> Roman
>
>> Am 19.07.2017 um 12:40 schrieb Elvis Stansvik <[hidden email]>:
>>
>> 2017-07-19 10:24 GMT+02:00 Roman Wüger <[hidden email]>:
>>> Hello,
>>>
>>> I have a project which depends on a self compiled 3rd party project (boost)
>>> Boost is here only an example, there are other 3rd party libraries too.
>>>
>>> If I call the "install" command on the target, then it would be packaged.
>>> But how could I add the shared libraries and especially the links for the shared libraries?
>>>
>>> E.g.:
>>> libboost_filesystem.so -> libboost_filesystem.so.1.48.0
>>> libboost_filesystem.so.1.48.0
>>>
>>> Thanks in advance
>>
>> I think fixup_bundle() from BundleUtilities is what you want [1].
>>
>> We're using it to make our Windows and macOS installs standalone, but
>> (I think) it should work on Linux as well.
>>
>> [1] https://cmake.org/cmake/help/v3.8/module/BundleUtilities.html
>>
>>>
>>> Best Regards
>>> Roman
>>> --
>>>
>>> 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
>
--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack install 3rd party shared libraries

Elvis Stansvik
2017-07-19 15:57 GMT+02:00 Elvis Stansvik <[hidden email]>:
> 2017-07-19 13:42 GMT+02:00 Roman Wüger <[hidden email]>:
>> The problem with BundleUtilities which Inder is that it doesn't support generator expressions.
>>
>> Maybe I do something wrong?
>> But I need to specify the path to the executable (generator expression) and the paths where to look for dependencies. Right?

And right, if your dependencies are in some place not searched by
fixup_bundle by default, you need to supply those directories in the
third parameter ("dirs").

In my example below, both zlib and boost were in standard locations on
my system, so I didn't have to.

Elvis

>
> You don't need to use a generator to fetch the executable path. You
> will know the path, since you installed the executable with
> install(..) :) I think most people essentially hardcode the executable
> path in their call to fixup_bundle(..).
>
> If you really want to, I think there is a way to use generator
> expressions, and that is to put the fixup_bundle(..) call in a
> separate file (say InstallStuff.cmake.in), and then process that file
> with file(GENERATE OUTPUT ...) [1] to produce InstallStuff.cmake with
> generator expressions evaluated and then use install(SCRIPT
> InstallStuff.cmake). But that's much too complicated IMHO, and I would
> avoid it.
>
> I made a minimal example that links against zlib and also the Boost
> library you mentioned:
>
> cmake_minimum_required(VERSION 2.8)
>
> project(bundletest)
>
> find_package(ZLIB REQUIRED)
> find_package(Boost REQUIRED COMPONENTS filesystem)
>
> add_executable(bundletest main.cpp)
>
> target_include_directories(bundletest PRIVATE ${ZLIB_INCLUDE_DIRS}
> ${Boost_INCLUDE_DIRS})
>
> target_link_libraries(bundletest ${ZLIB_LIBRARIES} ${Boost_LIBRARIES})
>
> install(TARGETS bundletest
>     RUNTIME DESTINATION "bin"
> )
>
> install(CODE "
>     function(gp_resolved_file_type_override resolved_file type_var)
>        set(\${type_var} local PARENT_SCOPE)
>     endfunction()
>     include(BundleUtilities)
>     fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/bin/bundletest\" \"\" \"\")
> " COMPONENT Runtime)
>
> main.cpp:
>
> #include <iostream>
> #include <zlib.h>
> #include <boost/filesystem.hpp>
>
> using namespace boost::filesystem;
>
> int main (int argc, char *argv[]) {
>     // Pretend we're using zlib and Boost
>     deflateInit(0, 0);
>     std::cout << file_size(argv[1]) << std::endl;
>     return 0;
> }
>
> The overriding of the gp_resolved_file_type_override was necessary, to
> make it treat all libraries as local (otherwise it skips "system"
> libraries). See the docs for GetPrerequisites.
>
> Building/installing this with
>
> mkdir build
> cd build
> cmake -DCMAKE_INSTALL_PREFIX=~/bundletest_install ..
> make install
>
> produces:
>
> /home/estan/bundletest_install
> /home/estan/bundletest_install/bin
> /home/estan/bundletest_install/bin/bundletest
> /home/estan/bundletest_install/bin/libm.so.6
> /home/estan/bundletest_install/bin/libstdc++.so.6
> /home/estan/bundletest_install/bin/libc.so.6
> /home/estan/bundletest_install/bin/libz.so.1
> /home/estan/bundletest_install/bin/libpthread.so.0
> /home/estan/bundletest_install/bin/libboost_system.so.1.58.0
> /home/estan/bundletest_install/bin/libgcc_s.so.1
> /home/estan/bundletest_install/bin/libboost_filesystem.so.1.58.0
>
> I did the build on Ubuntu, and tested that it also runs in a clean
> Fedora 24 Docker container.
>
> Hope that helps some.
>
> Elvis
>
> [1] https://cmake.org/cmake/help/v3.9/command/file.html
>
>>
>> Please, could you give me a hint?
>>
>> Regards
>> Roman
>>
>>> Am 19.07.2017 um 12:40 schrieb Elvis Stansvik <[hidden email]>:
>>>
>>> 2017-07-19 10:24 GMT+02:00 Roman Wüger <[hidden email]>:
>>>> Hello,
>>>>
>>>> I have a project which depends on a self compiled 3rd party project (boost)
>>>> Boost is here only an example, there are other 3rd party libraries too.
>>>>
>>>> If I call the "install" command on the target, then it would be packaged.
>>>> But how could I add the shared libraries and especially the links for the shared libraries?
>>>>
>>>> E.g.:
>>>> libboost_filesystem.so -> libboost_filesystem.so.1.48.0
>>>> libboost_filesystem.so.1.48.0
>>>>
>>>> Thanks in advance
>>>
>>> I think fixup_bundle() from BundleUtilities is what you want [1].
>>>
>>> We're using it to make our Windows and macOS installs standalone, but
>>> (I think) it should work on Linux as well.
>>>
>>> [1] https://cmake.org/cmake/help/v3.8/module/BundleUtilities.html
>>>
>>>>
>>>> Best Regards
>>>> Roman
>>>> --
>>>>
>>>> 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
>>
--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack install 3rd party shared libraries

CMake mailing list
In reply to this post by Elvis Stansvik
Very nice example. Does CMake have a place to put examples like VTK
does...? If so, where is it? And if not, it would be super useful to
start one somewhere "official."

However, one word of caution on the example. I know it was targeted at
Linux, and perhaps for a very simple case it's proper, but using an
unconditional "local" for everything in a
gp_resolved_file_type_override would not be something you'd want to do
in general, especially on Windows. You would end up with probably on
the order of a hundred (or maybe nowadays even a few hundred) DLLs
from the Windows system directories inside your bundle. Almost
certainly not what you intended.


Cheers,
David C.



On Wed, Jul 19, 2017 at 9:57 AM, Elvis Stansvik
<[hidden email]> wrote:

> 2017-07-19 13:42 GMT+02:00 Roman Wüger <[hidden email]>:
>> The problem with BundleUtilities which Inder is that it doesn't support generator expressions.
>>
>> Maybe I do something wrong?
>> But I need to specify the path to the executable (generator expression) and the paths where to look for dependencies. Right?
>
> You don't need to use a generator to fetch the executable path. You
> will know the path, since you installed the executable with
> install(..) :) I think most people essentially hardcode the executable
> path in their call to fixup_bundle(..).
>
> If you really want to, I think there is a way to use generator
> expressions, and that is to put the fixup_bundle(..) call in a
> separate file (say InstallStuff.cmake.in), and then process that file
> with file(GENERATE OUTPUT ...) [1] to produce InstallStuff.cmake with
> generator expressions evaluated and then use install(SCRIPT
> InstallStuff.cmake). But that's much too complicated IMHO, and I would
> avoid it.
>
> I made a minimal example that links against zlib and also the Boost
> library you mentioned:
>
> cmake_minimum_required(VERSION 2.8)
>
> project(bundletest)
>
> find_package(ZLIB REQUIRED)
> find_package(Boost REQUIRED COMPONENTS filesystem)
>
> add_executable(bundletest main.cpp)
>
> target_include_directories(bundletest PRIVATE ${ZLIB_INCLUDE_DIRS}
> ${Boost_INCLUDE_DIRS})
>
> target_link_libraries(bundletest ${ZLIB_LIBRARIES} ${Boost_LIBRARIES})
>
> install(TARGETS bundletest
>     RUNTIME DESTINATION "bin"
> )
>
> install(CODE "
>     function(gp_resolved_file_type_override resolved_file type_var)
>        set(\${type_var} local PARENT_SCOPE)
>     endfunction()
>     include(BundleUtilities)
>     fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/bin/bundletest\" \"\" \"\")
> " COMPONENT Runtime)
>
> main.cpp:
>
> #include <iostream>
> #include <zlib.h>
> #include <boost/filesystem.hpp>
>
> using namespace boost::filesystem;
>
> int main (int argc, char *argv[]) {
>     // Pretend we're using zlib and Boost
>     deflateInit(0, 0);
>     std::cout << file_size(argv[1]) << std::endl;
>     return 0;
> }
>
> The overriding of the gp_resolved_file_type_override was necessary, to
> make it treat all libraries as local (otherwise it skips "system"
> libraries). See the docs for GetPrerequisites.
>
> Building/installing this with
>
> mkdir build
> cd build
> cmake -DCMAKE_INSTALL_PREFIX=~/bundletest_install ..
> make install
>
> produces:
>
> /home/estan/bundletest_install
> /home/estan/bundletest_install/bin
> /home/estan/bundletest_install/bin/bundletest
> /home/estan/bundletest_install/bin/libm.so.6
> /home/estan/bundletest_install/bin/libstdc++.so.6
> /home/estan/bundletest_install/bin/libc.so.6
> /home/estan/bundletest_install/bin/libz.so.1
> /home/estan/bundletest_install/bin/libpthread.so.0
> /home/estan/bundletest_install/bin/libboost_system.so.1.58.0
> /home/estan/bundletest_install/bin/libgcc_s.so.1
> /home/estan/bundletest_install/bin/libboost_filesystem.so.1.58.0
>
> I did the build on Ubuntu, and tested that it also runs in a clean
> Fedora 24 Docker container.
>
> Hope that helps some.
>
> Elvis
>
> [1] https://cmake.org/cmake/help/v3.9/command/file.html
>
>>
>> Please, could you give me a hint?
>>
>> Regards
>> Roman
>>
>>> Am 19.07.2017 um 12:40 schrieb Elvis Stansvik <[hidden email]>:
>>>
>>> 2017-07-19 10:24 GMT+02:00 Roman Wüger <[hidden email]>:
>>>> Hello,
>>>>
>>>> I have a project which depends on a self compiled 3rd party project (boost)
>>>> Boost is here only an example, there are other 3rd party libraries too.
>>>>
>>>> If I call the "install" command on the target, then it would be packaged.
>>>> But how could I add the shared libraries and especially the links for the shared libraries?
>>>>
>>>> E.g.:
>>>> libboost_filesystem.so -> libboost_filesystem.so.1.48.0
>>>> libboost_filesystem.so.1.48.0
>>>>
>>>> Thanks in advance
>>>
>>> I think fixup_bundle() from BundleUtilities is what you want [1].
>>>
>>> We're using it to make our Windows and macOS installs standalone, but
>>> (I think) it should work on Linux as well.
>>>
>>> [1] https://cmake.org/cmake/help/v3.8/module/BundleUtilities.html
>>>
>>>>
>>>> Best Regards
>>>> Roman
>>>> --
>>>>
>>>> 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
>>
> --
>
> 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
--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack install 3rd party shared libraries

Elvis Stansvik
2017-07-19 16:42 GMT+02:00 David Cole <[hidden email]>:
> Very nice example. Does CMake have a place to put examples like VTK
> does...? If so, where is it? And if not, it would be super useful to
> start one somewhere "official."

I guess the wiki is for that? Though I think my example should be
cleaned up before being put up anywhere.

>
> However, one word of caution on the example. I know it was targeted at
> Linux, and perhaps for a very simple case it's proper, but using an
> unconditional "local" for everything in a
> gp_resolved_file_type_override would not be something you'd want to do
> in general, especially on Windows. You would end up with probably on
> the order of a hundred (or maybe nowadays even a few hundred) DLLs
> from the Windows system directories inside your bundle. Almost
> certainly not what you intended.

Yes, good point and I should have said something about that. My
example was quick and dirty.

In my real projects, I've so far always ended up with separate calls
to fixup_bundle for the different platforms anyway (though never used
fixup_bundle on Linux before), so I guess my mind was thinking "oh
well, this is just for Linux" when I wrote it.

Elvis

>
>
> Cheers,
> David C.
>
>
>
> On Wed, Jul 19, 2017 at 9:57 AM, Elvis Stansvik
> <[hidden email]> wrote:
>> 2017-07-19 13:42 GMT+02:00 Roman Wüger <[hidden email]>:
>>> The problem with BundleUtilities which Inder is that it doesn't support generator expressions.
>>>
>>> Maybe I do something wrong?
>>> But I need to specify the path to the executable (generator expression) and the paths where to look for dependencies. Right?
>>
>> You don't need to use a generator to fetch the executable path. You
>> will know the path, since you installed the executable with
>> install(..) :) I think most people essentially hardcode the executable
>> path in their call to fixup_bundle(..).
>>
>> If you really want to, I think there is a way to use generator
>> expressions, and that is to put the fixup_bundle(..) call in a
>> separate file (say InstallStuff.cmake.in), and then process that file
>> with file(GENERATE OUTPUT ...) [1] to produce InstallStuff.cmake with
>> generator expressions evaluated and then use install(SCRIPT
>> InstallStuff.cmake). But that's much too complicated IMHO, and I would
>> avoid it.
>>
>> I made a minimal example that links against zlib and also the Boost
>> library you mentioned:
>>
>> cmake_minimum_required(VERSION 2.8)
>>
>> project(bundletest)
>>
>> find_package(ZLIB REQUIRED)
>> find_package(Boost REQUIRED COMPONENTS filesystem)
>>
>> add_executable(bundletest main.cpp)
>>
>> target_include_directories(bundletest PRIVATE ${ZLIB_INCLUDE_DIRS}
>> ${Boost_INCLUDE_DIRS})
>>
>> target_link_libraries(bundletest ${ZLIB_LIBRARIES} ${Boost_LIBRARIES})
>>
>> install(TARGETS bundletest
>>     RUNTIME DESTINATION "bin"
>> )
>>
>> install(CODE "
>>     function(gp_resolved_file_type_override resolved_file type_var)
>>        set(\${type_var} local PARENT_SCOPE)
>>     endfunction()
>>     include(BundleUtilities)
>>     fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/bin/bundletest\" \"\" \"\")
>> " COMPONENT Runtime)
>>
>> main.cpp:
>>
>> #include <iostream>
>> #include <zlib.h>
>> #include <boost/filesystem.hpp>
>>
>> using namespace boost::filesystem;
>>
>> int main (int argc, char *argv[]) {
>>     // Pretend we're using zlib and Boost
>>     deflateInit(0, 0);
>>     std::cout << file_size(argv[1]) << std::endl;
>>     return 0;
>> }
>>
>> The overriding of the gp_resolved_file_type_override was necessary, to
>> make it treat all libraries as local (otherwise it skips "system"
>> libraries). See the docs for GetPrerequisites.
>>
>> Building/installing this with
>>
>> mkdir build
>> cd build
>> cmake -DCMAKE_INSTALL_PREFIX=~/bundletest_install ..
>> make install
>>
>> produces:
>>
>> /home/estan/bundletest_install
>> /home/estan/bundletest_install/bin
>> /home/estan/bundletest_install/bin/bundletest
>> /home/estan/bundletest_install/bin/libm.so.6
>> /home/estan/bundletest_install/bin/libstdc++.so.6
>> /home/estan/bundletest_install/bin/libc.so.6
>> /home/estan/bundletest_install/bin/libz.so.1
>> /home/estan/bundletest_install/bin/libpthread.so.0
>> /home/estan/bundletest_install/bin/libboost_system.so.1.58.0
>> /home/estan/bundletest_install/bin/libgcc_s.so.1
>> /home/estan/bundletest_install/bin/libboost_filesystem.so.1.58.0
>>
>> I did the build on Ubuntu, and tested that it also runs in a clean
>> Fedora 24 Docker container.
>>
>> Hope that helps some.
>>
>> Elvis
>>
>> [1] https://cmake.org/cmake/help/v3.9/command/file.html
>>
>>>
>>> Please, could you give me a hint?
>>>
>>> Regards
>>> Roman
>>>
>>>> Am 19.07.2017 um 12:40 schrieb Elvis Stansvik <[hidden email]>:
>>>>
>>>> 2017-07-19 10:24 GMT+02:00 Roman Wüger <[hidden email]>:
>>>>> Hello,
>>>>>
>>>>> I have a project which depends on a self compiled 3rd party project (boost)
>>>>> Boost is here only an example, there are other 3rd party libraries too.
>>>>>
>>>>> If I call the "install" command on the target, then it would be packaged.
>>>>> But how could I add the shared libraries and especially the links for the shared libraries?
>>>>>
>>>>> E.g.:
>>>>> libboost_filesystem.so -> libboost_filesystem.so.1.48.0
>>>>> libboost_filesystem.so.1.48.0
>>>>>
>>>>> Thanks in advance
>>>>
>>>> I think fixup_bundle() from BundleUtilities is what you want [1].
>>>>
>>>> We're using it to make our Windows and macOS installs standalone, but
>>>> (I think) it should work on Linux as well.
>>>>
>>>> [1] https://cmake.org/cmake/help/v3.8/module/BundleUtilities.html
>>>>
>>>>>
>>>>> Best Regards
>>>>> Roman
>>>>> --
>>>>>
>>>>> 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
>>>
>> --
>>
>> 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
--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack install 3rd party shared libraries

Roman Wüger
Thank you Elvis for the awesome example.

Best Regards
Roman

-----Ursprüngliche Nachricht-----
Von: Elvis Stansvik [mailto:[hidden email]]
Gesendet: Mittwoch, 19. Juli 2017 16:51
An: David Cole <[hidden email]>
Cc: Roman Wüger <[hidden email]>; CMake MailingList <[hidden email]>
Betreff: Re: [CMake] CPack install 3rd party shared libraries

2017-07-19 16:42 GMT+02:00 David Cole <[hidden email]>:
> Very nice example. Does CMake have a place to put examples like VTK
> does...? If so, where is it? And if not, it would be super useful to
> start one somewhere "official."

I guess the wiki is for that? Though I think my example should be cleaned up before being put up anywhere.

>
> However, one word of caution on the example. I know it was targeted at
> Linux, and perhaps for a very simple case it's proper, but using an
> unconditional "local" for everything in a
> gp_resolved_file_type_override would not be something you'd want to do
> in general, especially on Windows. You would end up with probably on
> the order of a hundred (or maybe nowadays even a few hundred) DLLs
> from the Windows system directories inside your bundle. Almost
> certainly not what you intended.

Yes, good point and I should have said something about that. My example was quick and dirty.

In my real projects, I've so far always ended up with separate calls to fixup_bundle for the different platforms anyway (though never used fixup_bundle on Linux before), so I guess my mind was thinking "oh well, this is just for Linux" when I wrote it.

Elvis

>
>
> Cheers,
> David C.
>
>
>
> On Wed, Jul 19, 2017 at 9:57 AM, Elvis Stansvik
> <[hidden email]> wrote:
>> 2017-07-19 13:42 GMT+02:00 Roman Wüger <[hidden email]>:
>>> The problem with BundleUtilities which Inder is that it doesn't support generator expressions.
>>>
>>> Maybe I do something wrong?
>>> But I need to specify the path to the executable (generator expression) and the paths where to look for dependencies. Right?
>>
>> You don't need to use a generator to fetch the executable path. You
>> will know the path, since you installed the executable with
>> install(..) :) I think most people essentially hardcode the
>> executable path in their call to fixup_bundle(..).
>>
>> If you really want to, I think there is a way to use generator
>> expressions, and that is to put the fixup_bundle(..) call in a
>> separate file (say InstallStuff.cmake.in), and then process that file
>> with file(GENERATE OUTPUT ...) [1] to produce InstallStuff.cmake with
>> generator expressions evaluated and then use install(SCRIPT
>> InstallStuff.cmake). But that's much too complicated IMHO, and I
>> would avoid it.
>>
>> I made a minimal example that links against zlib and also the Boost
>> library you mentioned:
>>
>> cmake_minimum_required(VERSION 2.8)
>>
>> project(bundletest)
>>
>> find_package(ZLIB REQUIRED)
>> find_package(Boost REQUIRED COMPONENTS filesystem)
>>
>> add_executable(bundletest main.cpp)
>>
>> target_include_directories(bundletest PRIVATE ${ZLIB_INCLUDE_DIRS}
>> ${Boost_INCLUDE_DIRS})
>>
>> target_link_libraries(bundletest ${ZLIB_LIBRARIES}
>> ${Boost_LIBRARIES})
>>
>> install(TARGETS bundletest
>>     RUNTIME DESTINATION "bin"
>> )
>>
>> install(CODE "
>>     function(gp_resolved_file_type_override resolved_file type_var)
>>        set(\${type_var} local PARENT_SCOPE)
>>     endfunction()
>>     include(BundleUtilities)
>>     fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/bin/bundletest\" \"\"
>> \"\") " COMPONENT Runtime)
>>
>> main.cpp:
>>
>> #include <iostream>
>> #include <zlib.h>
>> #include <boost/filesystem.hpp>
>>
>> using namespace boost::filesystem;
>>
>> int main (int argc, char *argv[]) {
>>     // Pretend we're using zlib and Boost
>>     deflateInit(0, 0);
>>     std::cout << file_size(argv[1]) << std::endl;
>>     return 0;
>> }
>>
>> The overriding of the gp_resolved_file_type_override was necessary,
>> to make it treat all libraries as local (otherwise it skips "system"
>> libraries). See the docs for GetPrerequisites.
>>
>> Building/installing this with
>>
>> mkdir build
>> cd build
>> cmake -DCMAKE_INSTALL_PREFIX=~/bundletest_install ..
>> make install
>>
>> produces:
>>
>> /home/estan/bundletest_install
>> /home/estan/bundletest_install/bin
>> /home/estan/bundletest_install/bin/bundletest
>> /home/estan/bundletest_install/bin/libm.so.6
>> /home/estan/bundletest_install/bin/libstdc++.so.6
>> /home/estan/bundletest_install/bin/libc.so.6
>> /home/estan/bundletest_install/bin/libz.so.1
>> /home/estan/bundletest_install/bin/libpthread.so.0
>> /home/estan/bundletest_install/bin/libboost_system.so.1.58.0
>> /home/estan/bundletest_install/bin/libgcc_s.so.1
>> /home/estan/bundletest_install/bin/libboost_filesystem.so.1.58.0
>>
>> I did the build on Ubuntu, and tested that it also runs in a clean
>> Fedora 24 Docker container.
>>
>> Hope that helps some.
>>
>> Elvis
>>
>> [1] https://cmake.org/cmake/help/v3.9/command/file.html
>>
>>>
>>> Please, could you give me a hint?
>>>
>>> Regards
>>> Roman
>>>
>>>> Am 19.07.2017 um 12:40 schrieb Elvis Stansvik <[hidden email]>:
>>>>
>>>> 2017-07-19 10:24 GMT+02:00 Roman Wüger <[hidden email]>:
>>>>> Hello,
>>>>>
>>>>> I have a project which depends on a self compiled 3rd party
>>>>> project (boost) Boost is here only an example, there are other 3rd party libraries too.
>>>>>
>>>>> If I call the "install" command on the target, then it would be packaged.
>>>>> But how could I add the shared libraries and especially the links for the shared libraries?
>>>>>
>>>>> E.g.:
>>>>> libboost_filesystem.so -> libboost_filesystem.so.1.48.0
>>>>> libboost_filesystem.so.1.48.0
>>>>>
>>>>> Thanks in advance
>>>>
>>>> I think fixup_bundle() from BundleUtilities is what you want [1].
>>>>
>>>> We're using it to make our Windows and macOS installs standalone,
>>>> but (I think) it should work on Linux as well.
>>>>
>>>> [1] https://cmake.org/cmake/help/v3.8/module/BundleUtilities.html
>>>>
>>>>>
>>>>> Best Regards
>>>>> Roman
>>>>> --
>>>>>
>>>>> 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
>>>
>> --
>>
>> 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

--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack install 3rd party shared libraries

Elvis Stansvik
(Adding the mailing list back to the list of recepients - It's always
good to keep the discussion on the list)

2017-07-19 19:30 GMT+02:00 Roman Wüger <[hidden email]>:
> Hello Elvis,
>
> I tried you solution, but I get always the message:
>
> CMake Error at /opt/cmake-3.8.2-Linux-x86_64/share/cmake-3.8/Modules/BundleUtilities.cmake:956 (message):
>   error: fixup_bundle: not a valid bundle

It would help to see your full CMake code.

Was there no warning printed before this error? Something like
"warning: *NOT* handled - " followed by an explanation?

Elvis

>
> Regards
> Roman
>
> -----Ursprüngliche Nachricht-----
> Von: CMake [mailto:[hidden email]] Im Auftrag von Roman Wüger
> Gesendet: Mittwoch, 19. Juli 2017 19:14
> An: 'Elvis Stansvik' <[hidden email]>
> Cc: 'CMake MailingList' <[hidden email]>
> Betreff: Re: [CMake] CPack install 3rd party shared libraries
>
> Thank you Elvis for the awesome example.
>
> Best Regards
> Roman
>
> -----Ursprüngliche Nachricht-----
> Von: Elvis Stansvik [mailto:[hidden email]]
> Gesendet: Mittwoch, 19. Juli 2017 16:51
> An: David Cole <[hidden email]>
> Cc: Roman Wüger <[hidden email]>; CMake MailingList <[hidden email]>
> Betreff: Re: [CMake] CPack install 3rd party shared libraries
>
> 2017-07-19 16:42 GMT+02:00 David Cole <[hidden email]>:
>> Very nice example. Does CMake have a place to put examples like VTK
>> does...? If so, where is it? And if not, it would be super useful to
>> start one somewhere "official."
>
> I guess the wiki is for that? Though I think my example should be cleaned up before being put up anywhere.
>
>>
>> However, one word of caution on the example. I know it was targeted at
>> Linux, and perhaps for a very simple case it's proper, but using an
>> unconditional "local" for everything in a
>> gp_resolved_file_type_override would not be something you'd want to do
>> in general, especially on Windows. You would end up with probably on
>> the order of a hundred (or maybe nowadays even a few hundred) DLLs
>> from the Windows system directories inside your bundle. Almost
>> certainly not what you intended.
>
> Yes, good point and I should have said something about that. My example was quick and dirty.
>
> In my real projects, I've so far always ended up with separate calls to fixup_bundle for the different platforms anyway (though never used fixup_bundle on Linux before), so I guess my mind was thinking "oh well, this is just for Linux" when I wrote it.
>
> Elvis
>
>>
>>
>> Cheers,
>> David C.
>>
>>
>>
>> On Wed, Jul 19, 2017 at 9:57 AM, Elvis Stansvik
>> <[hidden email]> wrote:
>>> 2017-07-19 13:42 GMT+02:00 Roman Wüger <[hidden email]>:
>>>> The problem with BundleUtilities which Inder is that it doesn't support generator expressions.
>>>>
>>>> Maybe I do something wrong?
>>>> But I need to specify the path to the executable (generator expression) and the paths where to look for dependencies. Right?
>>>
>>> You don't need to use a generator to fetch the executable path. You
>>> will know the path, since you installed the executable with
>>> install(..) :) I think most people essentially hardcode the
>>> executable path in their call to fixup_bundle(..).
>>>
>>> If you really want to, I think there is a way to use generator
>>> expressions, and that is to put the fixup_bundle(..) call in a
>>> separate file (say InstallStuff.cmake.in), and then process that file
>>> with file(GENERATE OUTPUT ...) [1] to produce InstallStuff.cmake with
>>> generator expressions evaluated and then use install(SCRIPT
>>> InstallStuff.cmake). But that's much too complicated IMHO, and I
>>> would avoid it.
>>>
>>> I made a minimal example that links against zlib and also the Boost
>>> library you mentioned:
>>>
>>> cmake_minimum_required(VERSION 2.8)
>>>
>>> project(bundletest)
>>>
>>> find_package(ZLIB REQUIRED)
>>> find_package(Boost REQUIRED COMPONENTS filesystem)
>>>
>>> add_executable(bundletest main.cpp)
>>>
>>> target_include_directories(bundletest PRIVATE ${ZLIB_INCLUDE_DIRS}
>>> ${Boost_INCLUDE_DIRS})
>>>
>>> target_link_libraries(bundletest ${ZLIB_LIBRARIES}
>>> ${Boost_LIBRARIES})
>>>
>>> install(TARGETS bundletest
>>>     RUNTIME DESTINATION "bin"
>>> )
>>>
>>> install(CODE "
>>>     function(gp_resolved_file_type_override resolved_file type_var)
>>>        set(\${type_var} local PARENT_SCOPE)
>>>     endfunction()
>>>     include(BundleUtilities)
>>>     fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/bin/bundletest\" \"\"
>>> \"\") " COMPONENT Runtime)
>>>
>>> main.cpp:
>>>
>>> #include <iostream>
>>> #include <zlib.h>
>>> #include <boost/filesystem.hpp>
>>>
>>> using namespace boost::filesystem;
>>>
>>> int main (int argc, char *argv[]) {
>>>     // Pretend we're using zlib and Boost
>>>     deflateInit(0, 0);
>>>     std::cout << file_size(argv[1]) << std::endl;
>>>     return 0;
>>> }
>>>
>>> The overriding of the gp_resolved_file_type_override was necessary,
>>> to make it treat all libraries as local (otherwise it skips "system"
>>> libraries). See the docs for GetPrerequisites.
>>>
>>> Building/installing this with
>>>
>>> mkdir build
>>> cd build
>>> cmake -DCMAKE_INSTALL_PREFIX=~/bundletest_install ..
>>> make install
>>>
>>> produces:
>>>
>>> /home/estan/bundletest_install
>>> /home/estan/bundletest_install/bin
>>> /home/estan/bundletest_install/bin/bundletest
>>> /home/estan/bundletest_install/bin/libm.so.6
>>> /home/estan/bundletest_install/bin/libstdc++.so.6
>>> /home/estan/bundletest_install/bin/libc.so.6
>>> /home/estan/bundletest_install/bin/libz.so.1
>>> /home/estan/bundletest_install/bin/libpthread.so.0
>>> /home/estan/bundletest_install/bin/libboost_system.so.1.58.0
>>> /home/estan/bundletest_install/bin/libgcc_s.so.1
>>> /home/estan/bundletest_install/bin/libboost_filesystem.so.1.58.0
>>>
>>> I did the build on Ubuntu, and tested that it also runs in a clean
>>> Fedora 24 Docker container.
>>>
>>> Hope that helps some.
>>>
>>> Elvis
>>>
>>> [1] https://cmake.org/cmake/help/v3.9/command/file.html
>>>
>>>>
>>>> Please, could you give me a hint?
>>>>
>>>> Regards
>>>> Roman
>>>>
>>>>> Am 19.07.2017 um 12:40 schrieb Elvis Stansvik <[hidden email]>:
>>>>>
>>>>> 2017-07-19 10:24 GMT+02:00 Roman Wüger <[hidden email]>:
>>>>>> Hello,
>>>>>>
>>>>>> I have a project which depends on a self compiled 3rd party
>>>>>> project (boost) Boost is here only an example, there are other 3rd party libraries too.
>>>>>>
>>>>>> If I call the "install" command on the target, then it would be packaged.
>>>>>> But how could I add the shared libraries and especially the links for the shared libraries?
>>>>>>
>>>>>> E.g.:
>>>>>> libboost_filesystem.so -> libboost_filesystem.so.1.48.0
>>>>>> libboost_filesystem.so.1.48.0
>>>>>>
>>>>>> Thanks in advance
>>>>>
>>>>> I think fixup_bundle() from BundleUtilities is what you want [1].
>>>>>
>>>>> We're using it to make our Windows and macOS installs standalone,
>>>>> but (I think) it should work on Linux as well.
>>>>>
>>>>> [1] https://cmake.org/cmake/help/v3.8/module/BundleUtilities.html
>>>>>
>>>>>>
>>>>>> Best Regards
>>>>>> Roman
>>>>>> --
>>>>>>
>>>>>> 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
>>>>
>>> --
>>>
>>> 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
>
> --
>
> 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
>
--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack install 3rd party shared libraries

Roman Wüger

Sorry for the MailingList thing, it was a reply mistake.

 

So, here is the complete output:

 

CPack: Enable Verbose

CPack Verbose: Read CPack config file:

CPack Verbose: Read CPack configuration file: /home/rowu/MyPackage/CPackConfig.cmake

CPack Verbose: Specified generator: DEB

CPack Verbose: Use generator: cmCPackDebGenerator

CPack Verbose: For project: MyPackage

CPack: Create package using DEB

CPack Verbose: Read description file: /opt/cmake-3.8.2-Linux-x86_64/share/cmake-3.8/Templates/CPack.GenericDescription.txt

CPack Verbose: [DEB] requested component grouping = ONE_PER_GROUP

CPack Verbose: Remove toplevel directory: /home/rowu/MyPackage/_CPack_Packages/Linux/DEB

CPack: Install projects

CPack: - Run preinstall target for: MyPackage

CPack: - Install project: MyPackage

CPack Verbose: Install configuration: "Release"

CPack Verbose: Installing: /home/rowu/MyPackage/_CPack_Packages/Linux/DEB/MyPackage-0.0.0.1499458629/opt/MyPackage-0.0.0.1499458629/./testprog

CPack Verbose: Set runtime path of "/home/rowu/MyPackage/_CPack_Packages/Linux/DEB/MyPackage-0.0.0.1499458629/opt/MyPackage-0.0.0.1499458629/bin/testprog" to ""

CPack Verbose: Installing: /home/rowu/MyPackage/_CPack_Packages/Linux/DEB/MyPackage-0.0.0.1499458629/opt/MyPackage-0.0.0.1499458629/./file1.dat

CPack Verbose: Installing: /home/rowu/MyPackage/_CPack_Packages/Linux/DEB/MyPackage-0.0.0.1499458629/opt/MyPackage-0.0.0.1499458629/./file2.dat

CPack Verbose: fixup_bundle

CPack Verbose:   app='/opt/MyPackage-0.0.0.1499458629/bin/testprog'

CPack Verbose:   libs=''

CPack Verbose:   dirs='/usr/local/lib'

CPack Verbose:   ignoreItems=''

CPack Verbose: warning: *NOT* handled - directory/file does not exist...

CMake Error at /opt/cmake-3.8.2-Linux-x86_64/share/cmake-3.8/Modules/BundleUtilities.cmake:956 (message):

  error: fixup_bundle: not a valid bundle

Call Stack (most recent call first):

  /home/rowu/MyPackage/app/testprog/cmake_install.cmake:68 (fixup_bundle)

  /home/rowu/MyPackage/app/cmake_install.cmake:37 (include)

  /home/rowu/MyPackage/cmake_install.cmake:37 (include)

 

CPack Verbose: fixup_bundle: done

CPack Error: Error when generating package: MyPackage

 

 

Regards

Roman

 

-----Ursprüngliche Nachricht-----
Von: Elvis Stansvik [mailto:[hidden email]]
Gesendet: Mittwoch, 19. Juli 2017 20:07
An: Roman Wüger <[hidden email]>; CMake MailingList <[hidden email]>
Betreff: Re: [CMake] CPack install 3rd party shared libraries

 

(Adding the mailing list back to the list of recepients - It's always good to keep the discussion on the list)

 

2017-07-19 19:30 GMT+02:00 Roman Wüger <[hidden email]>:

> Hello Elvis,

> 

> I tried you solution, but I get always the message:

> 

> CMake Error at /opt/cmake-3.8.2-Linux-x86_64/share/cmake-3.8/Modules/BundleUtilities.cmake:956 (message):

>   error: fixup_bundle: not a valid bundle

 

It would help to see your full CMake code.

 

Was there no warning printed before this error? Something like

"warning: *NOT* handled - " followed by an explanation?

 

Elvis

 

> 

> Regards

> Roman

> 

> -----Ursprüngliche Nachricht-----

> Von: CMake [[hidden email]] Im Auftrag von Roman Wüger

> Gesendet: Mittwoch, 19. Juli 2017 19:14

> An: 'Elvis Stansvik' <[hidden email]>

> Cc: 'CMake MailingList' <[hidden email]>

> Betreff: Re: [CMake] CPack install 3rd party shared libraries

> 

> Thank you Elvis for the awesome example.

> 

> Best Regards

> Roman

> 

> -----Ursprüngliche Nachricht-----

> Von: Elvis Stansvik [[hidden email]]

> Gesendet: Mittwoch, 19. Juli 2017 16:51

> An: David Cole <[hidden email]>

> Cc: Roman Wüger <[hidden email]>; CMake MailingList

> <[hidden email]>

> Betreff: Re: [CMake] CPack install 3rd party shared libraries

> 

> 2017-07-19 16:42 GMT+02:00 David Cole <[hidden email]>:

>> Very nice example. Does CMake have a place to put examples like VTK

>> does...? If so, where is it? And if not, it would be super useful to

>> start one somewhere "official."

> 

> I guess the wiki is for that? Though I think my example should be cleaned up before being put up anywhere.

> 

>> 

>> However, one word of caution on the example. I know it was targeted

>> at Linux, and perhaps for a very simple case it's proper, but using

>> an unconditional "local" for everything in a

>> gp_resolved_file_type_override would not be something you'd want to

>> do in general, especially on Windows. You would end up with probably

>> on the order of a hundred (or maybe nowadays even a few hundred) DLLs

>> from the Windows system directories inside your bundle. Almost

>> certainly not what you intended.

> 

> Yes, good point and I should have said something about that. My example was quick and dirty.

> 

> In my real projects, I've so far always ended up with separate calls to fixup_bundle for the different platforms anyway (though never used fixup_bundle on Linux before), so I guess my mind was thinking "oh well, this is just for Linux" when I wrote it.

> 

> Elvis

> 

>> 

>> 

>> Cheers,

>> David C.

>> 

>> 

>> 

>> On Wed, Jul 19, 2017 at 9:57 AM, Elvis Stansvik

>> <[hidden email]> wrote:

>>> 2017-07-19 13:42 GMT+02:00 Roman Wüger <[hidden email]>:

>>>> The problem with BundleUtilities which Inder is that it doesn't support generator expressions.

>>>> 

>>>> Maybe I do something wrong?

>>>> But I need to specify the path to the executable (generator expression) and the paths where to look for dependencies. Right?

>>> 

>>> You don't need to use a generator to fetch the executable path. You

>>> will know the path, since you installed the executable with

>>> install(..) :) I think most people essentially hardcode the

>>> executable path in their call to fixup_bundle(..).

>>> 

>>> If you really want to, I think there is a way to use generator

>>> expressions, and that is to put the fixup_bundle(..) call in a

>>> separate file (say InstallStuff.cmake.in), and then process that

>>> file with file(GENERATE OUTPUT ...) [1] to produce

>>> InstallStuff.cmake with generator expressions evaluated and then use

>>> install(SCRIPT InstallStuff.cmake). But that's much too complicated

>>> IMHO, and I would avoid it.

>>> 

>>> I made a minimal example that links against zlib and also the Boost

>>> library you mentioned:

>>> 

>>> cmake_minimum_required(VERSION 2.8)

>>> 

>>> project(bundletest)

>>> 

>>> find_package(ZLIB REQUIRED)

>>> find_package(Boost REQUIRED COMPONENTS filesystem)

>>> 

>>> add_executable(bundletest main.cpp)

>>> 

>>> target_include_directories(bundletest PRIVATE ${ZLIB_INCLUDE_DIRS}

>>> ${Boost_INCLUDE_DIRS})

>>> 

>>> target_link_libraries(bundletest ${ZLIB_LIBRARIES}

>>> ${Boost_LIBRARIES})

>>> 

>>> install(TARGETS bundletest

>>>     RUNTIME DESTINATION "bin"

>>> )

>>> 

>>> install(CODE "

>>>     function(gp_resolved_file_type_override resolved_file type_var)

>>>        set(\${type_var} local PARENT_SCOPE)

>>>     endfunction()

>>>     include(BundleUtilities)

>>>     fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/bin/bundletest\" \"\"

>>> \"\") " COMPONENT Runtime)

>>> 

>>> main.cpp:

>>> 

>>> #include <iostream>

>>> #include <zlib.h>

>>> #include <boost/filesystem.hpp>

>>> 

>>> using namespace boost::filesystem;

>>> 

>>> int main (int argc, char *argv[]) {

>>>     // Pretend we're using zlib and Boost

>>>     deflateInit(0, 0);

>>>     std::cout << file_size(argv[1]) << std::endl;

>>>     return 0;

>>> }

>>> 

>>> The overriding of the gp_resolved_file_type_override was necessary,

>>> to make it treat all libraries as local (otherwise it skips "system"

>>> libraries). See the docs for GetPrerequisites.

>>> 

>>> Building/installing this with

>>> 

>>> mkdir build

>>> cd build

>>> cmake -DCMAKE_INSTALL_PREFIX=~/bundletest_install ..

>>> make install

>>> 

>>> produces:

>>> 

>>> /home/estan/bundletest_install

>>> /home/estan/bundletest_install/bin

>>> /home/estan/bundletest_install/bin/bundletest

>>> /home/estan/bundletest_install/bin/libm.so.6

>>> /home/estan/bundletest_install/bin/libstdc++.so.6

>>> /home/estan/bundletest_install/bin/libc.so.6

>>> /home/estan/bundletest_install/bin/libz.so.1

>>> /home/estan/bundletest_install/bin/libpthread.so.0

>>> /home/estan/bundletest_install/bin/libboost_system.so.1.58.0

>>> /home/estan/bundletest_install/bin/libgcc_s.so.1

>>> /home/estan/bundletest_install/bin/libboost_filesystem.so.1.58.0

>>> 

>>> I did the build on Ubuntu, and tested that it also runs in a clean

>>> Fedora 24 Docker container.

>>> 

>>> Hope that helps some.

>>> 

>>> Elvis

>>> 

>>> [1] https://cmake.org/cmake/help/v3.9/command/file.html

>>> 

>>>> 

>>>> Please, could you give me a hint?

>>>> 

>>>> Regards

>>>> Roman

>>>> 

>>>>> Am 19.07.2017 um 12:40 schrieb Elvis Stansvik <[hidden email]>:

>>>>> 

>>>>> 2017-07-19 10:24 GMT+02:00 Roman Wüger <[hidden email]>:

>>>>>> Hello,

>>>>>> 

>>>>>> I have a project which depends on a self compiled 3rd party

>>>>>> project (boost) Boost is here only an example, there are other 3rd party libraries too.

>>>>>> 

>>>>>> If I call the "install" command on the target, then it would be packaged.

>>>>>> But how could I add the shared libraries and especially the links for the shared libraries?

>>>>>> 

>>>>>> E.g.:

>>>>>> libboost_filesystem.so -> libboost_filesystem.so.1.48.0

>>>>>> libboost_filesystem.so.1.48.0

>>>>>> 

>>>>>> Thanks in advance

>>>>> 

>>>>> I think fixup_bundle() from BundleUtilities is what you want [1].

>>>>> 

>>>>> We're using it to make our Windows and macOS installs standalone,

>>>>> but (I think) it should work on Linux as well.

>>>>> 

>>>>> [1] https://cmake.org/cmake/help/v3.8/module/BundleUtilities.html

>>>>> 

>>>>>> 

>>>>>> Best Regards

>>>>>> Roman

>>>>>> --

>>>>>> 

>>>>>> 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

>>>> 

>>> --

>>> 

>>> 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

> 

> --

> 

> 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

> 


--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack install 3rd party shared libraries

Elvis Stansvik
2017-07-19 20:56 GMT+02:00 Roman Wüger <[hidden email]>:

> Sorry for the MailingList thing, it was a reply mistake.
>
>
>
> So, here is the complete output:
>
>
>
> CPack: Enable Verbose
>
> CPack Verbose: Read CPack config file:
>
> CPack Verbose: Read CPack configuration file:
> /home/rowu/MyPackage/CPackConfig.cmake
>
> CPack Verbose: Specified generator: DEB
>
> CPack Verbose: Use generator: cmCPackDebGenerator
>
> CPack Verbose: For project: MyPackage
>
> CPack: Create package using DEB
>
> CPack Verbose: Read description file:
> /opt/cmake-3.8.2-Linux-x86_64/share/cmake-3.8/Templates/CPack.GenericDescription.txt
>
> CPack Verbose: [DEB] requested component grouping = ONE_PER_GROUP
>
> CPack Verbose: Remove toplevel directory:
> /home/rowu/MyPackage/_CPack_Packages/Linux/DEB
>
> CPack: Install projects
>
> CPack: - Run preinstall target for: MyPackage
>
> CPack: - Install project: MyPackage
>
> CPack Verbose: Install configuration: "Release"
>
> CPack Verbose: Installing:
> /home/rowu/MyPackage/_CPack_Packages/Linux/DEB/MyPackage-0.0.0.1499458629/opt/MyPackage-0.0.0.1499458629/./testprog
>
> CPack Verbose: Set runtime path of
> "/home/rowu/MyPackage/_CPack_Packages/Linux/DEB/MyPackage-0.0.0.1499458629/opt/MyPackage-0.0.0.1499458629/bin/testprog"
> to ""

This is probably unrelated, but: These two paths look strange to me.
One of them suggests you're installing the executable directly to
${CMAKE_INSTALL_PREFIX}, while the other suggests there's a
${CMAKE_INSTALL_PREFIX}/bin path involved as well.

Anyway, see below.

>
> CPack Verbose: Installing:
> /home/rowu/MyPackage/_CPack_Packages/Linux/DEB/MyPackage-0.0.0.1499458629/opt/MyPackage-0.0.0.1499458629/./file1.dat
>
> CPack Verbose: Installing:
> /home/rowu/MyPackage/_CPack_Packages/Linux/DEB/MyPackage-0.0.0.1499458629/opt/MyPackage-0.0.0.1499458629/./file2.dat
>
> CPack Verbose: fixup_bundle
>
> CPack Verbose:   app='/opt/MyPackage-0.0.0.1499458629/bin/testprog'
>
> CPack Verbose:   libs=''
>
> CPack Verbose:   dirs='/usr/local/lib'
>
> CPack Verbose:   ignoreItems=''
>
> CPack Verbose: warning: *NOT* handled - directory/file does not exist...

This means the executable path you passed in as the first argument to
fixup_bundle(..) doesn't exist, and is why you get the error below.

It would help to see your full CMake code (any CMakeLists.txt involved).

Elvis

>
> CMake Error at
> /opt/cmake-3.8.2-Linux-x86_64/share/cmake-3.8/Modules/BundleUtilities.cmake:956
> (message):
>
>   error: fixup_bundle: not a valid bundle
>
> Call Stack (most recent call first):
>
>   /home/rowu/MyPackage/app/testprog/cmake_install.cmake:68 (fixup_bundle)
>
>   /home/rowu/MyPackage/app/cmake_install.cmake:37 (include)
>
>   /home/rowu/MyPackage/cmake_install.cmake:37 (include)
>
>
>
> CPack Verbose: fixup_bundle: done
>
> CPack Error: Error when generating package: MyPackage
>
>
>
>
>
> Regards
>
> Roman
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Elvis Stansvik [mailto:[hidden email]]
> Gesendet: Mittwoch, 19. Juli 2017 20:07
> An: Roman Wüger <[hidden email]>; CMake MailingList <[hidden email]>
>
>
> Betreff: Re: [CMake] CPack install 3rd party shared libraries
>
>
>
> (Adding the mailing list back to the list of recepients - It's always good
> to keep the discussion on the list)
>
>
>
> 2017-07-19 19:30 GMT+02:00 Roman Wüger <[hidden email]>:
>
>> Hello Elvis,
>
>>
>
>> I tried you solution, but I get always the message:
>
>>
>
>> CMake Error at
>> /opt/cmake-3.8.2-Linux-x86_64/share/cmake-3.8/Modules/BundleUtilities.cmake:956
>> (message):
>
>>   error: fixup_bundle: not a valid bundle
>
>
>
> It would help to see your full CMake code.
>
>
>
> Was there no warning printed before this error? Something like
>
> "warning: *NOT* handled - " followed by an explanation?
>
>
>
> Elvis
>
>
>
>>
>
>> Regards
>
>> Roman
>
>>
>
>> -----Ursprüngliche Nachricht-----
>
>> Von: CMake [mailto:[hidden email]] Im Auftrag von Roman Wüger
>
>> Gesendet: Mittwoch, 19. Juli 2017 19:14
>
>> An: 'Elvis Stansvik' <[hidden email]>
>
>> Cc: 'CMake MailingList' <[hidden email]>
>
>> Betreff: Re: [CMake] CPack install 3rd party shared libraries
>
>>
>
>> Thank you Elvis for the awesome example.
>
>>
>
>> Best Regards
>
>> Roman
>
>>
>
>> -----Ursprüngliche Nachricht-----
>
>> Von: Elvis Stansvik [mailto:[hidden email]]
>
>> Gesendet: Mittwoch, 19. Juli 2017 16:51
>
>> An: David Cole <[hidden email]>
>
>> Cc: Roman Wüger <[hidden email]>; CMake MailingList
>
>> <[hidden email]>
>
>> Betreff: Re: [CMake] CPack install 3rd party shared libraries
>
>>
>
>> 2017-07-19 16:42 GMT+02:00 David Cole <[hidden email]>:
>
>>> Very nice example. Does CMake have a place to put examples like VTK
>
>>> does...? If so, where is it? And if not, it would be super useful to
>
>>> start one somewhere "official."
>
>>
>
>> I guess the wiki is for that? Though I think my example should be cleaned
>> up before being put up anywhere.
>
>>
>
>>>
>
>>> However, one word of caution on the example. I know it was targeted
>
>>> at Linux, and perhaps for a very simple case it's proper, but using
>
>>> an unconditional "local" for everything in a
>
>>> gp_resolved_file_type_override would not be something you'd want to
>
>>> do in general, especially on Windows. You would end up with probably
>
>>> on the order of a hundred (or maybe nowadays even a few hundred) DLLs
>
>>> from the Windows system directories inside your bundle. Almost
>
>>> certainly not what you intended.
>
>>
>
>> Yes, good point and I should have said something about that. My example
>> was quick and dirty.
>
>>
>
>> In my real projects, I've so far always ended up with separate calls to
>> fixup_bundle for the different platforms anyway (though never used
>> fixup_bundle on Linux before), so I guess my mind was thinking "oh well,
>> this is just for Linux" when I wrote it.
>
>>
>
>> Elvis
>
>>
>
>>>
>
>>>
>
>>> Cheers,
>
>>> David C.
>
>>>
>
>>>
>
>>>
>
>>> On Wed, Jul 19, 2017 at 9:57 AM, Elvis Stansvik
>
>>> <[hidden email]> wrote:
>
>>>> 2017-07-19 13:42 GMT+02:00 Roman Wüger <[hidden email]>:
>
>>>>> The problem with BundleUtilities which Inder is that it doesn't support
>>>>> generator expressions.
>
>>>>>
>
>>>>> Maybe I do something wrong?
>
>>>>> But I need to specify the path to the executable (generator expression)
>>>>> and the paths where to look for dependencies. Right?
>
>>>>
>
>>>> You don't need to use a generator to fetch the executable path. You
>
>>>> will know the path, since you installed the executable with
>
>>>> install(..) :) I think most people essentially hardcode the
>
>>>> executable path in their call to fixup_bundle(..).
>
>>>>
>
>>>> If you really want to, I think there is a way to use generator
>
>>>> expressions, and that is to put the fixup_bundle(..) call in a
>
>>>> separate file (say InstallStuff.cmake.in), and then process that
>
>>>> file with file(GENERATE OUTPUT ...) [1] to produce
>
>>>> InstallStuff.cmake with generator expressions evaluated and then use
>
>>>> install(SCRIPT InstallStuff.cmake). But that's much too complicated
>
>>>> IMHO, and I would avoid it.
>
>>>>
>
>>>> I made a minimal example that links against zlib and also the Boost
>
>>>> library you mentioned:
>
>>>>
>
>>>> cmake_minimum_required(VERSION 2.8)
>
>>>>
>
>>>> project(bundletest)
>
>>>>
>
>>>> find_package(ZLIB REQUIRED)
>
>>>> find_package(Boost REQUIRED COMPONENTS filesystem)
>
>>>>
>
>>>> add_executable(bundletest main.cpp)
>
>>>>
>
>>>> target_include_directories(bundletest PRIVATE ${ZLIB_INCLUDE_DIRS}
>
>>>> ${Boost_INCLUDE_DIRS})
>
>>>>
>
>>>> target_link_libraries(bundletest ${ZLIB_LIBRARIES}
>
>>>> ${Boost_LIBRARIES})
>
>>>>
>
>>>> install(TARGETS bundletest
>
>>>>     RUNTIME DESTINATION "bin"
>
>>>> )
>
>>>>
>
>>>> install(CODE "
>
>>>>     function(gp_resolved_file_type_override resolved_file type_var)
>
>>>>        set(\${type_var} local PARENT_SCOPE)
>
>>>>     endfunction()
>
>>>>     include(BundleUtilities)
>
>>>>     fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/bin/bundletest\" \"\"
>
>>>> \"\") " COMPONENT Runtime)
>
>>>>
>
>>>> main.cpp:
>
>>>>
>
>>>> #include <iostream>
>
>>>> #include <zlib.h>
>
>>>> #include <boost/filesystem.hpp>
>
>>>>
>
>>>> using namespace boost::filesystem;
>
>>>>
>
>>>> int main (int argc, char *argv[]) {
>
>>>>     // Pretend we're using zlib and Boost
>
>>>>     deflateInit(0, 0);
>
>>>>     std::cout << file_size(argv[1]) << std::endl;
>
>>>>     return 0;
>
>>>> }
>
>>>>
>
>>>> The overriding of the gp_resolved_file_type_override was necessary,
>
>>>> to make it treat all libraries as local (otherwise it skips "system"
>
>>>> libraries). See the docs for GetPrerequisites.
>
>>>>
>
>>>> Building/installing this with
>
>>>>
>
>>>> mkdir build
>
>>>> cd build
>
>>>> cmake -DCMAKE_INSTALL_PREFIX=~/bundletest_install ..
>
>>>> make install
>
>>>>
>
>>>> produces:
>
>>>>
>
>>>> /home/estan/bundletest_install
>
>>>> /home/estan/bundletest_install/bin
>
>>>> /home/estan/bundletest_install/bin/bundletest
>
>>>> /home/estan/bundletest_install/bin/libm.so.6
>
>>>> /home/estan/bundletest_install/bin/libstdc++.so.6
>
>>>> /home/estan/bundletest_install/bin/libc.so.6
>
>>>> /home/estan/bundletest_install/bin/libz.so.1
>
>>>> /home/estan/bundletest_install/bin/libpthread.so.0
>
>>>> /home/estan/bundletest_install/bin/libboost_system.so.1.58.0
>
>>>> /home/estan/bundletest_install/bin/libgcc_s.so.1
>
>>>> /home/estan/bundletest_install/bin/libboost_filesystem.so.1.58.0
>
>>>>
>
>>>> I did the build on Ubuntu, and tested that it also runs in a clean
>
>>>> Fedora 24 Docker container.
>
>>>>
>
>>>> Hope that helps some.
>
>>>>
>
>>>> Elvis
>
>>>>
>
>>>> [1] https://cmake.org/cmake/help/v3.9/command/file.html
>
>>>>
>
>>>>>
>
>>>>> Please, could you give me a hint?
>
>>>>>
>
>>>>> Regards
>
>>>>> Roman
>
>>>>>
>
>>>>>> Am 19.07.2017 um 12:40 schrieb Elvis Stansvik
>>>>>> <[hidden email]>:
>
>>>>>>
>
>>>>>> 2017-07-19 10:24 GMT+02:00 Roman Wüger <[hidden email]>:
>
>>>>>>> Hello,
>
>>>>>>>
>
>>>>>>> I have a project which depends on a self compiled 3rd party
>
>>>>>>> project (boost) Boost is here only an example, there are other 3rd
>>>>>>> party libraries too.
>
>>>>>>>
>
>>>>>>> If I call the "install" command on the target, then it would be
>>>>>>> packaged.
>
>>>>>>> But how could I add the shared libraries and especially the links for
>>>>>>> the shared libraries?
>
>>>>>>>
>
>>>>>>> E.g.:
>
>>>>>>> libboost_filesystem.so -> libboost_filesystem.so.1.48.0
>
>>>>>>> libboost_filesystem.so.1.48.0
>
>>>>>>>
>
>>>>>>> Thanks in advance
>
>>>>>>
>
>>>>>> I think fixup_bundle() from BundleUtilities is what you want [1].
>
>>>>>>
>
>>>>>> We're using it to make our Windows and macOS installs standalone,
>
>>>>>> but (I think) it should work on Linux as well.
>
>>>>>>
>
>>>>>> [1] https://cmake.org/cmake/help/v3.8/module/BundleUtilities.html
>
>>>>>>
>
>>>>>>>
>
>>>>>>> Best Regards
>
>>>>>>> Roman
>
>>>>>>> --
>
>>>>>>>
>
>>>>>>> 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
>
>>>>>
>
>>>> --
>
>>>>
>
>>>> 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
>
>>
>
>> --
>
>>
>
>> 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
>
>>
--

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
Loading...