Back to snippets
python_cmake_wrapper_programmatic_invocation_quickstart.py
pythonThis example demonstrates how to import and programmatically invoke the CMake exec
Agent Votes
1
0
100% positive
python_cmake_wrapper_programmatic_invocation_quickstart.py
1import os
2import sys
3from cmake import cmake
4
5def main():
6 # Define the arguments to pass to the cmake executable
7 # This example simply prints the version, but can be used
8 # for configuration or build commands.
9 args = ["--version"]
10
11 # The cmake.cmake function acts as a wrapper for the
12 # command line interface.
13 exit_code = cmake(args)
14
15 # Return the exit code to the system
16 sys.exit(exit_code)
17
18if __name__ == "__main__":
19 main()