Hi,
I'm using swift 5.9.1 on Windows and trying with swift package manger to create a clang module, but I'm having a strange error:
error file not found with <angled> include; use "quotes" instead
I uploaed my project at GitHub - felixf4xu/swiftclangmodule: demo project of swift clangmodule include issue
Basicly the package has 2 target, one is exe in swift, the other one is a c++ library project as clang module.
the clang module is named Cxxlib, it has an umbrella header file at: Cxxlib/include/Cxxlib.h
The c++ project of the library is in folder cxxsource
, which is a standard (hopefully) cmake project. It has public headers in cxxsource/include
folder, and other source (.cpp) and private header file in cxxsource/sublib1
and cxxsource/sublib2
folders. Under cxxsource
, there is a CMakeLists.txt
file and it can be built with cmake sucessfully.
cxxsource
--include (cxxsource's public header folder)
--sublib1
--sublib2
In cmake, to use the public include folder, target_include_directories
is used as:
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
I put all the cxxsource project source (public header and source files) in the Cxxlib
module, so it's not needed to install the cxxsource to system folders. (it can be changed if it's not the way to use a clang module -- I'm new to swift)
The current github commit can be compile by swift build
and then swift run
, but here is the issue:
in cxxsource\include\public.h
, my cxxsource project's publich header file:
// error: 'sublib2/public2.h' file not found with <angled> include; use "quotes" instead
// #include <sublib1/public1.h>
// #include <sublib2/public2.h>
#include "sublib1/public1.h"
#include "sublib2/public2.h"
I originally wanted to use include, like:
#include <sublib1/public1.h>
#include <sublib2/public2.h>
I would have a compiler error:
error: emit-module command failed with exit code 1 (use -v to see invocation)
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "D:\testcode\swiftclangmodule\Sources\Cxxlib\include\Cxxlib.h"
^
D:\testcode\swiftclangmodule\Sources\Cxxlib\include\Cxxlib.h:1:10: note: in file included from D:\testcode\swiftclangmodule\Sources\Cxxlib\include\Cxxlib.h:1:
#include "../cxxsource/include/public.h"
^
D:\testcode\swiftclangmodule\Sources\Cxxlib\include/../cxxsource/include/public.h:4:10: error: 'sublib1/public1.h' file not found with <angled> include; use "quotes" instead
#include <sublib1/public1.h>
^
that's from my previous cmake experience, if I have set the public cxxsource/include
header dir by target_include_directories
, I can (or should) use <>
for header file. cxxsource
is a big c++ project, I use <>
almost in all places that I need to use header files in the cxxsource/include
folder.
Now it seems that if I put the cxxsource/include
in the clang module and the umbrelle header file (Cxxlib/incude/Cxxlib.h
incudes cxxsource/include
, I need to use "quotes" include.
Anything wrong here? swift package manager? clang module? my understanding of "quotes" and <angled>
?
Thanks.