|
@@ -1,38 +1,56 @@
|
|
-from conans import ConanFile, CMake, tools
|
|
|
|
|
|
+from conans import ConanFile, tools
|
|
|
|
+from conans.errors import ConanInvalidConfiguration
|
|
|
|
+from conans.tools import os_info
|
|
|
|
+import os
|
|
|
|
|
|
|
|
|
|
class ZlibConan(ConanFile):
|
|
class ZlibConan(ConanFile):
|
|
name = "zlib"
|
|
name = "zlib"
|
|
version = "1.2.11"
|
|
version = "1.2.11"
|
|
- license = "<Put the package license here>"
|
|
|
|
- author = "<Put your name here> <And your email here>"
|
|
|
|
- url = "<Package recipe repository url here, for issues about the package>"
|
|
|
|
- description = "<Description of Zlib here>"
|
|
|
|
- topics = ("<Put some tag here>", "<here>", "<and here>")
|
|
|
|
|
|
+ license = "Zlib"
|
|
|
|
+ author = "Shawn Morford <DarkMorford@Gmail.com>"
|
|
|
|
+ url = "https://code.darkmorford.net/conan-pkg/zlib"
|
|
|
|
+ description = "A Massively Spiffy Yet Delicately Unobtrusive Compression Library"
|
|
|
|
+ homepage = "http://zlib.net/"
|
|
|
|
+ topics = ("compression", "utility")
|
|
|
|
+ exports_sources = ["patches/*"]
|
|
settings = "os", "compiler", "build_type", "arch"
|
|
settings = "os", "compiler", "build_type", "arch"
|
|
options = {"shared": [True, False]}
|
|
options = {"shared": [True, False]}
|
|
default_options = {"shared": False}
|
|
default_options = {"shared": False}
|
|
- generators = "cmake"
|
|
|
|
|
|
+
|
|
|
|
+ @property
|
|
|
|
+ def subfolder(self):
|
|
|
|
+ return os.path.join(self.source_folder, f"zlib-{self.version}")
|
|
|
|
+
|
|
|
|
+ def configure(self):
|
|
|
|
+ del self.settings.compiler.cppstd
|
|
|
|
+ del self.settings.compiler.libcxx
|
|
|
|
|
|
def source(self):
|
|
def source(self):
|
|
- self.run("git clone https://github.com/conan-io/hello.git")
|
|
|
|
- # This small hack might be useful to guarantee proper /MT /MD linkage
|
|
|
|
- # in MSVC if the packaged project doesn't have variables to set it
|
|
|
|
- # properly
|
|
|
|
- tools.replace_in_file("hello/CMakeLists.txt", "PROJECT(HelloWorld)",
|
|
|
|
- '''PROJECT(HelloWorld)
|
|
|
|
-include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
|
|
-conan_basic_setup()''')
|
|
|
|
|
|
+ tools.get(**self.conan_data["sources"][self.version])
|
|
|
|
+ for patch in self.conan_data["patches"][self.version]:
|
|
|
|
+ tools.patch(base_path=self.subfolder, **patch)
|
|
|
|
+
|
|
|
|
+ def _build_nmake(self):
|
|
|
|
+ flags = [f"-{self.settings.compiler.runtime}"]
|
|
|
|
+ if self.settings.build_type == "Debug":
|
|
|
|
+ flags.append("-Od")
|
|
|
|
+ else:
|
|
|
|
+ flags.append("-O2")
|
|
|
|
+ with tools.vcvars(self.settings), tools.chdir(self.subfolder):
|
|
|
|
+ makefile = os.path.join("win32", "Makefile.msc")
|
|
|
|
+ flags = " ".join(flags)
|
|
|
|
+ self.run(f'nmake -f "{makefile}" LOC="{flags}"')
|
|
|
|
|
|
def build(self):
|
|
def build(self):
|
|
- cmake = CMake(self)
|
|
|
|
- cmake.configure(source_folder="hello")
|
|
|
|
- cmake.build()
|
|
|
|
|
|
+ if self.settings.compiler == "Visual Studio" and os_info.is_windows:
|
|
|
|
+ self._build_nmake()
|
|
|
|
+ else:
|
|
|
|
+ raise ConanInvalidConfiguration("This configuration is not yet supported.")
|
|
|
|
|
|
- # Explicit way:
|
|
|
|
- # self.run('cmake %s/hello %s'
|
|
|
|
- # % (self.source_folder, cmake.command_line))
|
|
|
|
- # self.run("cmake --build . %s" % cmake.build_config)
|
|
|
|
|
|
+ def build_id(self):
|
|
|
|
+ if self.settings.compiler == "Visual Studio":
|
|
|
|
+ self.info_build.options.shared = "Both"
|
|
|
|
|
|
def package(self):
|
|
def package(self):
|
|
self.copy("*.h", dst="include", src="hello")
|
|
self.copy("*.h", dst="include", src="hello")
|
|
@@ -44,6 +62,3 @@ conan_basic_setup()''')
|
|
|
|
|
|
def package_info(self):
|
|
def package_info(self):
|
|
self.cpp_info.libs = ["hello"]
|
|
self.cpp_info.libs = ["hello"]
|
|
-
|
|
|
|
- def configure(self):
|
|
|
|
- del self.settings.compiler.libcxx
|
|
|