| 
									
										
										
										
											2019-04-04 10:34:58 +02:00
										 |  |  | # The MIT License (MIT) | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Copyright (c) 2018 Mateusz Pusz | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Permission is hereby granted, free of charge, to any person obtaining a copy | 
					
						
							|  |  |  | # of this software and associated documentation files (the "Software"), to deal | 
					
						
							|  |  |  | # in the Software without restriction, including without limitation the rights | 
					
						
							|  |  |  | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
					
						
							|  |  |  | # copies of the Software, and to permit persons to whom the Software is | 
					
						
							|  |  |  | # furnished to do so, subject to the following conditions: | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # The above copyright notice and this permission notice shall be included in all | 
					
						
							|  |  |  | # copies or substantial portions of the Software. | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
					
						
							|  |  |  | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
					
						
							|  |  |  | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
					
						
							|  |  |  | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
					
						
							|  |  |  | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
					
						
							|  |  |  | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 
					
						
							|  |  |  | # SOFTWARE. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-09 22:09:21 +01:00
										 |  |  | from conans import ConanFile, CMake, tools | 
					
						
							| 
									
										
										
										
											2020-01-31 17:02:27 +01:00
										 |  |  | from conans.tools import Version | 
					
						
							| 
									
										
										
										
											2019-04-10 17:12:24 +01:00
										 |  |  | from conans.errors import ConanInvalidConfiguration | 
					
						
							|  |  |  | import re | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def get_version(): | 
					
						
							|  |  |  |     try: | 
					
						
							| 
									
										
										
										
											2020-01-31 17:02:27 +01:00
										 |  |  |         content = tools.load("src/CMakeLists.txt") | 
					
						
							| 
									
										
										
										
											2019-04-10 17:12:24 +01:00
										 |  |  |         version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1) | 
					
						
							|  |  |  |         return version.strip() | 
					
						
							|  |  |  |     except Exception: | 
					
						
							|  |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-22 12:11:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 10:34:58 +02:00
										 |  |  | class UnitsConan(ConanFile): | 
					
						
							| 
									
										
										
										
											2019-04-07 08:33:13 +02:00
										 |  |  |     name = "mp-units" | 
					
						
							| 
									
										
										
										
											2019-04-10 17:12:24 +01:00
										 |  |  |     version = get_version() | 
					
						
							| 
									
										
										
										
											2018-08-22 12:11:19 +02:00
										 |  |  |     author = "Mateusz Pusz" | 
					
						
							| 
									
										
										
										
											2019-04-06 23:25:35 +02:00
										 |  |  |     license = "https://github.com/mpusz/units/blob/master/LICENSE.md" | 
					
						
							| 
									
										
										
										
											2018-08-22 12:11:19 +02:00
										 |  |  |     url = "https://github.com/mpusz/units" | 
					
						
							| 
									
										
										
										
											2018-09-28 07:47:37 -07:00
										 |  |  |     description = "Physical Units library for C++" | 
					
						
							| 
									
										
										
										
											2019-04-06 23:25:35 +02:00
										 |  |  |     exports = ["LICENSE.md"] | 
					
						
							| 
									
										
										
										
											2020-03-09 19:48:02 +01:00
										 |  |  |     exports_sources = ["docs/*", "src/*", "test/*", "cmake/*", "example/*","CMakeLists.txt"] | 
					
						
							| 
									
										
										
										
											2019-05-08 15:09:42 -06:00
										 |  |  |     settings = "os", "compiler", "build_type", "arch" | 
					
						
							| 
									
										
										
										
											2019-04-05 17:46:01 +02:00
										 |  |  |     requires = ( | 
					
						
							| 
									
										
										
										
											2019-12-11 08:22:12 +01:00
										 |  |  |         "fmt/6.1.0" | 
					
						
							| 
									
										
										
										
											2019-04-05 17:46:01 +02:00
										 |  |  |     ) | 
					
						
							| 
									
										
										
										
											2020-02-10 19:07:13 +01:00
										 |  |  |     # scm = { | 
					
						
							|  |  |  |     #     "type": "git", | 
					
						
							|  |  |  |     #     "url": "auto", | 
					
						
							|  |  |  |     #     "revision": "auto", | 
					
						
							|  |  |  |     #     "submodule": "recursive" | 
					
						
							|  |  |  |     # } | 
					
						
							| 
									
										
										
										
											2019-04-04 11:00:40 +02:00
										 |  |  |     generators = "cmake" | 
					
						
							| 
									
										
										
										
											2018-08-22 12:11:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 16:33:50 -03:00
										 |  |  |     @property | 
					
						
							|  |  |  |     def _run_tests(self): | 
					
						
							|  |  |  |         return tools.get_env("CONAN_RUN_TESTS", False) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-31 17:02:27 +01:00
										 |  |  |     def _configure_cmake(self, folder="src"): | 
					
						
							|  |  |  |         cmake = CMake(self) | 
					
						
							|  |  |  |         if self._run_tests: | 
					
						
							| 
									
										
										
										
											2020-03-09 18:55:41 +01:00
										 |  |  |             # developer's mode (unit tests, examples, documentation, restrictive compilation warnings, ...) | 
					
						
							| 
									
										
										
										
											2020-01-31 17:02:27 +01:00
										 |  |  |             cmake.configure() | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             # consumer's mode (library sources only) | 
					
						
							|  |  |  |             cmake.configure(source_folder=folder, build_folder=folder) | 
					
						
							|  |  |  |         return cmake | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-10 17:19:55 +01:00
										 |  |  |     def configure(self): | 
					
						
							| 
									
										
										
										
											2019-12-17 21:10:35 +01:00
										 |  |  |         if self.settings.compiler != "gcc": # and self.settings.compiler != "clang": | 
					
						
							|  |  |  |             raise ConanInvalidConfiguration("Library works only with gcc") # and clang") | 
					
						
							|  |  |  |         if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "9": | 
					
						
							|  |  |  |             raise ConanInvalidConfiguration("Library requires at least g++-9") | 
					
						
							|  |  |  |         if self.settings.compiler == "clang" and Version(self.settings.compiler.version) < "11": | 
					
						
							|  |  |  |             raise ConanInvalidConfiguration("Library requires at least clang++-11") | 
					
						
							| 
									
										
										
										
											2019-11-21 12:00:03 -03:00
										 |  |  |         if self.settings.compiler.cppstd not in ["20", "gnu20"]: | 
					
						
							| 
									
										
										
										
											2019-05-08 15:09:42 -06:00
										 |  |  |             raise ConanInvalidConfiguration("Library requires at least C++20 support") | 
					
						
							| 
									
										
										
										
											2019-04-10 17:19:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-08 16:09:00 +01:00
										 |  |  |     def requirements(self): | 
					
						
							| 
									
										
										
										
											2019-12-17 21:10:35 +01:00
										 |  |  |         if self.settings.compiler == "clang" or Version(self.settings.compiler.version) < "10": | 
					
						
							| 
									
										
										
										
											2019-12-08 16:09:00 +01:00
										 |  |  |             self.requires("range-v3/0.10.0@ericniebler/stable") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-31 17:02:27 +01:00
										 |  |  |     def build_requirements(self): | 
					
						
							|  |  |  |         if self._run_tests: | 
					
						
							|  |  |  |             self.build_requires("Catch2/2.11.0@catchorg/stable") | 
					
						
							| 
									
										
										
										
											2020-03-09 18:55:41 +01:00
										 |  |  |             # TODO update doxygen to the latest version when available | 
					
						
							|  |  |  |             self.build_requires("doxygen_installer/1.8.17@bincrafters/stable") | 
					
						
							| 
									
										
										
										
											2020-01-31 17:02:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-08 09:52:46 -06:00
										 |  |  |     def build(self): | 
					
						
							|  |  |  |         cmake = self._configure_cmake() | 
					
						
							| 
									
										
										
										
											2018-08-22 12:11:19 +02:00
										 |  |  |         cmake.build() | 
					
						
							| 
									
										
										
										
											2019-11-20 16:33:50 -03:00
										 |  |  |         if self._run_tests: | 
					
						
							| 
									
										
										
										
											2020-02-20 21:16:33 +01:00
										 |  |  |             cmake.test() | 
					
						
							| 
									
										
										
										
											2019-04-06 23:25:35 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def package(self): | 
					
						
							| 
									
										
										
										
											2019-11-21 12:00:03 -03:00
										 |  |  |         self.copy(pattern="LICENSE.md", dst="licenses") | 
					
						
							| 
									
										
										
										
											2019-05-08 09:52:46 -06:00
										 |  |  |         cmake = self._configure_cmake() | 
					
						
							|  |  |  |         cmake.install() | 
					
						
							| 
									
										
										
										
											2018-08-22 12:11:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def package_info(self): | 
					
						
							| 
									
										
										
										
											2019-09-18 11:04:51 -06:00
										 |  |  |         if self.settings.compiler == "gcc": | 
					
						
							| 
									
										
										
										
											2019-10-18 21:24:16 +02:00
										 |  |  |             self.cpp_info.cxxflags = [ | 
					
						
							|  |  |  |                 "-Wno-literal-suffix", | 
					
						
							|  |  |  |                 "-Wno-non-template-friend", | 
					
						
							|  |  |  |             ] | 
					
						
							| 
									
										
										
										
											2019-12-23 13:19:34 +01:00
										 |  |  |             if Version(self.settings.compiler.version) < "10": | 
					
						
							|  |  |  |                 self.cpp_info.cxxflags.extend([ | 
					
						
							|  |  |  |                     "-fconcepts" | 
					
						
							|  |  |  |                 ]) | 
					
						
							| 
									
										
										
										
											2019-04-06 23:25:35 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def package_id(self): | 
					
						
							| 
									
										
										
										
											2020-01-28 08:38:23 +01:00
										 |  |  |         self.info.header_only() |