9 TrueFalseStr=("False","True")
10 TrueFalse={'no':False, 'yes':True}
12 def GetCDMATHOptions(options):
13 res=" -DCDMATH_DIR="+options.cdmath_dir
16 def GetPETSC_DIROptions(options):
17 res=' -DPETSC_DIR='+options.petsc_dir
20 def GetDebugOptions(options):
21 if options.debug == True:
22 res=" -DCMAKE_BUILD_TYPE=Debug "
27 def GetPETSC_ARCHOptions(options):
28 res=' -DPETSC_ARCH="'+options.petsc_arch+'"'
31 def GetInstallPrefix(options):
32 res=" -DCMAKE_INSTALL_PREFIX="+options.install_prefix
35 def GetPythonOptions(options):
36 res=" -DCOREFLOWS_WITH_PYTHON="+TrueFalseStr[options.python]
39 def GetPackagesOptions(options):
40 res=" -DCOREFLOWS_WITH_PACKAGE="+TrueFalseStr[options.packages]
43 def GetDocOptions(options):
44 res=" -DCOREFLOWS_WITH_DOCUMENTATION="+TrueFalseStr[options.doc]
47 def GetGuiOptions(options):
48 res=" -DCOREFLOWS_WITH_GUI="+TrueFalseStr[options.gui]
51 def GetEclipseOptions(options):
52 res=" -G\"Eclipse CDT4 - Unix Makefiles\""*(options.create_eclipse_project)
55 def GetCmakeExecOption(options):
56 cmakeExecutable=options.path_to_cmake_exec
57 return cmakeExecutable
59 def CheckOptions(parser):
60 options, arguments = parser.parse_args()
61 for stringToCheck in ['cdmath_dir', 'petsc_dir', 'petsc_arch']:
62 if options.__dict__[stringToCheck] is None:
63 parser.error("cannot determine "+stringToCheck)
65 def printDocumentationInstructions(options):
67 print "\n\t$ make doc\n\tto create the documentation."
71 def ForgeCMakeCommand(options):
72 installPrefix=GetInstallPrefix(options)
73 CDMATHOptions=GetCDMATHOptions(options)
74 PETSC_DIROptions=GetPETSC_DIROptions(options)
75 PETSC_ARCHOptions=GetPETSC_ARCHOptions(options)
76 guiOptions=GetGuiOptions(options)
77 docOptions=GetDocOptions(options)
78 packagesOptions=GetPackagesOptions(options)
79 debugOptions=GetDebugOptions(options)
80 pythonOptions=GetPythonOptions(options)
81 absolutePathToConfigure = os.path.abspath(sys.argv[0])
82 absolutePathToProjectDir = os.path.dirname(absolutePathToConfigure)
83 eclipseProjectoptions=GetEclipseOptions(options)
91 +PETSC_ARCHOptions+" "
94 +eclipseProjectoptions
96 cmake_executable=GetCmakeExecOption(options)
97 cmake_cmd=cmake_executable+" "+cmake_options+" "+absolutePathToProjectDir
101 usage = "usage: %prog [options]"
102 p = optparse.OptionParser(usage=usage,conflict_handler="error")
103 p.add_option('--prefix',
106 dest="install_prefix",
107 help="specify location for installing CoreFlows (default is $PWD)"
109 p.add_option('--with-petsc-dir',
112 default=os.environ.get('PETSC_DIR'),
114 help="specify the petsc install directory (default value is $PETSC_DIR environement variable )"
116 p.add_option('--with-petsc-arch',
119 default=os.environ.get('PETSC_ARCH'),
121 help="specify the petsc arch (default value is $PETSC_ARCH environement variable )"
123 p.add_option('--with-cdmath-dir',
126 default=os.environ.get('CDMATH_DIR'),
128 help="specify the install directory or CDMATH (default is the environment variable $CDMATH_DIR)"
130 p.add_option('--create-eclipse-project',
133 dest="create_eclipse_project",
134 help="create an eclipse project"
136 p.add_option('--with-python',
140 help="compile python interface for CoreFlows"
142 p.add_option('--with-packages',
146 help="generate CoreFlows packages"
148 p.add_option('--with-gui',
152 help="compile CoreFlows GUI"
154 p.add_option('--with-doc',
158 help="generate CoreFlows documentation"
160 p.add_option('--with-debug',
164 help="compile CoreFlows in debug mode"
166 p.add_option('--with-cmake-exec',
170 dest="path_to_cmake_exec",
171 help="specify a path to a specific CMake executable"
173 options, arguments = p.parse_args()
175 cmake_cmd=ForgeCMakeCommand(options)
177 print "Configuring CoreFlows"
178 returnCode=subprocess.call(cmake_cmd,shell=True)
181 print("\n\nNow issue:\n\t$ make install\n\tfor compiling the code.")
182 print("\n\t$ make test\n\tto test the code execution.")
183 printDocumentationInstructions(options)
185 print("error: cmake did not run correctly.")
187 # if __name__ == '__main__':