text: from conans import ConanFile, CMake, tools
  import os
  import textwrap
  
  required_conan_version = ">=1.33.0"
  
  
  class CwalkConan(ConanFile):
      name = "cwalk"
      description = "Path library for C/C++. Cross-Platform for Windows, " \
                    "MacOS and Linux. Supports UNIX and Windows path styles " \
                    "on those platforms."
      url = "https://github.com/conan-io/conan-center-index"
      license = "MIT"
      homepage = "https://likle.github.io/cwalk/"
      topics = ("cwalk", "cross-platform", "windows", "macos", "osx", "linux",
                "path-manipulation", "path", "directory", "file", "file-system",
                "unc", "path-parsing", "file-path")
  
      settings = "os", "arch", "compiler", "build_type"
      options = {"shared": [True, False], "fPIC": [True, False]}
      default_options = {'shared': False, 'fPIC': True}
  
      exports_sources = ["CMakeLists.txt", "patches/**"]
      generators = "cmake"
      _cmake = None
  
      @property
      def _source_subfolder(self):
          return "source_subfolder"
  
      @property
      def _build_subfolder(self):
          return "build_subfolder"
  
      def config_options(self):
          if self.settings.os == "Windows":
              del self.options.fPIC
  
      def configure(self):
          if self.options.shared:
              del self.options.fPIC
          del self.settings.compiler.libcxx
          del self.settings.compiler.cppstd
  
      def source(self):
          tools.get(**self.conan_data["sources"][self.version],
                    destination=self._source_subfolder, strip_root=True)
  
      def _configure_cmake(self):
          if self._cmake:
              return self._cmake
          self._cmake = CMake(self)
          self._cmake.configure(build_folder=self._build_subfolder)
          return self._cmake
  
      def build(self):
          for patch in self.conan_data.get("patches", {}).get(self.version, []):
              tools.patch(**patch)
          cmake = self._configure_cmake()
          cmake.build()
  
      def package(self):
          self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder)
          cmake = self._configure_cmake()
          cmake.install()
          tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
          self._create_cmake_module_alias_targets(
              os.path.join(self.package_folder, self._module_file_rel_path),
              {"cwalk": "cwalk::cwalk"}
          )
  
      @staticmethod
      def _create_cmake_module_alias_targets(module_file, targets):
          content = ""
          for alias, aliased in targets.items():
              content += textwrap.dedent("""\
                  if(TARGET {aliased} AND NOT TARGET {alias})
                      add_library({alias} INTERFACE IMPORTED)
                      set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
                  endif()
              """.format(alias=alias, aliased=aliased))
          tools.save(module_file, content)
  
      @property
      def _module_subfolder(self):
          return os.path.join("lib", "cmake")
  
      @property
      def _module_file_rel_path(self):
          return os.path.join(self._module_subfolder,
                              "conan-official-{}-targets.cmake".format(self.name))
  
      def package_info(self):
          self.cpp_info.filenames["cmake_find_package"] = "Cwalk"
          self.cpp_info.filenames["cmake_find_package_multi"] = "Cwalk"
          self.cpp_info.names["cmake_find_package"] = "cwalk"
          self.cpp_info.names["cmake_find_package_multi"] = "cwalk"
          self.cpp_info.builddirs.append(self._module_subfolder)
          self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path]
          self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
          self.cpp_info.libs = ["cwalk"]
          if self.options.shared and tools.Version(self.version) >= "1.2.5":
              self.cpp_info.defines.append("CWK_SHARED")
  