[CMake] CPack: avoid creating unnecessary man dirs

Robert J. Hansen rjh at sixdemonbag.org
Sat Oct 29 14:39:09 EDT 2016


> Use `|CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION` to add a man's dir
> to 'exclude' list, so RPM package wouldn't have a dir, but files from
> it... so it wouldn't conflict w/ `filesystem` package.

Thank you; that solved one problem and exposed another.

In my old Autotools build, I used preprocessor defines to set at
compile-time where the binary should look for its data files.  In my
top-level CMakeLists.txt I set a CMake variable as:

	set(PKGDATADIR ${CMAKE_INSTALL_FULL_DATADIR}/nsrlsvr)

And in src/CMakeLists.txt I set the preprocessor define:

	add_definitions(-DPKGDATADIR="${PKGDATADIR}")

When I build the RPM and install it, though, something weird happens:

	[rjh at localhost nsrlsvr]$ /usr/bin/nsrlsvr --help
	nsrlsvr options:
	  ... (output omitted) ...
	  -f [ --file ] arg (=/usr/local/share/nsrlsvr/hashes.txt)
	                                        hash file

The default argument for -f is not /usr/share/nsrlsvr/hashes.txt, as it
should be for an RPM, but /usr/local/share/nsrlsvr/hashes.txt, as if it
were a locally-compiled package.

My first thought was that I should replace CMAKE_INSTALL_FULL_DATADIR
with CMAKE_INSTALL_DATADIR, but that was also less than useful:

	nsrlsvr options:
	  ... (output omitted) ...
	  -f [ --file ] arg (=share/nsrlsvr/hashes.txt)
	                                        hash file

How can I fix this?

("Have your code use a relative offset from where the binary is located"
is an acceptable answer; I'm hoping there's a better one, though!)


More information about the CMake mailing list