Skip to content

Commit

Permalink
Merge pull request #1860 from Jarod42/openmp-gcc-clang
Browse files Browse the repository at this point in the history
Add support of openmp for gcc/clang.
  • Loading branch information
samsinsane authored Apr 16, 2022
2 parents 5c2a1cc + dd61540 commit c4265c5
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/tools/clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
Fast = "-ffast-math",
},
strictaliasing = gcc.shared.strictaliasing,
openmp = gcc.shared.openmp,
optimize = {
Off = "-O0",
On = "-O2",
Expand Down
3 changes: 3 additions & 0 deletions src/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
Level2 = { "-fstrict-aliasing", "-Wstrict-aliasing=2" },
Level3 = { "-fstrict-aliasing", "-Wstrict-aliasing=3" },
},
openmp = {
On = "-fopenmp"
},
optimize = {
Off = "-O0",
On = "-O2",
Expand Down
18 changes: 17 additions & 1 deletion tests/tools/test_clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,20 @@
prepare()
test.contains({ "-miphoneos-version-min=5.0" }, clang.getcxxflags(cfg))
end


--
-- 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

15 changes: 15 additions & 0 deletions tests/tools/test_gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 3 additions & 7 deletions website/docs/openmp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```
```

0 comments on commit c4265c5

Please sign in to comment.