File: paraview-config.cxx.in

package info (click to toggle)
paraview 5.4.1%2Bdfsg4-3.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 218,616 kB
  • sloc: cpp: 2,331,508; ansic: 322,365; python: 111,051; xml: 79,203; tcl: 47,013; yacc: 4,877; java: 4,438; perl: 3,238; sh: 2,920; lex: 1,908; f90: 748; makefile: 273; pascal: 228; objc: 83; fortran: 31
file content (171 lines) | stat: -rw-r--r-- 5,217 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*=========================================================================

Program:   ParaView
Module:    paraview-config.cxx

Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.

This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "vtkModules.h"
#include "vtkPVConfig.h" // Required to get build options for paraview

#include <vtksys/SystemTools.hxx>

#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#include <cstdlib>

#define die(X)                   \
  do                             \
    {                            \
    std::cerr << X << std::endl; \
    return EXIT_FAILURE;         \
    } while (false)

int main(int argc, char* argv[])
{
  const char* flagUsage = "[--libs [--python] <target...>|--include|--list|--python-lib]";

  if (argc < 2)
    {
    die("Usage: " << argv[0] << " " << flagUsage);
    }

  typedef std::string vtkModuleName;
  typedef std::vector<vtkModuleName> vtkModuleNames;
  typedef std::map<vtkModuleName, vtkModuleNames> vtkModuleDependencyMap;
  typedef std::set<vtkModuleName> vtkPythonModules;
  vtkModuleDependencyMap moduleMapping;
  vtkModuleDependencyMap moduleLibraries;
  vtkPythonModules modulesWithPython;
  for (const vtkModuleDependency* module = vtkModules; module->ModuleName; ++module)
    {
    vtkModuleNames& depends = moduleMapping[module->ModuleName];
    for (const char** depend = module->Depends; *depend; ++depend)
      {
      depends.push_back(*depend);
      }
    vtkModuleNames& libraries = moduleLibraries[module->ModuleName];
    for (const char** library = module->LibraryNames; *library; ++library)
      {
      libraries.push_back(*library);
      }
    if (module->Python)
      {
      modulesWithPython.insert(module->ModuleName);
      }
    }

  const std::string flag = argv[1];
  if (flag == "--libs")
    {
    if (argc < 3)
      {
      die("Error: `--libs` requires at least one module name");
      }

    const std::string libflag = argv[2];
    const bool usePython = (libflag == "--python");

    std::set<vtkModuleName> includedModules;
    vtkModuleNames neededModules;
    for (int arg = 2 + usePython; arg < argc; ++arg)
      {
      const std::string target = argv[arg];

      const vtkModuleDependencyMap::const_iterator i = moduleMapping.find(target);
      if (i == moduleMapping.end())
        {
        die("Error: No such module: " << target);
        }

      neededModules.push_back(target);
      includedModules.insert(target);
      }

    size_t idx = 0;
    while (idx < neededModules.size())
      {
      const vtkModuleNames& depends = moduleMapping[neededModules[idx]];
      for (vtkModuleNames::const_iterator i = depends.begin(); i != depends.end(); ++i)
        {
        const vtkModuleName& dependency = *i;
        if (!includedModules.count(dependency))
          {
          neededModules.push_back(dependency);
          includedModules.insert(dependency);
          }
        }
      ++idx;
      }

#ifdef BUILD_SHARED_LIBS
    std::cout << " -L@CMAKE_INSTALL_PREFIX@/@VTK_INSTALL_LIBRARY_DIR@";
#else
    std::cout << " -L@CMAKE_INSTALL_PREFIX@/@VTK_INSTALL_ARCHIVE_DIR@";
#endif
    std::set<vtkModuleName> librariesLinked;
    for (vtkModuleNames::const_iterator i = neededModules.begin(); i != neededModules.end(); ++i)
      {
      const vtkModuleName& module = *i;
      if (usePython && modulesWithPython.count(module))
        {
        std::cout << " -l" << module << "Python@PYTHON_VERSION_MAJOR@@PYTHON_VERSION_MINOR@D-pv" PARAVIEW_VERSION;
        }
      const vtkModuleNames& libraries = moduleLibraries[module];
      for (vtkModuleNames::const_iterator j = libraries.begin(); j != libraries.end(); ++j)
        {
        if (!librariesLinked.count(*j))
          {
          if (vtksys::SystemTools::FileIsFullPath(j->c_str()))
            {
            std::string libraryName = vtksys::SystemTools::GetFilenameWithoutLastExtension(*j);
            if (libraryName.substr(0, 3) == "lib")
              {
              libraryName = libraryName.substr(3);
              }
            std::cout << " -L" << vtksys::SystemTools::GetFilenamePath(*j)
                      << " -l" << libraryName;
            }
          else
            {
            std::cout << " -l" << *j;
            }
          librariesLinked.insert(*j);
          }
        }
      }
      std::cout << std::endl;
    }
  else if (flag == "--include")
    {
    std::cout << " -I@CMAKE_INSTALL_PREFIX@/@VTK_INSTALL_INCLUDE_DIR@" << std::endl;
    }
  else if (flag == "--list")
    {
    for (vtkModuleDependencyMap::const_iterator i = moduleMapping.begin(); i != moduleMapping.end(); ++i)
      {
      std::cout << i->first << std::endl;
      }
    }
  else if (flag == "--python-lib")
    {
    std::cout << " -l@PYTHON_LIBRARY@" << std::endl;
    }
  else
    {
    die("Usage: " << argv[0] << " " << flagUsage);
    }

  return EXIT_SUCCESS;
}