I am using SWIG to generate wrappers for my code which makes SWIG as a direct dependency. I want to package it as part of the library code and build it prior to compilation of my source code. How shall i do so using cmake file if at all i can do so that way.
I have tried including it as an external dependency as well as subdirectory in the CMAKE file but it gives me error like SWIG not found or cannot include SWIG. I would love some recommendation on if this is the right way to package and install SWIG because I don't want to make it into a client side dependency. I would really appreciate some help.
This is the code snippet:
ExternalProject_Add(
SWIG_Project
SOURCE_DIR ${CMAKE_SOURCE_DIR}/headers/swig-4.1.1
BUILD_COMMAND make
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
After doing this how am i supposed to use SWIG like the way
find_package(SWIG)
works since i want to use this command
SWIG_ADD_LIBRARY(abc LANGUAGE python SOURCES abc.i)
You must use the module
UseSwig
so after yourfind_package(SWIG)
you must use:then you can use to wrap
foo.i
as module pyFoo:ref: https://cmake.org/cmake/help/latest/module/UseSWIG.html
note: you can also look at this template repo: https://github.com/Mizux/python-native