def generate(self): tc = CMakeToolchain(self) tc.variables["UNITS_DOWNCAST_MODE"] = str(self.options.downcast_mode).upper() # if self._run_tests: # TODO Enable this when environment is supported in the Conan toolchain tc.variables["UNITS_BUILD_DOCS"] = self.options.build_docs tc.generate() deps = CMakeDeps(self) deps.generate()
def generate(self): deps = CMakeDeps(self) deps.generate() tc = CMakeToolchain(self) tc.variables["BUILD_EXAMPLES"] = self.options.with_examples tc.variables["BUILD_CONFIG"] = self.options.with_config tc.variables["BUILD_GLFW"] = self.options.with_glfw tc.variables["BUILD_IMGUI"] = self.options.with_imgui tc.generate()
def generate(self): cmake = CMakeDeps(self) cmake.generate() tc = CMakeToolchain(self) # Don't use Visual Studio as the CMAKE_GENERATOR if self.settings.compiler == "Visual Studio": tc.blocks["generic_system"].values["generator_platform"] = None tc.blocks["generic_system"].values["toolset"] = None tc.generate()
def generate(self): toolchain = CMakeToolchain(self) toolchain.variables["GSOAP_PATH"] = "." toolchain.variables["BUILD_TOOLS"] = True toolchain.variables["WITH_OPENSSL"] = self.options.with_openssl toolchain.variables["WITH_IPV6"] = self.options.with_ipv6 toolchain.variables["WITH_COOKIES"] = self.options.with_cookies toolchain.variables["WITH_C_LOCALE"] = self.options.with_c_locale toolchain.generate() deps = CMakeDeps(self) deps.generate()
def generate(self): tc = CMakeToolchain(self) tc.generator = "Ninja Multi-Config" tc.variables["CMAKE_VERBOSE_MAKEFILE"] = "TRUE" if self.settings.os == "iOS": tc.variables["CMAKE_SYSTEM_NAME"] = "iOS" if self.settings.arch != "x86_64": tc.blocks["apple_system"].values[ "cmake_osx_architectures"] = "armv7;arm64" tc.generate() deps = CMakeDeps(self) deps.generate()
def generate(self): tc = CMakeToolchain(self) tc.variables["CMAKE_SYSTEM_NAME"] = "Generic" tc.variables["CMAKE_SYSTEM_PROCESSOR"] = "cortex-m4" # disable linking stage of cmake compiler test build (required for crosscompilation) tc.variables["CMAKE_TRY_COMPILE_TARGET_TYPE"] = "STATIC_LIBRARY" #tc.variables[""] = "" tc.generate() deps = CMakeDeps(self) deps.generate()
def test_cpp_info_name_cmakedeps_components(): conanfile = ConanFile(Mock(), None) conanfile.settings = "os", "compiler", "build_type", "arch" conanfile.initialize( Settings({ "os": ["Windows"], "compiler": ["gcc"], "build_type": ["Release"], "arch": ["x86"] }), EnvValues()) cpp_info = CppInfo("mypkg", "dummy_root_folder1") cpp_info.names["cmake_find_package_multi"] = "GlobakPkgName1" cpp_info.components["mycomp"].names[ "cmake_find_package_multi"] = "MySuperPkg1" cpp_info.filenames["cmake_find_package_multi"] = "ComplexFileName1" conanfile.deps_cpp_info.add("mypkg", DepCppInfo(cpp_info)) cmakedeps = CMakeDeps(conanfile) files = cmakedeps.content assert "TARGET GlobakPkgName1::MySuperPkg1" in files[ "ComplexFileName1Config.cmake"] with pytest.raises( ConanException, match="'mypkg' defines information for 'cmake_find_package_multi'" ): with environment_append({CONAN_V2_MODE_ENVVAR: "1"}): _ = cmakedeps.content
def generate(self): tc = CMakeToolchain(self) # TODO refactor to conans qt if self.options.qt_install: qt_install = str(self.options.qt_install) qt_cmake_dir = os.path.join(qt_install, 'lib', 'cmake', 'Qt5') self.output.info("qt_cmake_dir: %s" % (qt_cmake_dir)) tc.variables["Qt5_DIR"] = qt_cmake_dir.replace('\\', '\\\\') tc.variables["BUILD_SERVERS"] = self.options.get_safe("enable_servers", default=False) tc.variables["BUILD_UI"] = self.options.get_safe("enable_ui", default=False) tc.generate() cmake = CMakeDeps(self) cmake.generate()
def test_cmake_deps_links_flags(): # https://github.com/conan-io/conan/issues/8703 conanfile = ConanFile(Mock(), None) conanfile._conan_node = Mock() conanfile._conan_node.context = "host" conanfile.settings = "os", "compiler", "build_type", "arch" conanfile.initialize(Settings({"os": ["Windows"], "compiler": ["gcc"], "build_type": ["Release"], "arch": ["x86"]}), EnvValues()) conanfile.settings.build_type = "Release" conanfile.settings.arch = "x86" cpp_info = CppInfo("mypkg", "dummy_root_folder1") # https://github.com/conan-io/conan/issues/8811 regression, fix with explicit - instead of / cpp_info.sharedlinkflags = ["-NODEFAULTLIB", "-OTHERFLAG"] cpp_info.exelinkflags = ["-OPT:NOICF"] conanfile_dep = ConanFile(Mock(), None) conanfile_dep.cpp_info = cpp_info conanfile_dep._conan_node = Mock() conanfile_dep._conan_node.ref = ConanFileReference.loads("mypkg/1.0") conanfile_dep._conan_node.context = "host" conanfile_dep.package_folder = "/path/to/folder_dep" with mock.patch('conans.ConanFile.dependencies', new_callable=mock.PropertyMock) as mock_deps: req = Requirement(ConanFileReference.loads("OriginalDepName/1.0")) mock_deps.return_value = ConanFileDependencies({req: ConanFileInterface(conanfile_dep)}) cmakedeps = CMakeDeps(conanfile) files = cmakedeps.content data_cmake = files["mypkg-release-x86-data.cmake"] assert "set(mypkg_SHARED_LINK_FLAGS_RELEASE -NODEFAULTLIB;-OTHERFLAG)" in data_cmake assert "set(mypkg_EXE_LINK_FLAGS_RELEASE -OPT:NOICF)" in data_cmake
def generate(self): tc = CMakeToolchain(self) tc.variables["enable-debug"] = self.settings.build_type tc.variables["enable-tests"] = False tc.variables[ "LIB_INSTALL_DIR"] = "lib" # https://github.com/FluidSynth/fluidsynth/issues/476 tc.variables["BUILD_SHARED_LIBS"] = self.options.shared for o in [ "floats", "fpe-check", "trap-on-check", "portaudio", "aufile", "dbus", "ipv6", "jack", "ladspa", "libsndfile", "midishare", "opensles", "oboe", "network", "oss", "dsound", "waveout", "winmidi", "sdl2", "pkgconfig", "pulseaudio", "readline", "threads", "lash", "alsa", "systemd", "coreaudio", "coremidi", "framework" ]: tc.variables["enable-{}".format(o)] = self.options.get_safe(o) tc.generate() cmake = CMakeDeps(self) cmake.generate()
def test_cpp_info_name_cmakedeps_components(using_properties): conanfile = ConanFile(Mock(), None) conanfile.settings = "os", "compiler", "build_type", "arch" conanfile.initialize( Settings({ "os": ["Windows"], "compiler": ["gcc"], "build_type": ["Release", "Debug"], "arch": ["x86", "x64"] }), EnvValues()) conanfile.settings.build_type = "Debug" conanfile.settings.arch = "x64" cpp_info = CppInfo("mypkg", "dummy_root_folder1") if using_properties: cpp_info.set_property("cmake_target_name", "GlobakPkgName1") cpp_info.components["mycomp"].set_property("cmake_target_name", "MySuperPkg1") cpp_info.set_property("cmake_file_name", "ComplexFileName1") else: cpp_info.names["cmake_find_package_multi"] = "GlobakPkgName1" cpp_info.components["mycomp"].names[ "cmake_find_package_multi"] = "MySuperPkg1" cpp_info.filenames["cmake_find_package_multi"] = "ComplexFileName1" conanfile_dep = ConanFile(Mock(), None) conanfile_dep.cpp_info = cpp_info with mock.patch('conans.ConanFile.ref', new_callable=mock.PropertyMock) as mock_ref: with mock.patch('conans.ConanFile.dependencies', new_callable=mock.PropertyMock) as mock_deps: mock_ref.return_value = ConanFileReference.loads( "OriginalDepName/1.0") mock_deps.return_value = Mock() conanfile_dep.package_folder = "/path/to/folder_dep" conanfile.dependencies.transitive_host_requires = [ ConanFileInterface(conanfile_dep) ] conanfile.dependencies.host_requires = [ ConanFileInterface(conanfile_dep) ] cmakedeps = CMakeDeps(conanfile) files = cmakedeps.content assert "TARGET GlobakPkgName1::MySuperPkg1" in files[ "ComplexFileName1Config.cmake"] assert 'set(GlobakPkgName1_INCLUDE_DIRS_DEBUG "${GlobakPkgName1_PACKAGE_FOLDER}/include")' \ in files["ComplexFileName1-debug-x64-data.cmake"] assert 'set(GlobakPkgName1_MySuperPkg1_INCLUDE_DIRS_DEBUG ' \ '"${GlobakPkgName1_PACKAGE_FOLDER}/include")' \ in files["ComplexFileName1-debug-x64-data.cmake"]
def generate(self): tc = CMakeToolchain(self) tc.variables["CMAKE_SYSTEM_NAME"] = "Generic" tc.variables["CMAKE_SYSTEM_PROCESSOR"] = "armv7" tc.variables["CMAKE_TRY_COMPILE_TARGET_TYPE"] = "STATIC_LIBRARY" # If the source folder is missing, we're doing a local build from the recipe folder. Local # recipe builds have a different include path than cache builds, since the source is not # copied into the build/install folder during local builds. if (self.source_folder is None): # local build # eg, ~/work/libtest/include/ tc.variables[ "CMAKE_INCLUDE_PATH"] = self.recipe_folder + "/include" else: # cache build # eg, ~/.conan/data/libtest/0.0.1/aptera/sandbox/build/b1b...b9f6/ tc.variables[ "CMAKE_INCLUDE_PATH"] = self.install_folder + "/include" tc.generate() deps = CMakeDeps(self) deps.generate()
def test_component_name_same_package(): """ When the package and the component are the same the variables declared in data and linked to the target have to be the same. https://github.com/conan-io/conan/issues/9071""" conanfile = ConanFile(Mock(), None) conanfile._conan_node = Mock() conanfile._conan_node.context = "host" conanfile.settings = "os", "compiler", "build_type", "arch" conanfile.initialize( Settings({ "os": ["Windows"], "compiler": ["gcc"], "build_type": ["Release"], "arch": ["x86"] }), EnvValues()) conanfile.settings.build_type = "Release" conanfile.settings.arch = "x86" cpp_info = CppInfo("mypkg", "dummy_root_folder1") # We adjust the component with the same name as the package on purpose cpp_info.components["mypkg"].includedirs = ["includedirs1"] conanfile_dep = ConanFile(Mock(), None) conanfile_dep.cpp_info = cpp_info conanfile_dep._conan_node = Mock() conanfile_dep._conan_node.context = "host" conanfile_dep._conan_node.ref = ConanFileReference.loads("mypkg/1.0") conanfile_dep.folders.set_base_package("/path/to/folder_dep") with mock.patch('conans.ConanFile.dependencies', new_callable=mock.PropertyMock) as mock_deps: req = Requirement(ConanFileReference.loads("mypkg/1.0")) mock_deps.return_value = ConanFileDependencies( {req: ConanFileInterface(conanfile_dep)}) cmakedeps = CMakeDeps(conanfile) files = cmakedeps.content target_cmake = files["mypkg-Target-release.cmake"] assert "$<$<CONFIG:Release>:${mypkg_mypkg_mypkg_INCLUDE_DIRS_RELEASE}> APPEND)" \ in target_cmake data_cmake = files["mypkg-release-x86-data.cmake"] assert 'set(mypkg_mypkg_mypkg_INCLUDE_DIRS_RELEASE ' \ '"${mypkg_PACKAGE_FOLDER_RELEASE}/includedirs1")' in data_cmake
def test_cpp_info_name_cmakedeps_components(): conanfile = ConanFile(Mock(), None) conanfile._conan_node = Mock() conanfile._conan_node.context = "host" conanfile.settings = "os", "compiler", "build_type", "arch" conanfile.initialize( Settings({ "os": ["Windows"], "compiler": ["gcc"], "build_type": ["Release", "Debug"], "arch": ["x86", "x64"] }), EnvValues()) conanfile.settings.build_type = "Debug" conanfile.settings.arch = "x64" cpp_info = CppInfo("mypkg", "dummy_root_folder1") cpp_info.set_property("cmake_target_name", "GlobakPkgName1::GlobakPkgName1") cpp_info.components["mycomp"].set_property("cmake_target_name", "GlobakPkgName1::MySuperPkg1") cpp_info.set_property("cmake_file_name", "ComplexFileName1") conanfile_dep = ConanFile(Mock(), None) conanfile_dep.cpp_info = cpp_info conanfile_dep._conan_node = Mock() conanfile_dep._conan_node.ref = ConanFileReference.loads( "OriginalDepName/1.0") conanfile_dep._conan_node.context = "host" conanfile_dep.folders.set_base_package("/path/to/folder_dep") with mock.patch('conans.ConanFile.dependencies', new_callable=mock.PropertyMock) as mock_deps: req = Requirement(ConanFileReference.loads("OriginalDepName/1.0")) mock_deps.return_value = ConanFileDependencies( {req: ConanFileInterface(conanfile_dep)}) cmakedeps = CMakeDeps(conanfile) files = cmakedeps.content assert "TARGET GlobakPkgName1::MySuperPkg1" in files[ "ComplexFileName1-Target-debug.cmake"] assert 'set(OriginalDepName_INCLUDE_DIRS_DEBUG ' \ '"${OriginalDepName_PACKAGE_FOLDER_DEBUG}/include")' \ in files["ComplexFileName1-debug-x64-data.cmake"] assert 'set(OriginalDepName_GlobakPkgName1_MySuperPkg1_INCLUDE_DIRS_DEBUG ' \ '"${OriginalDepName_PACKAGE_FOLDER_DEBUG}/include")' \ in files["ComplexFileName1-debug-x64-data.cmake"]
def test_cpp_info_name_cmakedeps(using_properties): conanfile = ConanFile(Mock(), None) conanfile._conan_node = Mock() conanfile._conan_node.context = "host" conanfile.settings = "os", "compiler", "build_type", "arch" conanfile.initialize( Settings({ "os": ["Windows"], "compiler": ["gcc"], "build_type": ["Release"], "arch": ["x86"] }), EnvValues()) conanfile.settings.build_type = "Release" conanfile.settings.arch = "x86" cpp_info = CppInfo("mypkg", "dummy_root_folder1") if using_properties: cpp_info.set_property("cmake_target_name", "MySuperPkg1") cpp_info.set_property("cmake_file_name", "ComplexFileName1") else: cpp_info.names["cmake_find_package_multi"] = "MySuperPkg1" cpp_info.filenames["cmake_find_package_multi"] = "ComplexFileName1" conanfile_dep = ConanFile(Mock(), None) conanfile_dep.cpp_info = cpp_info conanfile_dep._conan_node = Mock() conanfile_dep._conan_node.ref = ConanFileReference.loads( "OriginalDepName/1.0") conanfile_dep._conan_node.context = "host" conanfile_dep.package_folder = "/path/to/folder_dep" with mock.patch('conans.ConanFile.dependencies', new_callable=mock.PropertyMock) as mock_deps: req = Requirement(ConanFileReference.loads("OriginalDepName/1.0")) mock_deps.return_value = ConanFileDependencies( {req: ConanFileInterface(conanfile_dep)}) cmakedeps = CMakeDeps(conanfile) files = cmakedeps.content assert "TARGET MySuperPkg1::MySuperPkg1" in files[ "ComplexFileName1-Target-release.cmake"] assert 'set(OriginalDepName_INCLUDE_DIRS_RELEASE ' \ '"${OriginalDepName_PACKAGE_FOLDER_RELEASE}/include")' \ in files["ComplexFileName1-release-x86-data.cmake"]
def test_cmake_deps_links_flags(): # https://github.com/conan-io/conan/issues/8703 conanfile = ConanFile(Mock(), None) conanfile.settings = "os", "compiler", "build_type", "arch" conanfile.initialize(Settings({"os": ["Windows"], "compiler": ["gcc"], "build_type": ["Release"], "arch": ["x86"]}), EnvValues()) conanfile.settings.build_type = "Release" conanfile.settings.arch = "x86" cpp_info = CppInfo("mypkg", "dummy_root_folder1") cpp_info.sharedlinkflags = ["/NODEFAULTLIB", "/OTHERFLAG"] cpp_info.exelinkflags = ["/OPT:NOICF"] conanfile.deps_cpp_info.add("mypkg", cpp_info) cmakedeps = CMakeDeps(conanfile) files = cmakedeps.content data_cmake = files["mypkg-release-x86-data.cmake"] assert "set(mypkg_SHARED_LINK_FLAGS_RELEASE -NODEFAULTLIB;-OTHERFLAG)" in data_cmake assert "set(mypkg_EXE_LINK_FLAGS_RELEASE -OPT:NOICF)" in data_cmake
def generate(self): tc = CMakeToolchain(self, generator=os.getenv("CONAN_CMAKE_GENERATOR")) tc.generate() deps = CMakeDeps(self) deps.generate()
def generate(self): cmake = CMakeDeps(self) cmake.generate()
def generate(self): tc = CMakeToolchain(self) tc.generate() deps = CMakeDeps(self) deps.generate()