I am using swig
to wrap my c++ code to python. And my file structure is:
build
Project
PackA
PackA.h
PackA.cpp
PackA.i
CMakeLists.txt (c)
CMakeLists.txt (b)
CMakeLists.txt (a)
The PackA.h/PackA.cpp/PackA.i
is:
// PackA.h
#ifndef PACKA_HEADER_H
#define PACKA_HEADER_H
#include "PackAGlobal.h"
#include <string>
class PackA
{
public:
PackA();
};
#endif
// PackA.cpp
#include "PackA.h"
#include <iostream>
PackA::PackA()
{
std::cout << "PackA" << std::endl;
}
// PackA.i
%module PackA
%{
#define SWIG_FILE_WITH_INIT
#include "PackA.h"
%}
%include "PackA.h"
And my CMakeLists.txt (c)
is:
add_library(PackA SHARED PackA.h PackA.cpp)
SET_TARGET_PROPERTIES(PackA
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${Bin_Root}
ARCHIVE_OUTPUT_DIRECTORY ${Lib_Root}
)
set_property(SOURCE PackA.i PROPERTY CPLUSPLUS ON)
swig_add_library(PackAWrapping
LANGUAGE python
SOURCES PackA.i PackA.cpp)
Then, the Configure
and Generate
of CMake
is OK, but vs reports a bug:
PackAPYTHON_wrap.cxx(2800,10): fatal error C1083: cannot open include file: “PackA.h”: No such file or directory
How can I fix this bug? Ang suggestion is appreciated~~~