diff --git a/SConstruct b/SConstruct index 0567c3499..769c80554 100644 --- a/SConstruct +++ b/SConstruct @@ -253,7 +253,15 @@ defaults.noDebugLinkFlags = '' defaults.warningFlags = '-Wall' defaults.buildPch = False env['pch_flags'] = [] -env['openmp_flag'] = '-fopenmp' # used to generate sample build scripts +env['openmp_flag'] = ['-fopenmp'] # used to generate sample build scripts + +env['using_apple_clang'] = False +# Check if this is actually Apple's clang on macOS +if env['OS'] == 'Darwin': + result = subprocess.check_output([env.subst('$CC'), '--version']).decode('utf-8') + if 'clang' in result.lower() and result.startswith('Apple LLVM'): + env['using_apple_clang'] = True + env['openmp_flag'].insert(0, '-Xpreprocessor') if 'gcc' in env.subst('$CC') or 'gnu-cc' in env.subst('$CC'): defaults.optimizeCcFlags += ' -Wno-inline' @@ -276,13 +284,13 @@ elif env['CC'] == 'cl': # Visual Studio defaults.warningFlags = '/W3' defaults.buildPch = True env['pch_flags'] = ['/FIpch/system.h'] - env['openmp_flag'] = '/openmp' + env['openmp_flag'] = ['/openmp'] elif 'icc' in env.subst('$CC'): defaults.cxxFlags = '-std=c++0x' defaults.ccFlags = '-vec-report0 -diag-disable 1478' defaults.warningFlags = '-Wcheck' - env['openmp_flag'] = '-openmp' + env['openmp_flag'] = ['-openmp'] elif 'clang' in env.subst('$CC'): defaults.ccFlags = '-fcolor-diagnostics' diff --git a/samples/cxx/SConscript b/samples/cxx/SConscript index 0d859b87f..5ce6c5f90 100644 --- a/samples/cxx/SConscript +++ b/samples/cxx/SConscript @@ -18,6 +18,9 @@ for subdir, name, extensions, openmp in samples: localenv = env.Clone() if openmp: localenv.Append(CXXFLAGS=env['openmp_flag'], LINKFLAGS=env['openmp_flag']) + if env['using_apple_clang']: + localenv.Append(LIBS=['omp']) + localenv['cmake_extra'] = """ find_package(OpenMP REQUIRED) set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}) @@ -29,6 +32,8 @@ set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}) if env["OS"] == "Darwin": localenv["cmake_extra"] += "find_library(ACCELERATE_FRAMEWORK Accelerate)" + localenv.Append(LIBS=env['cantera_libs']) + buildSample(localenv.Program, pjoin(subdir, name), mglob(localenv, subdir, *extensions), CPPPATH=['#include', env['boost_inc_dir']])