public static void adjustModuleCMakeLists(File moduleDirName, String fileName, boolean fileWasCreated, IOutput output)
    {
        output.writeLine("    Registering file in module specific CMakeLists");
        File cmakelistsFile = new File(moduleDirName, Constants.CMAKELISTS_FILENAME);
        if (!cmakelistsFile.exists())
        {
            try
            {
                cmakelistsFile.createNewFile();
            }
            catch (IOException e)
            {
                throw new IllegalStateException(e);
            }
        }
        String[] lines = readAllLines(cmakelistsFile);
        Map<String, String> variables = new HashMap<String, String>();
        variables.put("fileName", fileName);
        String addFileCommand = TemplateHandling.getProperty("FileContents.properties", "ADD_FILE_TEMPLATE", variables, moduleDirName);
        if (lineAlreadyExists(lines, addFileCommand))
        {
            // no need to write, but we need to "change" the file so that a rebuild is performed
            if (fileWasCreated)
            {
                cmakelistsFile.setLastModified(System.currentTimeMillis());
            }
            output.writeLine("    No need to adjust CMakeLists, because file entry already exists.");
            return;
        }
        String[] newlines = new String[lines.length + 1];
        for (int i = 0; i < newlines.length; i++)
        {
            newlines[i] = "";
        }
        int index = 0;
        String addModulePrefix = TemplateHandling.getProperty("FileContents.properties", "ADD_MODULE_PREFIX_TEMPLATE", null, moduleDirName);
        boolean found = false;
        for (int i = 0; i < lines.length; i++)
        {
            newlines[index] = lines[i];
            index++;

            // insert right after module definition
            if (lines[i].trim().toLowerCase().contains(addModulePrefix.toLowerCase()))
            {
                // add our entry right after it!
                newlines[index] = addFileCommand;
                index++;
                found = true;
            }
        }

        if (found)
        {
            writeAllLines(cmakelistsFile, newlines);
        }
        else
        {
            output.writeLine("    Could not insert text in the CMakeLists file. It remains unchanged.");
        }
    }