#641 Proposal to improve wiki page of cmake packaging
Opened 2 years ago by raphgro. Modified 7 months ago

https://fedoraproject.org/wiki/Packaging:Cmake

  1. The sample could be improved to fully use available macros, e.g. for make. cmake likes to build out of source tree, e.g. in a dedicated build folder or platform specific. ctest can get more verbose in case of failures (-VV).
%build
mkdir build
pushd build
# or: mkdir -p %{_target_platform} ; pushd %{_target_platform}
%cmake ..
popd
%make_build -C build
# or: make %{?_smp_mflags} -C build

%install
%make_install -C build
# or: make install DESTDIR=%{buildroot}

%check
# in case there are tests, build and execute them
pushd build
ctest -VV %{?_smp_mflags}
popd
  1. We saw that some upstream project [¹] to enforce rpath, maybe by accident. The dedicated rpath section [²] does not address how rpath can be dropped in a special cmake logic and packager tends to use the proposed last resort solution with chrpath --delete [³]. It may help to cross-link to cmake specific rpath notes. Please also add an hint about removing misleading INSTALL_RPATH:
%prep
# unpack tarball etc...
# drop rpath, https://fedoraproject.org/wiki/Packaging:Guidelines#Beware_of_Rpath
find . -name CMakeLists.txt |xargs sed -i /INSTALL_RPATH/d
  1. Above general page about cmake packaging should be also linked in application specific section [4] of guidelines.

¹ https://github.com/mhogomchungu/zuluCrypt/blob/77a698e817fd8df7b832171b4dc7131e9f93c85e/zuluCrypt-gui/CMakeLists.txt#L97

² https://fedoraproject.org/wiki/Packaging:Guidelines#Beware_of_Rpath

³ https://fedoraproject.org/wiki/Packaging:Guidelines#Removing_Rpath

4 https://fedoraproject.org/wiki/Packaging:Guidelines#Application_Specific_Guidelines


Ad 1.:

%build
mkdir build
pushd build
# or: mkdir -p %{_target_platform} ; pushd %{_target_platform}
%cmake ..
popd
%make_build -C build
# or: make %{?_smp_mflags} -C build

%install
%make_install -C build
# or: make install DESTDIR=%{buildroot} -C build

%check
# in case there are tests, build and execute them
pushd build
ctest -VV %{?_smp_mflags}
popd ` 

Ad 2.:

%prep
# unpack tarball etc...
# drop rpath, ​https://fedoraproject.org/wiki/Packaging:Guidelines#Beware_of_Rpath
find . -name CMakeLists.txt |xargs sed -i /INSTALL_RPATH/d

find . -name CMakeLists.txt |xargs sed -i /INSTALL_RPATH/d

This is wrong. Not all uses of INSTALL_RPATH are either wrong (e.g., usage in something like if (CMAKE_SKIP_INSTALL_RPATH) would have this create unparseable CMake files) and not all of them are guaranteed to occur in a CMakeLists.txt file (e.g., a function defined in some utility .cmake file that is included). Instead, the wiki currently suggests setting -DCMAKE_SKIP_INSTALL_RPATH=ON which causes CMake to ignore any INSTALL_RPATH property setting on a target.

We discussed this at this weeks meeting (http://meetbot.fedoraproject.org/fedora-meeting-1/2016-08-11/fpc.2016-08-11-16.00.txt):

  • Ticket #641 Proposal to improve wiki page of cmake packaging (geppetto, 16:09:30)
  • ACTION: Need a real draft (geppetto, 16:14:53)
  • ACTION: Out-of-src-tree suggestion won't work for all packages. (geppetto, 16:15:14)
  • ACTION: - rpath sed is rejected (orionp, 16:18:20)

Replying to [comment:4 james]:

  • ACTION: Out-of-src-tree suggestion won't work for all packages.

On Cygwin, we generally build packages in a dedicated build directory, and among my ~700 packages which use cmake, a quick check showed only three which needed to be fixed therefor:

https://github.com/cygwinports/ibus-chewing/blob/master/1.4.2-vpath.patch
https://github.com/cygwinports-extras/cmake-fedora/blob/master/1.0.5-vpath.patch
https://github.com/cygwinports-extras/qxkb/blob/master/0.4.6-vpath.patch

So overall I don't think this should be a major problem.

Metadata Update from @yselkowitz:
- Issue assigned to james

2 years ago

Metadata Update from @tibbs:
- Issue close_status updated to: None
- Issue tagged with: draftneeded

2 years ago

Metadata Update from @ignatenkobrain:
- Issue tagged with: cmake

7 months ago

Login to comment on this ticket.

Metadata