-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildDemo.py
executable file
·41 lines (31 loc) · 1.04 KB
/
buildDemo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
import os
import subprocess as sp
def build_cmake_bin(srcdir, installdir):
"""
This function builds a 'build' directory under srcdir for out of source build.
The compiled binaries will be automatically installed to installdir.
Inputs:
- srcdir: directory containing 'CMakeLists.txt'
- installdir: directory to install compiled binaries
"""
origpath = os.getcwd()
os.chdir(srcdir)
if not os.path.isfile("CMakeLists.txt"):
print "-- ERROR: can't find CMakeLists.txt in " + os.getcwd()
exit(-1)
if os.path.isdir( "build" ):
r = raw_input( "-- Previous build exists, delete?[y/n]")
if r == "y":
sp.call( "rm -rf build/*", shell=True )
else:
os.makedirs( "build" )
os.chdir( "build" )
sp.call( ["cmake", "-DCMAKE_INSTALL_PREFIX=" + installdir, ".."] )
sp.call( ["make"] )
sp.call( ["make", "install"] )
os.chdir(origpath)
def main():
build_cmake_bin("demo", os.getcwd())
if __name__ == "__main__":
main()