cmCPackNSISGenerator.h 2.92 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3 4 5
#ifndef cmCPackNSISGenerator_h
#define cmCPackNSISGenerator_h

6
#include "cmConfigure.h"
Daniel Pfeifer's avatar
Daniel Pfeifer committed
7

Bill Hoffman's avatar
Bill Hoffman committed
8
#include "cmCPackGenerator.h"
Brad King's avatar
Brad King committed
9

Daniel Pfeifer's avatar
Daniel Pfeifer committed
10
#include <iosfwd>
11
#include <set>
Daniel Pfeifer's avatar
Daniel Pfeifer committed
12 13 14 15 16
#include <string>
#include <vector>

class cmCPackComponent;
class cmCPackComponentGroup;
17 18 19 20 21 22

/** \class cmCPackNSISGenerator
 * \brief A generator for NSIS files
 *
 * http://people.freebsd.org/~kientzle/libarchive/
 */
Bill Hoffman's avatar
Bill Hoffman committed
23
class cmCPackNSISGenerator : public cmCPackGenerator
24 25
{
public:
Bill Hoffman's avatar
Bill Hoffman committed
26
  cmCPackTypeMacro(cmCPackNSISGenerator, cmCPackGenerator);
27

28
  static cmCPackGenerator* CreateGenerator64()
29 30 31
  {
    return new cmCPackNSISGenerator(true);
  }
32

33 34 35
  /**
   * Construct generator
   */
36
  cmCPackNSISGenerator(bool nsis64 = false);
37
  ~cmCPackNSISGenerator() CM_OVERRIDE;
38 39

protected:
40
  int InitializeInternal() CM_OVERRIDE;
41
  void CreateMenuLinks(std::ostream& str, std::ostream& deleteStr);
42 43 44
  int PackageFiles() CM_OVERRIDE;
  const char* GetOutputExtension() CM_OVERRIDE { return ".exe"; }
  const char* GetOutputPostfix() CM_OVERRIDE { return "win32"; }
45

46
  bool GetListOfSubdirectories(const char* dir,
47
                               std::vector<std::string>& dirs);
48

49 50 51 52
  enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const
    CM_OVERRIDE;
  bool SupportsAbsoluteDestination() const CM_OVERRIDE;
  bool SupportsComponentInstallation() const CM_OVERRIDE;
53

54 55
  /// Produce a string that contains the NSIS code to describe a
  /// particular component. Any added macros will be emitted via
56
  /// macrosOut.
57
  std::string CreateComponentDescription(cmCPackComponent* component,
58
                                         std::ostream& macrosOut);
59 60 61

  /// Produce NSIS code that selects all of the components that this component
  /// depends on, recursively.
62 63
  std::string CreateSelectionDependenciesDescription(
    cmCPackComponent* component, std::set<cmCPackComponent*>& visited);
64

65 66
  /// Produce NSIS code that de-selects all of the components that are
  /// dependent on this component, recursively.
67 68
  std::string CreateDeselectionDependenciesDescription(
    cmCPackComponent* component, std::set<cmCPackComponent*>& visited);
69

70
  /// Produce a string that contains the NSIS code to describe a
71 72
  /// particular component group, including its components. Any
  /// added macros will be emitted via macrosOut.
73
  std::string CreateComponentGroupDescription(cmCPackComponentGroup* group,
74
                                              std::ostream& macrosOut);
75

76 77 78 79 80
  /// Returns the custom install directory if available for the specified
  /// component, otherwise $INSTDIR is returned.
  std::string CustomComponentInstallDirectory(
    const std::string& componentName);

Nicolas Despres's avatar
Nicolas Despres committed
81
  /// Translations any newlines found in the string into \\r\\n, so that the
82 83
  /// resulting string can be used within NSIS.
  static std::string TranslateNewlines(std::string str);
84 85

  bool Nsis64;
86 87 88
};

#endif