JuliaInterop / Cxx.jl

The Julia C++ Interface
Other
757 stars 108 forks source link

Provide override for standard headers in C++ #448

Closed robertu94 closed 4 years ago

robertu94 commented 4 years ago

Using Cxx on a system like Gentoo or some supercomputers with multiple compilers installed in non-standard locations will result in Cxx not finding the standard library. This change allows users to specify where to find the system includes in a way that doesn't requiring forking Cxx to make these changes. Since these systems are inherently non-standard, these changes are unlikely to be fixed with a change to CollectLinuxHeaderPaths! so providing anoverride is better.

This patch is an updated version of pull request #324 and #283 which no longer compile with the current version of Cxx. It also serves as a solution to the issue raised #315 that doesn't require a solution like VPetukhov suggested which essentially forks Cxx for every user with these nonstandard locations.

Gnimuc commented 4 years ago

I think this is good to merge. Thanks for your contribution!

schmrlng commented 4 years ago

I see that this was just merged, but how do we feel about moving these overrides up one line, i.e.,

function collectAllHeaders!(headers, nostdcxx)
    for header in split(get(ENV, "CXXJL_HEADER_DIRS", ""), ":")
        isempty(header) || push!(headers, (header, C_System))
    end
    nostdcxx || collectStdHeaders!(headers)
    collectClangHeaders!(headers)
    headers
end

Otherwise I'm finding (at least on my machine) that headers in "/usr/include" still take precedence over custom "system" headers specified in ENV["CXXJL_HEADER_DIRS"].