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

Fix build step on MacOS (workaround) #14

Merged
merged 3 commits into from
Oct 26, 2020
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
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