Reputation: 405
I'm trying to run CMake for my program, but I keep getting errors that all point towards me not having the desired version of swig in my usr/bin
directory.
Here are the errors I get when I run:
home/program/build_program/Debug$ cmake .. -DCMAKE_BUILD_TYPE=Debug
CMake Error at /home/my_name/tools/cmake/share/cmake-3.15/Modules/FindSWIG.cmake:39 (message):
Command "/usr/bin/swig2.0 -swiglib" failed with output:Call Stack (most recent call first):
CMakeLists.txt:245 (FIND_PACKAGE)CMake Error at CMakeLists.txt:246 (INCLUDE):
INCLUDE called with wrong number of arguments. include() only takes one file.CMake Error at CMakeLists.txt:265 (SWIG_ADD_LIBRARY): Unknown CMake command "SWIG_ADD_LIBRARY".
-- Configuring incomplete, errors occurred! See also "/home/program/build_program/CMakeFiles/CMakeOutput.log".
This is what I see in usr/bin
:
usr/bin$ ls | grep swig
ccache-swig
ccache-swig3.0
swig
swig3.0
And these are lines 245, 246, and 265 in my CMakeLists.txt:
(245) FIND_PACKAGE(SWIG REQUIRED)
(246) INCLUDE(${SWIG_USE_FILE})
(265) SWIG_ADD_LIBRARY(pymcell TYPE SHARED LANGUAGE python SOURCES src/pymcell.i ${SOURCE_FILES} ${BISON_dynGeomParser_OUTPUTS} ${FLEX_dynGeomScanner_OUTPUTS}
)
I think the solution here is to get swig2.0 in usr/bin
, but I'm not sure how to do that.
What I've tried:
I've installed swig2.0.12, but there's no file called "swig2.0", and even if there was, I'm not sure how to properly move that into usr/bin
.
I'm a bit of a noob, so I'm hoping this isn't too silly of a question.
I'm using Debian 9 and CMake 3.15.4.
Upvotes: 0
Views: 1234
Reputation: 18243
Turning my comment into an answer:
The FindSWIG module uses the SWIG_EXECUTABLE
variable as a hint to the location/version of SWIG to use. When a SWIG executable is found, the version is obtained, and cached by CMake. Therefore, subsequent uses of CMake will likely expect the same version of SWIG.
If using CMake with multiple versions of SWIG, or updating the SWIG path and/or version, you can set this SWIG_EXECUTABLE
variable to tell CMake where to look.
set(SWIG_EXECUTABLE /usr/bin/swig3.0)
find_package(SWIG REQUIRED)
When updating the SWIG version or location on your machine, you want to clear any cached SWIG variables within CMake so the latest (or correct) version can be found. Do this by clearing the CMake cache, or deleting the CMakeCache.txt file, and re-running CMake.
Upvotes: 1