class CMakeFile:
    """CMake configuration file."""
    def __init__(self, file_name: str) -> None:
        self._file = open(file_name, "w")
        self._contents = []

    def __del__(self) -> None:
        self._file.close()

    def find_package(self, s: str) -> None:
        """Mimic of CMake 'find_package' command."""
        self._contents.append(f"find_package({s})")

    def include_directories(self, s: str) -> None:
        self._contents.append(f"include_directories({s})")
    
    def add_compile_definitions(self, s: str) -> None:
        self._contents.append(f"add_compile_definitions({s})")

    def add_link_options(self, s: str) -> None:
        self._contents.append(f"add_link_options({s})")

    def link_libraries(self, s: str) -> None:
        self._contents.append(f"link_libraries({s})")

    def add_command(self, s: str) -> None:
        """Add a general command to contents."""
        self._contents.append(s)

    def write_contents(self, clear: bool = True) -> None:
        """Write and clear contents."""
        for s in self._contents:
            self._file.write(f"{s}\n")
        if clear:
            self._contents.clear()

    def write_command(self, s: str) -> None:
        """Write a general command to file."""
        self._file.write(f"{s}\n")
