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/macros.cmake.

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

Specfile Usage

%build
%cmake .
%make_build


%install
%make_install

%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. For example, 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: