From Fedora Project Wiki

m (Fix bad documentation link.)
(Minor updates)
Line 7: Line 7:
== RPM Macros ==
== RPM Macros ==


If cmake is installed, see /etc/rpm/macros.cmake
If cmake is installed, see /usr/lib/rpm/macros.d/cmake or /etc/rpm/macros.cmake on EL6.


If kde-filesystem is installed, see /etc/rpm/macros.kde4
If kde-filesystem is installed, see /usr/lib/rpm/macros.d/macros.kde4




Line 22: Line 22:


%install
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=%{buildroot}
make install DESTDIR=$RPM_BUILD_ROOT




%check
%check
ctest
ctest -V %{?_smp_mflags}
</pre>
</pre>


{{Anchor|cmakeNotes}}
{{Anchor|cmakeNotes}}
== Notes ==
== Notes ==
'''NOTE''': <code>-DCMAKE_SKIP_RPATH:BOOL=ON</code>.  With recent cmake-2.4, it should not be used. This cmake version should hand RPATHs issues correctly (set them in build-dir, remove them during installation). Setting <code>CMAKE_SKIP_RPATH</code> for this version would avoid RPATHs in build-dir too. This might link binaries against system-libraries (e.g. when a previous version of the package was installed) instead of the libraries which were created by the build.
'''NOTE''': <code>-DCMAKE_SKIP_RPATH:BOOL=ON</code>.  With recent cmake-2.4, it should not be used. This cmake version should handle RPATHs issues correctly (set them in build-dir, remove them during installation). Setting <code>CMAKE_SKIP_RPATH</code> for this version would avoid RPATHs in build-dir too. This might link binaries against system-libraries (e.g. when a previous version of the package was installed) instead of the libraries which were created by the build.


Nevertheless, RPATH issues might arise when cmake was used improperly. E.g. installing a target with <code>INSTALL(FILES ... RENAME ...)</code> will '''not''' strip rpaths; in this case <code>INSTALL(TARGETS ...)</code> must be used in combination with changing the <code>OUTPUT_NAME</code> property.
Nevertheless, RPATH issues might arise when cmake was used improperly. E.g. installing a target with <code>INSTALL(FILES ... RENAME ...)</code> will '''not''' strip rpaths; in this case <code>INSTALL(TARGETS ...)</code> must be used in combination with changing the <code>OUTPUT_NAME</code> property.

Revision as of 17:01, 11 March 2015

Guidelines for cmake

This document provides cmake best-practices for generating Fedora RPMS using cmake


RPM Macros

If cmake is installed, see /usr/lib/rpm/macros.d/cmake or /etc/rpm/macros.cmake on EL6.

If kde-filesystem is installed, see /usr/lib/rpm/macros.d/macros.kde4


Specfile Usage

%build
%cmake .
make %{?_smp_mflags}


%install
make install DESTDIR=%{buildroot}


%check
ctest -V %{?_smp_mflags}

Notes

NOTE: -DCMAKE_SKIP_RPATH:BOOL=ON. With recent cmake-2.4, it should not be used. This cmake version should handle RPATHs issues correctly (set them in build-dir, remove them during installation). Setting CMAKE_SKIP_RPATH for this version would avoid RPATHs in build-dir too. This might link binaries against system-libraries (e.g. when a previous version of the package was installed) instead of the libraries which were created by the build.

Nevertheless, RPATH issues might arise when cmake was used improperly. E.g. installing a target with INSTALL(FILES ... RENAME ...) will not strip rpaths; in this case INSTALL(TARGETS ...) must be used in combination with changing the OUTPUT_NAME property.

NOTE: cmake has good documentation in two places: