Skip to content

Commit 41ee27c

Browse files
committed
CMakeLists.txt: allow disabling Python support
In some cases, even if Swig is found and Python3 is found, it may not be desirable to build Python support in avrdude, so this commit adds an ENABLE_PYTHON_SUPPORT option to be able to explicitly disable using Python support (unfortunately CMake doesn't allow passing arguments that would prevent it from finding Swig/Python 3 if available). To preserve existing behavior, this option defaults to enabled (ON). Signed-off-by: Thomas Petazzoni <[email protected]>
1 parent b440362 commit 41ee27c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

CMakeLists.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ option(USE_EXTERNAL_LIBS "Use external libraries from AVRDUDE GitHub repositorie
3434
option(USE_LIBUSBWIN32 "Prefer libusb-win32 over libusb" OFF)
3535
option(DEBUG_CMAKE "Enable debugging output for this CMake project" OFF)
3636
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
37+
option(ENABLE_PYTHON_SUPPORT "Enable Python support" ON)
3738

3839
if(WIN32)
3940
# Prefer static libraries over DLLs on Windows
@@ -281,14 +282,16 @@ if(HAVE_LINUXGPIO)
281282
endif()
282283

283284
# -------------------------------------
284-
# Find SWIG
285-
find_package(SWIG 4.0 COMPONENTS python)
286-
if(SWIG_FOUND)
287-
find_package(Python3 COMPONENTS Interpreter Development)
288-
if(PYTHON3_FOUND)
289-
set(HAVE_SWIG 1)
290-
else()
291-
message(STATUS "Found SWIG but no Python3 header/library; cannot use SWIG")
285+
# Find SWIG/Python3 if needed
286+
if(ENABLE_PYTHON_SUPPORT)
287+
find_package(SWIG 4.0 COMPONENTS python)
288+
if(SWIG_FOUND)
289+
find_package(Python3 COMPONENTS Interpreter Development)
290+
if(PYTHON3_FOUND)
291+
set(HAVE_SWIG 1)
292+
else()
293+
message(STATUS "Found SWIG but no Python3 header/library; cannot use SWIG")
294+
endif()
292295
endif()
293296
endif()
294297

0 commit comments

Comments
 (0)