def _configure_autotools(self): autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) yes_no = lambda v: "yes" if v else "no" conf_args = [ "--with-mozilla={}".format(yes_no(self.options.with_mozilla)), "--enable-64bit={}".format(yes_no(self.settings.arch in ("armv8", "x86_64", "mips64", "ppc64", "ppc64le"))), "--enable-strip={}".format(yes_no(self.settings.build_type not in ("Debug", "RelWithDebInfo"))), "--enable-debug={}".format(yes_no(self.settings.build_type == "Debug")), "--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), "--disable-cplus", ] if self._is_msvc: conf_args.extend([ "{}-pc-mingw32".format("x86_64" if self.settings.arch == "x86_64" else "x86"), "--enable-static-rtl={}".format(yes_no("MT" in msvc_runtime_flag(self))), "--enable-debug-rtl={}".format(yes_no("d" in msvc_runtime_flag(self))), ]) elif self.settings.os == "Android": conf_args.extend([ "--with-android-ndk={}".format(tools.get_env(["NDK_ROOT"])), "--with-android-version={}".format(self.settings.os.api_level), "--with-android-platform={}".format(tools.get_env("ANDROID_PLATFORM")), "--with-android-toolchain={}".format(tools.get_env("ANDROID_TOOLCHAIN")), ]) elif self.settings.os == "Windows": conf_args.append("--enable-win32-target={}".format(self.options.win32_target)) env = autotools.vars if self.settings.os == "Macos": if self.settings.arch == "armv8": # conan adds `-arch`, which conflicts with nspr's apple silicon support env["CFLAGS"] = env["CFLAGS"].replace("-arch arm64", "") env["CXXFLAGS"] = env["CXXFLAGS"].replace("-arch arm64", "") autotools.configure(args=conf_args, vars=env) return autotools
def validate(self): # Currently, mimalloc/1.7.6,2.0.6 does not work properly with shared MD builds. # https://github.com/conan-io/conan-center-index/pull/10333#issuecomment-1114110046 if self.version in ["1.7.6", "2.0.6"] and \ self.options.shared and \ microsoft.is_msvc(self) and \ "MD" in microsoft.msvc_runtime_flag(self): raise ConanInvalidConfiguration( "Currently, mimalloc/1.7.6,2.0.6 doesn't work properly with shared MD builds.") # Shared overriding requires dynamic runtime for MSVC: if self.options.override and \ self.options.shared and \ microsoft.is_msvc(self) and \ "MT" in microsoft.msvc_runtime_flag(self): raise ConanInvalidConfiguration( "Dynamic runtime (MD/MDd) is required when using mimalloc as a shared library for override") if self.options.override and \ self.options.get_safe("single_object") and \ self.options.get_safe("inject"): raise ConanInvalidConfiguration("Single object is incompatible with library injection") if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, "17") minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) if not minimum_version: self.output.warn("mimalloc requires C++17. Your compiler is unknown. Assuming it supports C++17.") elif tools.Version(self.settings.compiler.version) < minimum_version: raise ConanInvalidConfiguration("mimalloc requires a compiler that supports at least C++17")
def _replace_runtime_in_file(self, filename): for e in ["MDd", "MTd", "MD", "MT"]: tools.replace_in_file(filename, "/%s " % e, "/%s " % msvc_runtime_flag(self), strict=False) tools.replace_in_file(filename, "/%s\"" % e, "/%s\"" % msvc_runtime_flag(self), strict=False)
def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) if is_msvc(self): tools.replace_in_file( os.path.join(self._source_subfolder, "cmake", "GtsamBuildTypes.cmake"), "/MD ", "/{} ".format(msvc_runtime_flag(self))) tools.replace_in_file( os.path.join(self._source_subfolder, "cmake", "GtsamBuildTypes.cmake"), "/MDd ", "/{} ".format(msvc_runtime_flag(self)))
def _configure_cmake(self): cmake = CMake(self) if tools.cross_building(self): cmake.definitions["FOLLY_HAVE_UNALIGNED_ACCESS_EXITCODE"] = "0" cmake.definitions[ "FOLLY_HAVE_UNALIGNED_ACCESS_EXITCODE__TRYRUN_OUTPUT"] = "" cmake.definitions["FOLLY_HAVE_LINUX_VDSO_EXITCODE"] = "0" cmake.definitions[ "FOLLY_HAVE_LINUX_VDSO_EXITCODE__TRYRUN_OUTPUT"] = "" cmake.definitions["FOLLY_HAVE_WCHAR_SUPPORT_EXITCODE"] = "0" cmake.definitions[ "FOLLY_HAVE_WCHAR_SUPPORT_EXITCODE__TRYRUN_OUTPUT"] = "" cmake.definitions["HAVE_VSNPRINTF_ERRORS_EXITCODE"] = "0" cmake.definitions[ "HAVE_VSNPRINTF_ERRORS_EXITCODE__TRYRUN_OUTPUT"] = "" cmake.definitions[ "CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe( "fPIC", True) cmake.definitions["CXX_STD"] = self.settings.compiler.get_safe( "cppstd") or "c++{}".format(self._minimum_cpp_standard) if is_msvc: cmake.definitions["MSVC_ENABLE_ALL_WARNINGS"] = False cmake.definitions[ "MSVC_USE_STATIC_RUNTIME"] = "MT" in msvc_runtime_flag(self) cmake.configure() return cmake
def validate(self): if self.options.enable_apacheconnector: # FIXME: missing apache2 recipe + few issues raise ConanInvalidConfiguration( "Apache connector not supported: https://github.com/pocoproject/poco/issues/1764" ) if self._is_msvc and self.options.shared and "MT" in msvc_runtime_flag( self): raise ConanInvalidConfiguration( "Cannot build shared poco libraries with MT(d) runtime") for compopt in self._poco_component_tree.values(): if not compopt.option: continue if self.options.get_safe(compopt.option, False): for compdep in compopt.dependencies: if not self._poco_component_tree[compdep].option: continue if not self.options.get_safe( self._poco_component_tree[compdep].option, False): raise ConanInvalidConfiguration( "option {} requires also option {}".format( compopt.option, self._poco_component_tree[compdep].option)) if self.options.enable_data_sqlite: if self.options["sqlite3"].threadsafe == 0: raise ConanInvalidConfiguration( "sqlite3 must be built with threadsafe enabled") if self.options.enable_netssl and self.options.get_safe( "enable_netssl_win", False): raise ConanInvalidConfiguration( "Conflicting enable_netssl[_win] settings")
def _configure_cmake(self): cmake = CMake(self) cmake.definitions[ "CMAKE_INSTALL_CMAKEDIR"] = self._cmake_install_base_path.replace( "\\", "/") cmake.definitions["protobuf_WITH_ZLIB"] = self.options.with_zlib cmake.definitions["protobuf_BUILD_TESTS"] = False cmake.definitions["protobuf_BUILD_PROTOC_BINARIES"] = True if not self.options.debug_suffix: cmake.definitions["protobuf_DEBUG_POSTFIX"] = "" if tools.Version(self.version) >= "3.14.0": cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True if self._can_disable_rtti: cmake.definitions[ "protobuf_DISABLE_RTTI"] = not self.options.with_rtti if self._is_msvc or self._is_clang_cl: runtime = msvc_runtime_flag(self) if not runtime: runtime = self.settings.get_safe("compiler.runtime") cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = "MT" in runtime if tools.Version(self.version) < "3.18.0" and self._is_clang_cl: cmake.definitions["CMAKE_RC_COMPILER"] = os.environ.get( "RC", "llvm-rc") cmake.configure(build_folder=self._build_subfolder) return cmake
def validate(self): if self.settings.compiler.get_safe("cppstd") and self.options.with_openexr: tools.check_min_cppstd(self, 11) if self.options.shared and self._is_msvc and "MT" in msvc_runtime_flag(self): raise ConanInvalidConfiguration("Visual Studio with static runtime is not supported for shared library.") if self.settings.compiler == "clang" and tools.Version(self.settings.compiler.version) < "4": raise ConanInvalidConfiguration("Clang 3.x cannot build OpenCV 3.x due an internal bug.")
def _build_visual(self): crypto_dep = self.deps_cpp_info[str(self.options.crypto_library)] crypto_incdir = crypto_dep.include_paths[0] crypto_libdir = crypto_dep.lib_paths[0] libs = map(lambda lib : lib + ".lib", crypto_dep.libs) system_libs = map(lambda lib : lib + ".lib", crypto_dep.system_libs) nmake_flags = [ "TLIBS=\"%s %s\"" % (" ".join(libs), " ".join(system_libs)), "LTLIBPATHS=/LIBPATH:%s" % crypto_libdir, "OPTS=\"-I%s -DSQLITE_HAS_CODEC\"" % (crypto_incdir), "NO_TCL=1", "USE_AMALGAMATION=1", "OPT_FEATURE_FLAGS=-DSQLCIPHER_CRYPTO_OPENSSL", "SQLITE_TEMP_STORE=%s" % self._temp_store_nmake_value, "TCLSH_CMD=%s" % self.deps_env_info.TCLSH, ] main_target = "dll" if self.options.shared else "sqlcipher.lib" if msvc_runtime_flag(self) in ["MD", "MDd"]: nmake_flags.append("USE_CRT_DLL=1") if self.settings.build_type == "Debug": nmake_flags.append("DEBUG=2") nmake_flags.append("FOR_WIN10=1") platforms = {"x86": "x86", "x86_64": "x64"} nmake_flags.append("PLATFORM=%s" % platforms[str(self.settings.arch)]) vcvars = tools.vcvars_command(self.settings) self.run("%s && nmake /f Makefile.msc %s %s" % (vcvars, main_target, " ".join(nmake_flags)), cwd=self._source_subfolder)
def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) #You can check what these flags do in http://ceres-solver.org/installation.html self._cmake.definitions["LIB_SUFFIX"] = "" self._cmake.definitions["GFLAGS"] = self.options.use_gflags self._cmake.definitions["BUILD_EXAMPLES"] = False #Requires gflags self._cmake.definitions["BUILD_TESTING"] = False #Requires gflags self._cmake.definitions["BUILD_DOCUMENTATION"] = False #Requires python modules Sphinx and sphinx-rtd-theme self._cmake.definitions["CUSTOM_BLAS"] = self.options.use_custom_blas self._cmake.definitions["GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION"] = False #Set to false to Force CMake to use the conan-generated dependencies self._cmake.definitions["EIGENSPARSE"] = self.options.use_eigen_sparse self._cmake.definitions["SUITESPARSE"] = False #Optional. Not supported right now because SuiteSparse is not part of conan-index self._cmake.definitions["LAPACK"] = False #Optional. Not supported right now because LAPACK is not part of conan-index self._cmake.definitions["CXSPARSE"] = False #Optional. Not supported right now because CXSSPARSE is not part of conan-index self._cmake.definitions["MINIGLOG"] = not self.options.use_glog if not self.options.use_TBB: self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_TBB"] = True if tools.Version(self.version) < "2.0": self._cmake.definitions["TBB"] = self.options.use_TBB self._cmake.definitions["OPENMP"] = False self._cmake.definitions["EIGEN_PREFER_EXPORTED_EIGEN_CMAKE_CONFIGURATION"] = False #Set to false to Force CMake to use the conan-generated dependencies self._cmake.definitions["GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION"] = False #Set to false to Force CMake to use the conan-generated dependencies self._cmake.definitions["CXX11_THREADS"] = self.options.use_CXX11_threads self._cmake.definitions["CXX11"] = self.options.use_CXX11 self._cmake.definitions["SCHUR_SPECIALIZATIONS"] = self.options.use_schur_specializations if self._is_msvc: self._cmake.definitions["MSVC_USE_STATIC_CRT"] = "MT" in msvc_runtime_flag(self) self._cmake.configure() return self._cmake
def _configure_cmake(self): cmake = CMake(self) cmake.definitions["PCRE_BUILD_TESTS"] = False cmake.definitions["PCRE_BUILD_PCRE8"] = self.options.build_pcre_8 cmake.definitions["PCRE_BUILD_PCRE16"] = self.options.build_pcre_16 cmake.definitions["PCRE_BUILD_PCRE32"] = self.options.build_pcre_32 cmake.definitions["PCRE_BUILD_PCREGREP"] = self.options.build_pcregrep cmake.definitions["PCRE_BUILD_PCRECPP"] = self.options.build_pcrecpp cmake.definitions["PCRE_SUPPORT_LIBZ"] = self.options.get_safe( "with_zlib", False) cmake.definitions["PCRE_SUPPORT_LIBBZ2"] = self.options.get_safe( "with_bzip2", False) cmake.definitions["PCRE_SUPPORT_JIT"] = self.options.with_jit cmake.definitions["PCRE_SUPPORT_UTF"] = self.options.with_utf cmake.definitions[ "PCRE_SUPPORT_UNICODE_PROPERTIES"] = self.options.with_unicode_properties cmake.definitions["PCRE_SUPPORT_LIBREADLINE"] = False cmake.definitions["PCRE_SUPPORT_LIBEDIT"] = False cmake.definitions[ "PCRE_NO_RECURSE"] = not self.options.with_stack_for_recursion if self._is_msvc: cmake.definitions[ "PCRE_STATIC_RUNTIME"] = "MT" in msvc_runtime_flag(self) if tools.is_apple_os(self.settings.os): # Generate a relocatable shared lib on Macos cmake.definitions["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" cmake.configure(build_folder=self._build_subfolder) return cmake
def _configure_cmake(self): cmake = CMake(self) cmake.definitions["BUILD_BULLET3"] = self.options.bullet3 cmake.definitions["INSTALL_LIBS"] = True cmake.definitions[ "USE_GRAPHICAL_BENCHMARK"] = self.options.graphical_benchmark cmake.definitions[ "USE_DOUBLE_PRECISION"] = self.options.double_precision cmake.definitions[ "BULLET2_MULTITHREADING"] = self.options.bt2_thread_locks cmake.definitions[ "USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD"] = self.options.soft_body_multi_body_dynamics_world cmake.definitions["BUILD_ENET"] = self.options.network_support cmake.definitions["BUILD_CLSOCKET"] = self.options.network_support cmake.definitions["BUILD_CPU_DEMOS"] = False cmake.definitions["BUILD_OPENGL3_DEMOS"] = False cmake.definitions["BUILD_BULLET2_DEMOS"] = False cmake.definitions["BUILD_EXTRAS"] = self.options.extras cmake.definitions["BUILD_UNIT_TESTS"] = False if self._is_msvc: cmake.definitions[ "USE_MSVC_RUNTIME_LIBRARY_DLL"] = "MD" in msvc_runtime_flag( self) cmake.configure() return cmake
def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) if self.options.with_openssl: self._cmake.definitions["OPENSSL_ROOT_DIR"] = self.deps_cpp_info[ "openssl"].rootpath self._cmake.definitions[ "EVENT__LIBRARY_TYPE"] = "SHARED" if self.options.shared else "STATIC" self._cmake.definitions[ "EVENT__DISABLE_DEBUG_MODE"] = self.settings.build_type == "Release" self._cmake.definitions[ "EVENT__DISABLE_OPENSSL"] = not self.options.with_openssl self._cmake.definitions[ "EVENT__DISABLE_THREAD_SUPPORT"] = self.options.disable_threads self._cmake.definitions["EVENT__DISABLE_BENCHMARK"] = True self._cmake.definitions["EVENT__DISABLE_TESTS"] = True self._cmake.definitions["EVENT__DISABLE_REGRESS"] = True self._cmake.definitions["EVENT__DISABLE_SAMPLES"] = True # libevent uses static runtime (MT) for static builds by default if self._is_msvc: self._cmake.definitions[ "EVENT__MSVC_STATIC_RUNTIME"] = "MT" in msvc_runtime_flag(self) self._cmake.configure(build_folder=self._build_subfolder) return self._cmake
def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) if self._is_msvc: run_configure_icu_file = os.path.join(self._source_subfolder, "source", "runConfigureICU") flags = "-{}".format(msvc_runtime_flag(self)) if not (self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < "12"): flags += " -FS" tools.replace_in_file(run_configure_icu_file, "-MDd", flags) tools.replace_in_file(run_configure_icu_file, "-MD", flags) if tools.os_info.is_windows: # https://unicode-org.atlassian.net/projects/ICU/issues/ICU-20545 srcdir = os.path.join(self.build_folder, self._source_subfolder, "source") makeconv_cpp = os.path.join(srcdir, "tools", "makeconv", "makeconv.cpp") tools.replace_in_file( makeconv_cpp, "pathBuf.appendPathPart(arg, localError);", "pathBuf.append(\"/\", localError); pathBuf.append(arg, localError);" ) # relocatable shared libs on macOS mh_darwin = os.path.join(self._source_subfolder, "source", "config", "mh-darwin") tools.replace_in_file(mh_darwin, "-install_name $(libdir)/$(notdir", "-install_name @rpath/$(notdir") tools.replace_in_file( mh_darwin, "-install_name $(notdir $(MIDDLE_SO_TARGET)) $(PKGDATA_TRAILING_SPACE)", "-install_name @rpath/$(notdir $(MIDDLE_SO_TARGET))", )
def generate(self): tc = CMakeToolchain(self) if Version(self.version) < "2.2.8": tc.variables["BUILD_doc"] = "Off" tc.variables["BUILD_examples"] = "Off" tc.variables["BUILD_shared"] = self.options.shared tc.variables["BUILD_tests"] = "Off" tc.variables["BUILD_tools"] = "Off" # Generate a relocatable shared lib on Macos tc.variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" else: # These options were renamed in 2.2.8 to be more consistent tc.variables["EXPAT_BUILD_DOCS"] = "Off" tc.variables["EXPAT_BUILD_EXAMPLES"] = "Off" tc.variables["EXPAT_SHARED_LIBS"] = self.options.shared tc.variables["EXPAT_BUILD_TESTS"] = "Off" tc.variables["EXPAT_BUILD_TOOLS"] = "Off" # EXPAT_CHAR_TYPE was added in 2.2.8 tc.variables["EXPAT_CHAR_TYPE"] = self.options.char_type if is_msvc(self): tc.variables[ "EXPAT_MSVC_STATIC_CRT"] = "MT" in msvc_runtime_flag(self) if Version(self.version) >= "2.2.10": tc.variables["EXPAT_BUILD_PKGCONFIG"] = False tc.generate()
def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) build_only = ["core"] for sdk in self._sdks: if self.options.get_safe(sdk): build_only.append(sdk) self._cmake.definitions["BUILD_ONLY"] = ";".join(build_only) self._cmake.definitions["ENABLE_UNITY_BUILD"] = True self._cmake.definitions["ENABLE_TESTING"] = False self._cmake.definitions["AUTORUN_UNIT_TESTS"] = False self._cmake.definitions["BUILD_DEPS"] = False if self.settings.os != "Windows": self._cmake.definitions["ENABLE_OPENSSL_ENCRYPTION"] = True self._cmake.definitions["MINIMIZE_SIZE"] = self.options.min_size if self._is_msvc and not self._use_aws_crt_cpp: self._cmake.definitions["FORCE_SHARED_CRT"] = "MD" in msvc_runtime_flag(self) if tools.cross_building(self): self._cmake.definitions["CURL_HAS_H2_EXITCODE"] = "0" self._cmake.definitions["CURL_HAS_H2_EXITCODE__TRYRUN_OUTPUT"] = "" self._cmake.definitions["CURL_HAS_TLS_PROXY_EXITCODE"] = "0" self._cmake.definitions["CURL_HAS_TLS_PROXY_EXITCODE__TRYRUN_OUTPUT"] = "" self._cmake.configure() return self._cmake
def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) self._cmake.definitions[ "Boost_USE_STATIC_LIBS"] = not self.options["boost"].shared self._cmake.definitions[ "deprecated-functions"] = self.options.enable_deprecated_functions self._cmake.definitions["dht"] = self.options.enable_dht self._cmake.definitions["encryption"] = self.options.enable_encryption self._cmake.definitions["exceptions"] = self.options.enable_exceptions self._cmake.definitions["i2p"] = self.options.enable_i2p self._cmake.definitions["logging"] = self.options.enable_logging self._cmake.definitions[ "mutable-torrents"] = self.options.enable_mutable_torrents self._cmake.definitions["build_tests"] = False self._cmake.definitions["build_examples"] = False self._cmake.definitions["build_tools"] = False self._cmake.definitions["python-bindings"] = False self._cmake.definitions["python-bindings"] = False if self._is_msvc: self._cmake.definitions[ "static_runtime"] = "MT" in msvc_runtime_flag(self) self._cmake.configure() return self._cmake
def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) if tools.Version(self.version) < "2.2.8": self._cmake.definitions["BUILD_doc"] = "Off" self._cmake.definitions["BUILD_examples"] = "Off" self._cmake.definitions["BUILD_shared"] = self.options.shared self._cmake.definitions["BUILD_tests"] = "Off" self._cmake.definitions["BUILD_tools"] = "Off" # Generate a relocatable shared lib on Macos self._cmake.definitions["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" else: # These options were renamed in 2.2.8 to be more consistent self._cmake.definitions["EXPAT_BUILD_DOCS"] = "Off" self._cmake.definitions["EXPAT_BUILD_EXAMPLES"] = "Off" self._cmake.definitions["EXPAT_SHARED_LIBS"] = self.options.shared self._cmake.definitions["EXPAT_BUILD_TESTS"] = "Off" self._cmake.definitions["EXPAT_BUILD_TOOLS"] = "Off" # EXPAT_CHAR_TYPE was added in 2.2.8 self._cmake.definitions["EXPAT_CHAR_TYPE"] = self.options.char_type if self._is_msvc: self._cmake.definitions["EXPAT_MSVC_STATIC_CRT"] = "MT" in msvc_runtime_flag(self) if tools.Version(self.version) >= "2.2.10": self._cmake.definitions["EXPAT_BUILD_PKGCONFIG"] = False self._cmake.configure(build_folder=self._build_subfolder) return self._cmake
def validate(self): if self.options.shared and self._is_msvc and "MT" in msvc_runtime_flag( self): raise ConanInvalidConfiguration( "shared gdcm can't be built with MT or MTd") if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, "11")
def validate(self): if self.options.get_safe( "shared") and self._is_msvc and "MT" in msvc_runtime_flag( self): raise ConanInvalidConfiguration( "Visual Studio build for shared library with MT runtime is not supported" )
def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) self._cmake.definitions[ "CMAKE_DISABLE_FIND_PACKAGE_Sndio"] = True # FIXME: missing sndio cci recipe (check whether it is really required) self._cmake.definitions[ "CMAKE_DISABLE_FIND_PACKAGE_Speex"] = True # FIXME: missing sndio cci recipe (check whether it is really required) self._cmake.definitions[ "CMAKE_DISABLE_FIND_PACKAGE_SQLite3"] = True # only used for regtest self._cmake.definitions[ "ENABLE_EXTERNAL_LIBS"] = self.options.with_external_libs if not self.options.with_external_libs: self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Ogg"] = True self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Vorbis"] = True self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_FLAC"] = True self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Opus"] = True if not self.options.get_safe("with_alsa", False): self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_ALSA"] = True self._cmake.definitions["BUILD_PROGRAMS"] = self.options.programs self._cmake.definitions["BUILD_EXAMPLES"] = False self._cmake.definitions["BUILD_TESTING"] = False self._cmake.definitions["ENABLE_CPACK"] = False self._cmake.definitions[ "ENABLE_EXPERIMENTAL"] = self.options.experimental if self._is_msvc: self._cmake.definitions[ "ENABLE_STATIC_RUNTIME"] = "MT" in msvc_runtime_flag(self) self._cmake.definitions["BUILD_REGTEST"] = False self._cmake.configure() return self._cmake
def _configure_cmake(self): cmake = CMake(self) cmake.definitions["DISABLE_SHARED"] = not self.options.shared cmake.definitions[ "STACK_DIRECTION"] = "-1" # stack grows downwards, on very few platforms stack grows upwards cmake.definitions["WITHOUT_SERVER"] = True cmake.definitions["WITH_UNIT_TESTS"] = False cmake.definitions["ENABLED_PROFILING"] = False cmake.definitions["MYSQL_MAINTAINER_MODE"] = False cmake.definitions["WIX_DIR"] = False if self._with_lz4: cmake.definitions["WITH_LZ4"] = "system" if self._with_zstd: cmake.definitions["WITH_ZSTD"] = "system" cmake.definitions["ZSTD_INCLUDE_DIR"] = self.deps_cpp_info[ "zstd"].include_paths[0] if is_msvc(self): cmake.definitions[ "WINDOWS_RUNTIME_MD"] = "MD" in msvc_runtime_flag(self) if self.options.with_ssl: cmake.definitions["WITH_SSL"] = self.deps_cpp_info[ "openssl"].rootpath if self.options.with_zlib: cmake.definitions["WITH_ZLIB"] = "system" cmake.configure(source_dir=self._source_subfolder) return cmake
def _build_visual_studio(self): if not self.options.shared: # RuntimeLibrary only defined in lib props files build_type = "debug" if self.settings.build_type == "Debug" else "release" props_path = os.path.join(self._source_subfolder, "build.vc", "mpir_{}_lib.props".format(build_type)) old_runtime = "MultiThreaded{}".format( "Debug" if build_type == "debug" else "", ) new_runtime = "MultiThreaded{}{}".format( "Debug" if "d" in msvc_runtime_flag(self) else "", "DLL" if "MD" in msvc_runtime_flag(self) else "", ) tools.replace_in_file(props_path, old_runtime, new_runtime) msbuild = MSBuild(self) for vcxproj_path in self._vcxproj_paths: msbuild.build(vcxproj_path, platforms=self._platforms, upgrade_project=False)
def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) if "MT" in str(msvc_runtime_flag(self)): self._cmake.definitions["RPCLIB_MSVC_STATIC_RUNTIME"] = True self._cmake.configure(build_folder=self._build_subfolder) return self._cmake
def _build_msvc(self): yes_no = lambda v: "yes" if v else "no" with self._msvc_build_environment(): crypto_engines = [] if self.options.with_openssl: ov = tools.Version(self.deps_cpp_info["openssl"].version) crypto_engines.append("openssl={}{}0".format( ov.major, ov.minor)) args = [ "cscript", "configure.js", "prefix={}".format(self.package_folder), "cruntime=/{}".format(msvc_runtime_flag(self)), "debug={}".format(yes_no(self.settings.build_type == "Debug")), "static={}".format(yes_no(not self.options.shared)), "include=\"{}\"".format(";".join( self.deps_cpp_info.include_paths)), "lib=\"{}\"".format(";".join(self.deps_cpp_info.lib_paths)), "with-dl=no", "xslt={}".format(yes_no(self.options.with_xslt)), "iconv={}".format(yes_no(False)), "crypto={}".format(",".join(crypto_engines)), ] configure_command = " ".join(args) self.output.info(configure_command) self.run(configure_command) # Fix library names def format_libs(package): libs = [] for lib in self.deps_cpp_info[package].libs: libname = lib if not libname.endswith(".lib"): libname += ".lib" libs.append(libname) for lib in self.deps_cpp_info[package].system_libs: libname = lib if not libname.endswith(".lib"): libname += ".lib" libs.append(libname) return " ".join(libs) tools.replace_in_file("Makefile.msvc", "libxml2.lib", format_libs("libxml2")) tools.replace_in_file("Makefile.msvc", "libxml2_a.lib", format_libs("libxml2")) if self.options.with_xslt: tools.replace_in_file("Makefile.msvc", "libxslt.lib", format_libs("libxslt")) tools.replace_in_file("Makefile.msvc", "libxslt_a.lib", format_libs("libxslt")) if self.settings.build_type == "Debug": tools.replace_in_file("Makefile.msvc", "libcrypto.lib", "libcryptod.lib") self.run("nmake /f Makefile.msvc")
def _configure_cmake(self): cmake = CMake(self) if is_msvc(self): cmake.definitions["BUILD_SHARED_RUNTIME"] = msvc_runtime_flag(self) == "MD" cmake.definitions["BUILD_TESTS"] = False cmake.definitions["WITH_OPENMP"] = self.options.with_openmp cmake.definitions["WITH_LSR_BINDINGS"] = self.options.with_lsr_bindings cmake.configure(build_folder=self._build_subfolder) return cmake
def _replace_runtime_in_file(self, filename): runtime = msvc_runtime_flag(self) if self._is_clangcl and not runtime: # TODO: to remove if min conan version bumped to a version # implementing https://github.com/conan-io/conan/pull/10898 runtime = self.settings.get_safe("compiler.runtime") for e in ["MDd", "MTd", "MD", "MT"]: tools.replace_in_file(filename, "/{} ".format(e), "/{} ".format(runtime), strict=False) tools.replace_in_file(filename, "/{}\"".format(e), "/{}\"".format(runtime), strict=False)
def _configure_cmake(self): cmake = CMake(self) if is_msvc(self): # don't use self.settings.compiler.runtime cmake.definitions[ "USE_MSVC_RUNTIME_LIBRARY_DLL"] = "MD" in msvc_runtime_flag( self) cmake.configure(build_folder=self._build_subfolder) return cmake
def validate(self): if self.options.shared and self._is_msvc and "MT" in msvc_runtime_flag(self): raise ConanInvalidConfiguration("Visual Studio with static runtime is not supported for shared library.") if self.settings.compiler == "clang" and tools.Version(self.settings.compiler.version) < "4": raise ConanInvalidConfiguration("Clang 3.x can build OpenCV 4.x due an internal bug.") if self.options.with_cuda and not self.options.contrib: raise ConanInvalidConfiguration("contrib must be enabled for cuda") if self.options.get_safe("dnn_cuda", False) and \ (not self.options.with_cuda or not self.options.contrib or not self.options.with_cublas or not self.options.with_cudnn): raise ConanInvalidConfiguration("with_cublas, with_cudnn and contrib must be enabled for dnn_cuda")
def _replace_runtime_in_file(self, filename): runtime = msvc_runtime_flag(self) for e in ["MDd", "MTd", "MD", "MT"]: tools.replace_in_file(filename, "/{} ".format(e), "/{} ".format(runtime), strict=False) tools.replace_in_file(filename, "/{}\"".format(e), "/{}\"".format(runtime), strict=False)