public static File getCMakeExecutable()

in cmake-runner-agent/src/jetbrains/buildServer/cmakerunner/agent/util/CMakeUtil.java [82:110]


  public static File getCMakeExecutable(@NotNull final BuildAgentConfiguration agentConf) {
    File cmakeFile = null;
    final Map<String, String> buildParams = agentConf.getConfigurationParameters();
    final String cmakeCommandStr = buildParams.get(CMakeConfigureConstants.UI_CMAKE_COMMAND);
    if (cmakeCommandStr != null) {
      final File workDirectory = agentConf.getWorkDirectory();
      final File pathFile = new File(cmakeCommandStr);
      if (pathFile.isAbsolute()) {
        cmakeFile = pathFile;
      } else {
        final String rel = FileUtil.normalizeRelativePath(cmakeCommandStr);
        if (rel.startsWith("..")) {
          String a = cmakeCommandStr.substring(2);
          while (a.startsWith("\\")) a = a.substring(1);
          while (a.startsWith("/")) a = a.substring(1);
          cmakeFile = new File(workDirectory, a);
        } else {
          // Do not check (cmake may be in repository)
        }
      }
    } else {
      final String path = FileUtil2.findExecutableByNameInPATH(CMakeConfigureBuildService.DEFAULT_CMAKE_PROGRAM, agentConf.getBuildParameters().getEnvironmentVariables());
      if (path == null) {
        return null;
      }
      cmakeFile = new File(path);
    }
    return cmakeFile;
  }