Skip to content

Commit

Permalink
mysql-connector-cpp: another try at macOS cross-compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Sep 7, 2024
1 parent 11c4023 commit 70c612a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions recipes/mysql-connector-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import get, copy, rm, export_conandata_patches, apply_conandata_patches, save
from conan.tools.files import get, copy, rm, export_conandata_patches, apply_conandata_patches, replace_in_file
from conan.tools.microsoft import is_msvc_static_runtime
from conan.tools.scm import Version

Expand Down Expand Up @@ -108,13 +108,17 @@ def generate(self):
deps.set_property("zstd", "cmake_target_name", "ext::zstd")
deps.generate()

def build(self):
def _patch_sources(self):
apply_conandata_patches(self)
if is_apple_os(self):
# The CMAKE_OSX_ARCHITECTURES value set by Conan seems to be having no effect for some reason.
# This is a workaround for that.
save(self, os.path.join(self.source_folder, "cdk", "cmake", "platform.cmake"),
f"\nadd_compile_options(-arch {self.settings.arch})\n", append=True)
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
"PROJECT(MySQL_CONCPP)",
f"PROJECT(MySQL_CONCPP)\n\nadd_compile_options(-arch {self.settings.arch})\n")

def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()
Expand Down

0 comments on commit 70c612a

Please sign in to comment.