UseSWIG version 2 does not support multiple input files
Minimal project (using Python as target language for Swig and ninja as generator although I believe these do not matter), with CMake 3.13.0-rc1
cmake_minimum_required(VERSION 3.13)
project(swig_cmake LANGUAGES CXX)
find_package(Python COMPONENTS Development REQUIRED)
find_package(SWIG REQUIRED)
set(UseSWIG_MODULE_VERSION 2)
include(${SWIG_USE_FILE})
set_source_files_properties(foo.i bar.i PROPERTIES CPLUSPLUS ON)
swig_add_library(mod TYPE MODULE LANGUAGE python SOURCES foo.i bar.i)
target_link_libraries(mod PRIVATE Python::Python)
Unless I'm misreading the documentation, using multiple *.i
files as SOURCES
is allowed.
The issue is that the cleanup command for the support files directory is embedded in the custom command doing the swig call. When there are multiple swig input files one gets multiple cmake -E remove_directory
for the same target/support files directory.
- Using
ninja -j1
, compiles fine but only the last module file (herebar.i
->bar.py
) appears in the support directory. I'm not entirely sure how this work but I'm assuming removing the directory on the second custom command call is not a good thing. - Using
ninja
(parallel build) I randomly getError removing directory "/home/sylvain/test/swig_cmake/build/CMakeFiles/mod.dir/python.files".
, most likely trying to do the same job at the same time.