Skip to content

Commit

Permalink
fix: Conan profile needs to be set outside of ConanFile to ensure it …
Browse files Browse the repository at this point in the history
…applies during the first Conan run. Fixes #525.
  • Loading branch information
dpad committed Jun 27, 2024
1 parent 930eddf commit 39271b6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
36 changes: 19 additions & 17 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,6 @@ class BasiliskConan(ConanFile):
# set cmake generator default
generator = None

# make sure conan is configured to use the libstdc++11 by default
if platform.system() != "Darwin":
try:
subprocess.check_output(["conan", "profile", "new", "default", "--detect"], stdout=subprocess.DEVNULL)
except:
pass

if platform.system() == "Linux":
try:
subprocess.check_output(["conan", "profile", "update",
"settings.compiler.libcxx=libstdc++11", "default"])
print("\nConfiguring: " + statusColor + "use libstdc++11 by default" + endColor)

except:
pass

print(statusColor + "Checking conan configuration:" + endColor + " Done")

def system_requirements(self):
if not self.options.deprecatedBuild:
Expand Down Expand Up @@ -347,6 +330,25 @@ def add_basilisk_to_sys_path(self):
warnings.warn("Installation via 'conanfile.py' is deprecated. Please use `pip` installation instead!", DeprecationWarning)
# TODO: Disable this usage entirely, including all "deprecatedBuild" items.

# make sure conan is configured to use the libstdc++11 by default
# XXX: This needs to be run before dispatching to Conan (i.e. outside of the
# ConanFile object), because it affects the configuration of the first run.
# (Running it here fixes https://github.com/AVSLab/basilisk/issues/525)
if platform.system() != "Darwin":
try:
subprocess.check_output(["conan", "profile", "new", "default", "--detect"])
except:
pass

if platform.system() == "Linux":
try:
# XXX: This fixes a linker issue due to the dual C++ ABI.
subprocess.check_output(["conan", "profile", "update", "settings.compiler.libcxx=libstdc++11", "default"])
print("\nConfiguring: " + statusColor + "use libstdc++11 by default" + endColor)
except:
pass
print(statusColor + "Checking conan configuration:" + endColor + " Done")

parser = argparse.ArgumentParser(description="Configure the Basilisk framework.")
# define the optional arguments
parser.add_argument("--generator", help="cmake generator")
Expand Down
17 changes: 17 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

from unittest.mock import patch
from subprocess import run
import platform

from typing import List
from pathlib import Path
Expand Down Expand Up @@ -120,6 +121,22 @@ def get_source_files(self) -> List[str]:
return []

def run(self) -> None:
if platform.system() != "Darwin":
try:
# XXX: Configure default Conan profile.
run(["conan", "profile", "new", "default", "--detect"])
except:
pass

if platform.system() == "Linux":
try:
# XXX: This is necessary to set the C++ Dual ABI such that some
# libraries, such as opencv, build correctly (without undefined
# symbols). Fixes (https://github.com/AVSLab/basilisk/issues/525).
run(["conan", "profile", "update", "settings.compiler.libcxx=libstdc++11", "default"])
except:
pass

for ext in self.conan_extensions:
# Configure Conan and install dependencies with the appropriate settings.
run([
Expand Down

0 comments on commit 39271b6

Please sign in to comment.