[CMake] how to debug CPack creation

Eric Noulard eric.noulard at gmail.com
Tue Oct 23 02:55:55 EDT 2018


Le mar. 23 oct. 2018 à 08:07, Илья Шипицин <chipitsine at gmail.com> a écrit :

> Eric, thank you for your review.
> I still wonder why is it so complicated (my expectation was "ok, since I
> use both cmake and cpack, they should work together")
>

The main reason is that CPack was first design as a standalone tool that
can be used without CMake.
I guess that some project may still be using that way.
CMake has a "simple" way to generate CPackConfig.cmake file that drives the
CPack run but you can generate those files
by other mean and still be using CPack, without CMake.



> can you please review
> https://github.com/SoftEtherVPN/SoftEtherVPN/commit/139fffe6e0c218f580cd8a397d94856be37fa947
> (it is based on your suggestions)
>

I made comment on this commit, basically don't generate *any* file in
source tree it's a [relatively] bad habit.
If a file is an artefact of the build then it belongs to build tree.

As a matter of fact you CI build tree seems to <source_tree>/tmp (from your
configure script) but if ever this is changing it'll break the build
use CMAKE_BINARY_DIR.

I think it should work now but your CI will show you if it's ok.

Now concerning your CMAKE_INSTALL_PREFIX if your CI is producing ready to
use .deb / .rpm etc... package then
you'd better use "/opt" as a prefix as suggested by Craig.




> сб, 20 окт. 2018 г. в 17:59, Eric Noulard <eric.noulard at gmail.com>:
>
>>
>>
>> Le sam. 20 oct. 2018 à 10:54, Илья Шипицин <chipitsine at gmail.com> a
>> écrit :
>>
>>>
>>>
>>> сб, 20 окт. 2018 г. в 13:30, Eric Noulard <eric.noulard at gmail.com>:
>>>
>>>>
>>>>
>>>> Le sam. 20 oct. 2018 à 10:15, Илья Шипицин <chipitsine at gmail.com> a
>>>> écrit :
>>>>
>>>>> hi,
>>>>>
>>>>> we use cmake/cpack for mangling systemd scripts
>>>>>
>>>>>
>>>>> https://github.com/SoftEtherVPN/SoftEtherVPN/blob/master/src/vpnserver/CMakeLists.txt#L26
>>>>>
>>>>> what happens:
>>>>>
>>>>> (*) deb installs files to /usr/libexec
>>>>> (*) cmake sets location as /usr/local/libexec
>>>>>
>>>>
>>>> It looks like your get default "/usr/local" prefix from somewhere.
>>>>
>>>
>>> exactly.
>>>
>>
>> So I I understand it well (correct me if I'm wrong) when you do:
>>
>> 1) make install
>>     You get all installed files prefixed by /usr/local
>>     which is the expected behaviour unless you configure
>> CMAKE_INSTALL_PREFIX
>>     or you use
>>     DESTDIR=/your/prefix make install
>>
>> 2) deb created by CPack get "/usr" prefix instead
>>    which is the expected behaviour unless you specify an alternate value
>> using
>>    CPACK_PACKAGING_INSTALL_PREFIX
>>
>>     go to your build tree and try:
>>     cpack -G DEB -D  CPACK_PACKAGING_INSTALL_PREFIX=/opt
>>
>>     and you'll see that the .deb will have /opt prefix.
>>
>> The question is what do expect as a prefix?
>> /usr/local
>> /usr
>> something else ??
>>
>> The rules are the following when using install rule.
>> 1) if your DESTINATION is a relative path then it will be prefix with
>>    CMAKE_INSTALL_PREFIX when doing make install
>>    CPACK_PACKAGING_INSTALL_PREFIX when building package with CPack
>>
>> 2) if your DESTINATION is "absolute" like /etc/whatever/confdir
>>     It'll get install there when doing make install (whatever the value
>> of  CMAKE_INSTALL_PREFIX)
>>
>>     With CPack, it depends on the generator.
>>    Some generators (like DEB a,nd RPM) try to catch "absolute" install
>> file and handle them
>>    as config file. RPM generator is more verbose about it see below.
>>
>> Is the RPM containing what you expect?
>>>>
>>>
>>> I did not check it yet.
>>>
>>
>> I tried using:
>> $  cpack -G RPM
>>
>> and you get expected warning about the mix of absolute and relative
>> install path:
>> CPack: Create package using RPM
>> CPack: Install projects
>> CPack: - Install project: SoftEtherVPN
>> CPack: -   Install component: vpnserver
>> CPack: -   Install component: vpnclient
>> CPack: -   Install component: vpnbridge
>> CPack: -   Install component: vpncmd
>> CPack: Create package
>> CMake Warning (dev) at
>> /home/enoulard/local/share/cmake-3.12/Modules/Internal/CPack/CPackRPM.cmake:135
>> (message):
>>   CPackRPM:Warning: Path /lib/systemd/system/softether-vpnbridge.service
>> is
>>   not on one of the relocatable paths! Package will be partially
>> relocatable.
>> Call Stack (most recent call first):
>>
>> /home/enoulard/local/share/cmake-3.12/Modules/Internal/CPack/CPackRPM.cmake:1001
>> (cpack_rpm_prepare_relocation_paths)
>>
>> /home/enoulard/local/share/cmake-3.12/Modules/Internal/CPack/CPackRPM.cmake:1870
>> (cpack_rpm_generate_package)
>> This warning is for project developers.  Use -Wno-dev to suppress it.
>>
>> [...]
>>
>> CPack: - package: []/build/softether-vpnbridge-5.1.9660-1.x86_64.rpm
>> generated.
>> CPack: - package: []/build/softether-vpnclient-5.1.9660-1.x86_64.rpm
>> generated.
>> CPack: - package: []/build/softether-vpncmd-5.1.9660-1.x86_64.rpm
>> generated.
>> CPack: - package: []/build/softether-vpnserver-5.1.9660-1.x86_64.rpm
>> generated.
>>
>> And the content is:
>> $ rpm -qpl softether-vpnserver-5.1.9660-1.x86_64.rpm
>> /lib
>> /lib/systemd
>> /lib/systemd/system
>> /lib/systemd/system/softether-vpnserver.service
>> /usr/libexec
>> /usr/libexec/softether
>> /usr/libexec/softether/vpnserver
>> /usr/libexec/softether/vpnserver/hamcore.se2
>> /usr/libexec/softether/vpnserver/vpnserver
>> /usr/local
>> /usr/local/bin
>> /usr/local/bin/vpnserver
>>
>> the content of the .deb is similar:
>> $ dpkg-deb -c softether-vpnserver_5.1.9660_amd64.deb
>> drwxr-xr-x root/root         0 2018-10-20 14:45 ./lib/
>> drwxr-xr-x root/root         0 2018-10-20 14:45 ./lib/systemd/
>> drwxr-xr-x root/root         0 2018-10-20 14:45 ./lib/systemd/system/
>> -rw-r--r-- root/root       700 2018-10-20 14:45
>> ./lib/systemd/system/softether-vpnserver.service
>> drwxr-xr-x root/root         0 2018-10-20 14:45 ./usr/
>> drwxr-xr-x root/root         0 2018-10-20 14:45 ./usr/libexec/
>> drwxr-xr-x root/root         0 2018-10-20 14:45 ./usr/libexec/softether/
>> drwxr-xr-x root/root         0 2018-10-20 14:45
>> ./usr/libexec/softether/vpnserver/
>> -rw-r--r-- root/root   1770716 2018-10-20 14:45
>> ./usr/libexec/softether/vpnserver/hamcore.se2
>> -rwxr-xr-x root/root   2088960 2018-10-20 14:45
>> ./usr/libexec/softether/vpnserver/vpnserver
>> drwxr-xr-x root/root         0 2018-10-20 14:45 ./usr/local/
>> drwxr-xr-x root/root         0 2018-10-20 14:45 ./usr/local/bin/
>> -rwxr-xr-x root/root        72 2018-10-20 14:45 ./usr/local/bin/vpnserver
>>
>> The main question is, what filesystem layout do you expect for those
>> files?
>>
>> --
>> Eric
>>
>

-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181023/cf644790/attachment.html>


More information about the CMake mailing list