Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCons] Skip OpenMP test/sample when omp.h is not available #962

Merged
merged 2 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ 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 'Xcode' in result:
if 'clang' in result.lower() and ('Xcode' in result or 'Apple' in result):
env['using_apple_clang'] = True
env['openmp_flag'].insert(0, '-Xpreprocessor')

Expand Down Expand Up @@ -1052,6 +1052,7 @@ else:
env['cxx_stdlib'] = []

env['HAS_CLANG'] = conf.CheckDeclaration('__clang__', '', 'C++')
env['HAS_OPENMP'] = conf.CheckCXXHeader('omp.h', '""')

boost_version_source = get_expression_value(['<boost/version.hpp>'], 'BOOST_LIB_VERSION')
retcode, boost_lib_version = conf.TryRun(boost_version_source, '.cpp')
Expand Down
7 changes: 5 additions & 2 deletions samples/cxx/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS})
localenv.Append(LIBS=env['cantera_libs'])
localenv.Prepend(CPPPATH=['#include'])

buildSample(localenv.Program, pjoin(subdir, name),
mglob(localenv, subdir, *extensions))
if openmp and not env['HAS_OPENMP']:
print("INFO: Skipping sample {} because 'omp.h' was not found.".format(name))
else:
buildSample(localenv.Program, pjoin(subdir, name),
mglob(localenv, subdir, *extensions))

# Note: These Makefiles and SConstruct files are automatically installed
# by the "RecursiveInstall" that grabs everything in the cxx directory.
Expand Down
9 changes: 5 additions & 4 deletions test_problems/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,11 @@ Test('cxx-gas-transport', 'cxx_samples',
Test('cxx-LiC6-electrode', 'cxx_samples',
'#build/samples/cxx/LiC6_electrode/LiC6_electrode', None,
comparisons=[('LiC6_electrode_blessed.csv', 'LiC6_electrode_output.csv')])
Test('cxx-openmp-ignition', 'cxx_samples',
'#build/samples/cxx/openmp_ignition/openmp_ignition',
'opmenmp_ignition_blessed.txt',
ignoreLines=['Running on'])
if env['HAS_OPENMP']:
Test('cxx-openmp-ignition', 'cxx_samples',
'#build/samples/cxx/openmp_ignition/openmp_ignition',
'opmenmp_ignition_blessed.txt',
ignoreLines=['Running on'])
Test('cxx-rankine', 'cxx_samples', '#build/samples/cxx/rankine/rankine',
'rankine_blessed.txt')

Expand Down