Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def find_cmake(p, start):
if p and not os.path.isabs(p):
absp = util.actual_path(p, start)
if os.path.exists(absp): return absp
else:
x = util.cget_dir('cmake', p)
if os.path.exists(x): return x
elif os.path.exists(x + '.cmake'): return x + '.cmake'
return p
def configure(self, src_dir, defines=None, generator=None, install_prefix=None, test=True, variant=None):
self.prefix.log("configure")
util.mkdir(self.build_dir)
args = [
src_dir,
'-DCGET_CMAKE_DIR={}'.format(util.cget_dir('cmake')),
'-DCGET_CMAKE_ORIGINAL_SOURCE_FILE={}'.format(os.path.join(src_dir, self.cmake_original_file))
]
for d in defines or []:
args.append('-D{0}'.format(d))
if generator is not None: args = ['-G', generator] + args
if self.prefix.verbose: args.extend(['-DCMAKE_VERBOSE_MAKEFILE=On'])
if test: args.extend(['-DBUILD_TESTING=On'])
else: args.extend(['-DBUILD_TESTING=Off'])
args.extend(['-DCMAKE_BUILD_TYPE={}'.format(variant or 'Release')])
if install_prefix is not None: args.extend(['-DCMAKE_INSTALL_PREFIX=' + install_prefix])
try:
self.cmake(args=args, cwd=self.build_dir, use_toolchain=True)
except:
self.show_logs()
raise