Discussion:
[CMake] Simple CPack example is needed...
Dick Munroe
2008-10-18 21:34:43 UTC
Permalink
I've gotten to the point where I need to build an installer and want to
use CPack. The available documentation is pretty impenetrable and I
can't find any simple examples on the web. I've found a bug in the
CPack.make file shipped with CMake 2.6.2 (in the section of the file
following the comment: Generate source file,
CPACK_INSTALL_CMAKE_PROJECTS is clobbered by
CPACK_SOURCE_INSTALL_CMAKE_PROJECTS which winds up generating the
following error when I try to run make package:

Run CPack packaging tool...
CPack: Create package using PackageMaker
CPack: Install projects
CPack Error: Not enough items on list: CPACK_INSTALL_CMAKE_PROJECTS.
CPACK_INSTALL_CMAKE_PROJECTS should hold quadruplet of install
directory, install project name, install component, and install
subdirectory.
CPack Error: Error when generating package:
make: *** [package] Error 1

So I "fixed" the error by using cpack_set_if_not_set to conditionally
set CPACK_INSTALL_CMAKE_PROJECTS and I get somewhat further, but now I get:

ESPlanner Executables-cmake $ more
_CPack_Packages/Darwin/PackageMaker/PreinstallOutput.log
# Run command: /usr/bin/make "preinstall"
# Directory: bin/ESPlanner
# Output:

So I'm got curious about what the various bits of the
CPACK_INSTALL_CMAKE_PROJECTS are. I've started with:

set(
CPACK_INSTALL_CMAKE_PROJECTS
"bin/ESPlanner;ESPlanner-Web;WEB;/tmp/ESPlanner-install")

which got the error above, so the first argument has to be something
like the root of the build directory. So, I changed the directory to
${CMAKE_HOME_DIRECTORY} and I get kits built, but I still think there is
a bug in CPack.make.

Best,

Dick Munroe
Eric Noulard
2008-10-19 11:42:51 UTC
Permalink
I've gotten to the point where I need to build an installer and want to use
CPack. The available documentation is pretty impenetrable and I can't find
any simple examples on the web. I've found a bug in the CPack.make file
shipped with CMake 2.6.2
I do use CPack/CMake 2.6.2 without trouble for
ZIP
TGZ
RPM
DEB
cpack generator so I think...
Generate source file, CPACK_INSTALL_CMAKE_PROJECTS is clobbered by
CPACK_SOURCE_INSTALL_CMAKE_PROJECTS which winds up generating the following
You may have misunderstood the purpose of those line.
CPack.cmake is generated 2 files:

CPackConfig.cmake for binary package
CPackSourceConfig.cmake for source package

the
SET(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")

is done before generating "CPackSourceConfig.cmake" but
after "CPackConfig.cmake" has been produced.
look for configure_file commands.

[...]
So I'm got curious about what the various bits of the
set(
CPACK_INSTALL_CMAKE_PROJECTS
"bin/ESPlanner;ESPlanner-Web;WEB;/tmp/ESPlanner-install")
which got the error above, so the first argument has to be something like
the root of the build directory. So, I changed the directory to
${CMAKE_HOME_DIRECTORY} and I get kits built, but I still think there is a
bug in CPack.make.
look at:
http://www.cmake.org/Wiki/CMake:CPackConfiguration
Eric Noulard
2008-10-20 19:44:26 UTC
Permalink
And once I keep CPack.make from clobbering CPACK_INSTALL_CMAKE_PROJECTS I
get kits built as well.
project(foo)
...
set(
CPACK_INSTALL_CMAKE_PROJECTS
"${CMAKE_HOME_DIRECTORY};ESPlanner-Web;WEB;/tmp/ESPlanner-install"
)
message("x: ${CPACK_INSTALL_CMAKE_PROJECTS})
include(CPack)
message("x: ${CPACK_INSTALL_CMAKE_PROJECTS})
When you configure your Makefiles (this particular build is for Darwin,
running make) you'll see that after the include, the value for
CPACK_INSTALL_CMAKE_PROJECTS is now null (I'm not building any source
releases) because it's been overwritten by the contents of the
CPACK_SOURCE_INSTALL_CMAKE_PROJECTS variable. After the overwriting of
CPACK_INSTALL_CMAKE_PROJECTS, there is a call to configure_file which is
where I think that the bogus value of CPACK_INSTALL_CMAKE_PROJECTS gets
written, resulting in the error.
When you run the package command for the make file one (or at least I) get
the error described below, in effect, CPack appears to have no data
available from CPACK_INSTALL_CMAKE_PROJECTS set prior to the include of
CPack. If you make the change to CPack.cmake, described below, you get the
correct behavior (or at least you get kits built which is what this is all
about after all). I'm just describing observed behavior with the shipped
2.6.2 product on Darwin (10.5.4+) not stating what other folks do or don't
see. As near as I can tell from the sparse CPack documentation all I should
have to do is set CPACK_INSTALL_CMAKE_PROJECTS, which I do, run make
package, which I do, and get kits, which I don't.
OK Dick,
If I use your example (setting CPACK_INSTALL_CMAKE_PROJECTS before
include CPack)
I'm able reproduce the described behavior, I must admit I did never set
CPACK_INSTALL_CMAKE_PROJECTS myself.

You are right the behavior is weird, but I think it shouldn't lead to an error.

When you set CPACK_INSTALL_CMAKE_PROJECTS before including(CPack)
the value is used for generating the CPackConfig.cmake file (the one
used for BINARY packages)
generated at line CPack.cmake:199

configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}"
@ONLY IMMEDIATE)

[and in fact the generated file CONTAINS the value you set]

Now at line CPack.cmake 209:
SET(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")

the variable is "reset" with the value of
CPACK_SOURCE_INSTALL_CMAKE_PROJECTS (note the SOURCE)
because at lines CPack.cmake 218 configure_file("${cpack_source_input_file}"
219
"${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)

you generate the CPackSourceConfig.cmake (the one used for SOURCE packages)

So YES the variables is reset by INCLUDE(CPack) but this is not a bug,
just a weird feature because
Source package and Binary package CPack config files shares the
"CPACK_INSTALL_CMAKE_PROJECTS".

If you want to specify CPACK_INSTALL_CMAKE_PROJECTS you need to specify BOTH

CPACK_INSTALL_CMAKE_PROJECTS
and
CPACK_SOURCE_INSTALL_CMAKE_PROJECTS
yourself.

However I don't even know what would be the meaning of
"CPACK_SOURCE_INSTALL_CMAKE_PROJECTS"
for a SOURCE package since there is NO INSTALL for a SOURCE package???
I initially tried just including CPack and running make package, but got the
same error (there is no data in CPACK_INSTALL_CMAKE_PROJECTS).
In this case on a Linux + TGZ/ZIP/RPM/DEB CPack package generator
I do not have ANY error when running

make package
or
make package_source (not available for RPM or DEB though)

I would say that this looks like a PackageMaker/OS X specific bug.
May be you should file a bug report
may be affer trying the attached project which works well for me.
--
Erk
Loading...