2011/3/17 Dixon, Shane <[email protected]>:
> I want to add some messages at the end of cmake that display all the
> DEB-related variables and what they’re set to.  I’d prefer to now shows
> these when building on windows where DEB isn’t available.  Is there
> something like
>
>
>
>   If(DEBIAN_FOUND)

This is not currently possible because
[un]fortunately CMake is not aware of CPack generator existence :-]

> that I can use to determine if the deb package builder will be used?  Should
> I scan CPACK_GENERATORS for ‘DEB”?

You cannot scan that either, because this var is set to a default value by CMake
and it may be overwritten by the user.

> What’s the best way to do this?

You can try the attached cmake script which launch "cpack --help" and collect
available generators from CPack itself, if it is found then

CPACK_<GEN>_FOUND is set to true.

try
include(AvailableCPackGenerators.cmake)

then
if (CPACK_DEB_FOUND)
or
if (CPACK_TGZ_FOUND)

etc...
should.

If you find the feature is worth to be included in CMake mainstream
file a feature request and attach the file (or a modified version if
you can do it in a better way).

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
find_program(CPACK_PROGRAM NAMES cpack)
if (CPACK_PROGRAM)
  # Analyze 'cpack --help' output for list of available generators:
  #
  execute_process(COMMAND ${CPACK_PROGRAM} --help
    RESULT_VARIABLE result
    OUTPUT_VARIABLE stdout
    ERROR_VARIABLE stderr)
  
  string(REPLACE ";" "\\;" stdout "${stdout}")
  string(REPLACE "\n" "E;" stdout "${stdout}")
  
  set(collecting 0)
  set(generators)
  foreach(eline ${stdout})
    string(REGEX REPLACE "^(.*)E$" "\\1" line "${eline}")
    if(collecting AND NOT line STREQUAL "")
      string(REGEX REPLACE "^  ([^ ]+) += (.*)$" "\\1" gen "${line}")
      string(REGEX REPLACE "^  ([^ ]+) += (.*)$" "\\2" doc "${line}")
      list(APPEND generators ${gen})
    endif()
    if(line STREQUAL "Generators")
      set(collecting 1)
    endif()
  endforeach()  
  set(possiblegen "DEB;NSIS;RPM;STGZ;TBZ2;TGZ;TZ;ZIP;DMG;CygwinBinary;CygwinSource;DragNDrop;Bundle;PackageMaker;OSXX11")
  foreach(gen ${possiblegen})
    list(FIND generators "${gen}" IDX)
    if(IDX EQUAL "-1")
      set(CPACK_${gen}_FOUND FALSE)
    else()
      set(CPACK_${gen}_FOUND TRUE)
    endif()
  endforeach()
endif(CPACK_PROGRAM)
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to