From b7459231d26563870242164c156ed8be199821ce Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 17 Sep 2019 14:16:55 +0200 Subject: [PATCH] Check CC environment variable --- python/setup-build.sh.in | 2 ++ python/setup.py | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/python/setup-build.sh.in b/python/setup-build.sh.in index b5e84c85b..d52a7cac0 100644 --- a/python/setup-build.sh.in +++ b/python/setup-build.sh.in @@ -12,6 +12,8 @@ cp -r @PROJECT_SOURCE_DIR@/python @PROJECT_BINARY_DIR@ cd @PROJECT_BINARY_DIR@/python rm -f python/opm/libopmcommon_python.so +export CC=@CMAKE_CXX_COMPILER@ + python setup.py build build_ext --build-lib=python/opm \ --library-dirs=@_setup_lib_dirs@ \ --include-dirs=@_setup_include_dirs@ diff --git a/python/setup.py b/python/setup.py index 8b18e2d73..309dc2495 100644 --- a/python/setup.py +++ b/python/setup.py @@ -36,15 +36,16 @@ if setupdir != '': os.chdir( setupdir ) try: - subprocess.call(["c++", "--version"]) - subprocess.call(['ccache', '--version']) - os.environ['CC'] = 'ccache c++' + subprocess.call(['ccache', '--version']) + cc = os.environ.get("CC", "c++") + os.environ['CC'] = 'ccache {}'.format(cc) + print("Using 'ccache {}' as compiler".format(cc)) except OSError as e: - print('\nNOTE: please install ccache for faster compilation of python bindings.\n') + print('\nNOTE: please install ccache for faster compilation of python bindings.\n') if 'build' in sys.argv: - if not 'build_ext' in sys.argv: - raise TypeError("Missing option 'build_ext'.") + if not 'build_ext' in sys.argv: + raise TypeError("Missing option 'build_ext'.") ext_modules = [ Extension(