I have the following Python script.
Code
#!/usr/bin/env python3
import os
def Build(cmake_args):
cmake cmake_args # How to call cmake here by passing in the arguments?
make install # How to call make install here from within Python?
os.mkdir('build')
os.chdir('build')
# Call method Build by passing in all correct arguments
Build('-DCMAKE_INSTALL_PREFIX="./install" -DCMAKE_PREFIX_PATH="$PWD/../packages" ../SourceCodeFolder')
Question:
How do I call cmake
by passing in all Cmake arguments that my CMakeLists.txt
understands? And then how do I call make install
?
Environment:
I am running Python 3.9.0 on macOS Catalina.
PS:
I have ensured that mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX="./install" -DCMAKE_PREFIX_PATH="$PWD/../packages" ../SourceCodeFolder
succeeds when run from the bash shell. So, its only a question of how to call cmake and make from my Python script.
Edit:
I want to run my script on Macos as well as Windows. This is the reason for running cmake and make from a Python script.