SPM Wrapped C++ Dependencies .hpp header file not found

Hello,

I'm experimenting with bundling a handful of boost C++ dependency targets inside a SPM project that will contain an ObjC & Swift wrapper for some of the C++ functionality. Some of these boost C++ library targets are header only containing an includes folder with multiple .hpp files (some nested) and no executable C++. When building the project Xcode reports that header files aren't found from the dependency. Here's a limited example:

Boost Regex includes Boost Config:

.target(
            name: "boost_config",
            path: "boost/libs/config",
            exclude: [
                "checks/",
                "doc/",
                "meta/",
                "test/",
                "tools/",
                "appveyor.yml",
                "CMakeLists.txt",
                "configure",
                "index.html",
                "README.md"
            ]
        ),
.target(
            name: "boost_regex",
            dependencies: [
                .target(name: "boost_assert"),
                .target(name: "boost_config")
            ],
            path: "boost/libs/regex",
            exclude: [
                "build/",
                "doc/",
                "example/",
                "meta/",
                "performance",
                "test/",
                "tools/",
                "CMakeLists.txt",
                "index.html",
                "README.md",
                "readme.txt"
            ],
            sources: [
                "src",
            ]),

I've attempted things like adding publicHeadersPath: "include/", adding "include/" to the sources, etc. But it seems that SPM should consider the path include as the default public headers path.

The Xcode error on build is: ..../boost/libs/regex/include/boost/regex/config/cwchar.hpp:24:10: 'boost/config.hpp' file not found. The 'boost/config.hpp' file can be found inside the boost_config dependency target at the path: boost/libs/config/include/boost/config.hpp.

The boost library can be seen here for reference to the file structure, etc. Thoughts on how to accomplish this configuration of multiple separate but somewhat interdependent c++ library dependencies?

You'll need to add each of the sub-library include directories to .headerSearchPath in CXXSettings.

1 Like

That's the ticket. Thanks!