Unknown CMake command "SWIG_ADD_LIBRARY"

Hi, I’m trying to install a python3 library with cmake 3.17 and I get this error all the time.

CMake Error at CMakeLists.txt:12 (SWIG_ADD_LIBRARY):
Unknown CMake command “SWIG_ADD_LIBRARY”.

I’ve seen that was a common error with previous versions, but 3.17 is the latest and I still get it.
Do any of you know how to solve it? thanks!

This command is defined in module UseSWIG so it is required to include this module to enable SWIG_ADD_LIBRARY() definition. And SWIG must be searched before this inclusion (module FindSWIG). Here is the needed code:

find_package (SWIG)
include (UseSWIG)
1 Like

many thanks!! that solved it!