Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick St.Pierre <120039901+nicholas-stpierre-simplisafe@users.noreply.github.com>2023-05-15 21:35:57 +0300
committerPetteri Aimonen <jpa@github.mail.kapsi.fi>2023-05-15 22:28:14 +0300
commitdbbf5d8992295aae669b8071eadad02f87d5faf0 (patch)
tree4fbacf6c3c61eeb3f6304ead3185d88cdc3e86cc
parent5a3bd898e492255926333fcc585a618bbfc0e5c3 (diff)
Add nanopb_PYTHON_INSTDIR_OVERRIDE to CMakeLists.txt
-rw-r--r--CMakeLists.txt21
1 files changed, 14 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index da32427..7875504 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,8 @@ option(nanopb_BUILD_RUNTIME "Build the headers and libraries needed at runtime"
option(nanopb_BUILD_GENERATOR "Build the protoc plugin for code generation" ON)
option(nanopb_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON)
+set(nanopb_PYTHON_INSTDIR_OVERRIDE "" CACHE PATH "Override the default python installation directory with the given path")
+
find_program(nanopb_PROTOC_PATH protoc HINTS generator-bin generator)
if(NOT EXISTS ${nanopb_PROTOC_PATH})
message(FATAL_ERROR "protoc compiler not found")
@@ -39,13 +41,18 @@ if(NOT DEFINED CMAKE_INSTALL_CMAKEDIR)
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/nanopb")
endif()
-find_package(Python REQUIRED COMPONENTS Interpreter)
-execute_process(
- COMMAND ${Python_EXECUTABLE} -c
- "import os.path, sys, sysconfig; print(os.path.relpath(sysconfig.get_path('purelib'), start=sys.prefix))"
- OUTPUT_VARIABLE PYTHON_INSTDIR
- OUTPUT_STRIP_TRAILING_WHITESPACE
-)
+if (NOT nanopb_PYTHON_INSTDIR_OVERRIDE)
+ find_package(Python REQUIRED COMPONENTS Interpreter)
+ execute_process(
+ COMMAND ${Python_EXECUTABLE} -c
+ "import os.path, sys, sysconfig; print(os.path.relpath(sysconfig.get_path('purelib'), start=sys.prefix))"
+ OUTPUT_VARIABLE PYTHON_INSTDIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+else()
+ set(PYTHON_INSTDIR ${nanopb_PYTHON_INSTDIR_OVERRIDE})
+endif()
+message(STATUS "Python install dir: ${PYTHON_INSTDIR}")
if(nanopb_BUILD_GENERATOR)
set(generator_protos nanopb)