[cmake-developers] trouble with running cpack --help during cmake step

Eric Noulard eric.noulard at gmail.com
Tue Jun 26 17:56:02 EDT 2012


2012/6/26 Bill Hoffman <bill.hoffman at kitware.com>:
> So, this code here:
>
> 2a34b579 Tests/CMakeLists.txt  (Eric NOULARD                  2012-03-30
> 17:07:06 +0200  720)     # Analyze 'cpack --help' output for list of
> available generators:
> 2a34b579 Tests/CMakeLists.txt  (Eric NOULARD                  2012-03-30
> 17:07:06 +0200  721)     execute_process(COMMAND ${CMAKE_CPACK_COMMAND}
> --help
>
>
> The trouble is the cpack that is being tested is the one from the build
> tree.  If you have a very old CMake build tree, and you do a git pull and
> gets lots of new cmake code.  Then when you re-run cmake on the build tree,
> the cpack --help might crash.   I am not sure how this works on a fresh
> build tree either as cpack won't even exist.

You are right this kind of tests may not be safely done at CMake time.
I did that in order to avoid to replicate the code inside CPack factory
(have a look at cmCPackDebGenerator::CanGenerate()
 and  cmCPackRPMGenerator::CanGenerate())
which checks whether if a generator may be instantiated or not.
This was done for conditionnally enabling RPM or DEB generator on MacOS
see http://public.kitware.com/Bug/view.php?id=13064

This is was mistake to do that in Tests/CMakeLists.txt.
This should be harmless since it will probably "only" prevent RPM and DEB
CPack tests to be run (ACTIVE_CPACK_GENERATORS will be empty)
but this is a mistake.

I shall implement proper CMake-time check in Tests/CMakeLists.txt.
Unfortunately I may not be able to do that until sunday 1rst of July...

Is this blocking 2.8.9 ?

I'll try tomorrow night but I cannot ensure I'll have time to do it.

Basically this would be something like:
set(ACTIVE_CPACK_GENERATORS)
then
find_program(RPMBUILD_EXECUTABLE NAMES rpmbuild)
if (RPMBUILD_EXECUTABLE)
   list(APPEND ACTIVE_CPACK_GENERATORS "RPM")
endif()

find_program(DPKG_EXECUTABLE NAMES dpkg)
if (DPKG_EXECUTABLE)
   list(APPEND ACTIVE_CPACK_GENERATORS "DEB")
endif()


-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org



More information about the cmake-developers mailing list