From dd6154045caba4e5ac1137196379b76741396941 Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Tue, 12 Apr 2022 23:50:47 +0200 Subject: [PATCH] Add support of openmp for gcc/clang. --- src/tools/clang.lua | 1 + src/tools/gcc.lua | 3 +++ tests/tools/test_clang.lua | 18 +++++++++++++++++- tests/tools/test_gcc.lua | 15 +++++++++++++++ website/docs/openmp.md | 10 +++------- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/tools/clang.lua b/src/tools/clang.lua index 90ca05fc66..104f3f1e39 100644 --- a/src/tools/clang.lua +++ b/src/tools/clang.lua @@ -49,6 +49,7 @@ Fast = "-ffast-math", }, strictaliasing = gcc.shared.strictaliasing, + openmp = gcc.shared.openmp, optimize = { Off = "-O0", On = "-O2", diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 0c82b406d1..5f2080faa4 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -67,6 +67,9 @@ Level2 = { "-fstrict-aliasing", "-Wstrict-aliasing=2" }, Level3 = { "-fstrict-aliasing", "-Wstrict-aliasing=3" }, }, + openmp = { + On = "-fopenmp" + }, optimize = { Off = "-O0", On = "-O2", diff --git a/tests/tools/test_clang.lua b/tests/tools/test_clang.lua index e438f70da7..162e27202c 100644 --- a/tests/tools/test_clang.lua +++ b/tests/tools/test_clang.lua @@ -68,4 +68,20 @@ prepare() test.contains({ "-miphoneos-version-min=5.0" }, clang.getcxxflags(cfg)) end - \ No newline at end of file + +-- +-- Check handling of openmp. +-- + + function suite.cflags_onOpenmpOn() + openmp "On" + prepare() + test.contains("-fopenmp", clang.getcflags(cfg)) + end + + function suite.cflags_onOpenmpOff() + openmp "Off" + prepare() + test.excludes("-fopenmp", clang.getcflags(cfg)) + end + diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index df58e0f7b7..eff4056a03 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -702,6 +702,21 @@ test.contains({ "-fstrict-aliasing", "-Wstrict-aliasing=3" }, gcc.getcflags(cfg)) end +-- +-- Check handling of openmp. +-- + + function suite.cflags_onOpenmpOn() + openmp "On" + prepare() + test.contains("-fopenmp", gcc.getcflags(cfg)) + end + + function suite.cflags_onOpenmpOff() + openmp "Off" + prepare() + test.excludes("-fopenmp", gcc.getcflags(cfg)) + end -- -- Check handling of system search paths. diff --git a/website/docs/openmp.md b/website/docs/openmp.md index fd0fe0f70a..9b9ffe6fb3 100644 --- a/website/docs/openmp.md +++ b/website/docs/openmp.md @@ -20,15 +20,11 @@ Project configurations. ### Availability ### -Premake 5.0-beta1 or later. Currently only implemented for Visual Studio 2010+. As a workaround for other toolsets, you can use [buildoptions](buildoptions.md) like this: - -```lua -filter "toolset:not msc*" - buildoptions "-fopenmp" -``` +Premake 5.0-beta1 or later for Visual Studio 2010+ and the MSC toolset. +Premake 5.0-beta2 or later for the GCC and Clang toolsets. ## Examples ## ```lua openmp "On" -``` \ No newline at end of file +```