Skip to content

Commit

Permalink
Merge pull request #14 from trixi-framework/msl/fix-build-on-macos
Browse files Browse the repository at this point in the history
Fix build step on MacOS (workaround)
  • Loading branch information
sloede authored Oct 26, 2020
2 parents ff2b989 + aa98636 commit 818e50c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ installed as a dependency.
serial binaries without MPI support. Both limitations are planned to be lifted
in the future.*

*Note: On MacOS, you need to have Xcode installed to be able to use this package.*

You can configure P4est.jl to use a custom build of p4est by setting the
following environment variables and building P4est.jl again afterwards:
1. **Set `JULIA_P4EST_PATH`.**
Expand Down
19 changes: 16 additions & 3 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ using MPI
import Pkg.TOML
import P4est_jll


# setup configuration using ideas from MPI.jl
config_toml = joinpath(first(DEPOT_PATH), "prefs", "P4est.toml")
const config_toml = joinpath(first(DEPOT_PATH), "prefs", "P4est.toml")
mkpath(dirname(config_toml))

if !isfile(config_toml)
Expand Down Expand Up @@ -145,12 +144,26 @@ hdrs = ["p4est.h", "p4est_extended.h",
"p6est.h", "p6est_extended.h",
"p8est.h", "p8est_extended.h"]

# Convert symbols in header
# Build list of arguments for Clang
include_args = String[]
@show include_directories
for dir in include_directories
append!(include_args, ("-I", dir))
end

# Workaround for MacOS: The some headers required by p4est (such as `math.h`) are only available via
# Xcode
if Sys.isapple()
# These two paths *should* - on any reasonably current MacOS system - contain the relevant headers
const xcode_include_path_cli = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/"
const xcode_include_path_gui = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/"
if !isdir(xcode_include_path_cli) && !isdir(xcode_include_path_gui)
error("MacOS SDK include paths ('$xcode_include_path_cli' or '$xcode_include_path_gui') do not exist. Have you installed Xcode?")
end
append!(include_args, ("-idirafter", xcode_include_path_cli, "-idirafter", xcode_include_path_gui))
end

# Convert symbols in header
cvts = convert_headers(hdrs, args=include_args) do cursor
header = CodeLocation(cursor).file
name = string(cursor)
Expand Down

0 comments on commit 818e50c

Please sign in to comment.