[CMake] ExternalProject + PREFIX + CPACK - cannot get the good path

Alfred Sawaya alfred at huji.fr
Mon Jul 17 16:54:06 EDT 2017


Hello folks,

I am trying to create a package with CPack from an External Project using
the autotools. The make install part try to copy files to /usr/local/lib,
but I do not want to package as root, so it fails. The cpack works because
(I think) it create a temp dir and set it as environment variable before
issuing the make install. But if I do a "make package", then it fails with
permissions denied.

I am not the first to get stuck with this issue (
https://stackoverflow.com/questions/44724281/cpack-building-external-autogen-project-with-bad-output-location
)
So I do not think that there is a direct solution ? Anyway, I can implement
one and send the patch.

I see only one solution to this issue: actually set a prefix on the
external project and implement a boolean variable
CPACK_IGNORE_INSTALL_PREFIX to remove it into the package. I tihnk it is
the most consistent way to resolve this ?
Do you have other ideas before I start implementing it ?

Thank you all,
Alfred

The CMakeLists.txt: (usable as is) <<<EOF

project(sqlcipher)

cmake_minimum_required (VERSION 2.8)

include(ExternalProject)

ExternalProject_Add(
    sqlcipher
    GIT_REPOSITORY https://github.com/sqlcipher/sqlcipher.git
    BUILD_IN_SOURCE true
    CONFIGURE_COMMAND ./configure --enable-tempstore=yes
"CFLAGS=-DSQLITE_HAS_CODEC"
)


set(CPACK_DEBIAN_PACKAGE_PROVIDES libsqlcipher0 libsqlcipher-dev sqlcipher)
set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})

SET(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_NAME "my-sqlcipher")
SET(CPACK_PACKAGE_VERSION "3.15")

SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "me")
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Install the last version of
sqlcipher")

SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all")
SET(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
INCLUDE(CPack)

EOF

make package  # fails if not root
cpack # succes if not root

-- 
Cordialement,
Alfred Sawaya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170717/3d737d77/attachment.html>


More information about the CMake mailing list