def configure(self, clargs=(), generator_id=None): """Calls cmake to generate the makefile (or VS solution, or XCode project). Input: ------ generator_id: string The string representing the CMake generator to use. If None, uses defaults for your platform. """ clargs, generator_id = pop_arg("-G", clargs) generator_id = get_platform().get_best_generator(generator_id) if generator_id is None: sys.exit("Could not get working generator for your system." " Aborting build.") if not os.path.exists("cmake_build"): os.makedirs("cmake_build") cmd = [ "cmake", "..", "-G", generator_id, "-DCMAKE_INSTALL_PREFIX={0}".format(os.getcwd()), "-DPYTHON_EXECUTABLE=" + sys.executable, "-DPYTHON_VERSION_STRING=" + sys.version.split(" ")[0], ] cmd.extend(clargs) # changes dir to cmake_build and calls cmake's configure step # to generate makefile rtn = subprocess.check_call(cmd, cwd="cmake_build") if rtn != 0: raise RuntimeError( "Could not successfully configure your project. " "Please see CMake's output for more information." )
# -*- coding: utf-8 -*- """test_platform ---------------------------------- Tests for platforms, to verify that CMake correctly does a test compilation. """ import os from pycmake.platform_specifics import get_platform # platform is shared across each test. It's a platform-specific object # that defines default CMake generator strings. global platform platform = get_platform() def test_platform_has_entries(): assert(len(platform.default_generators) > 0) def test_write_compiler_test_file(): # write the file that CMake will use to test compile (empty list indicates # we're testing no languages.) platform.write_test_cmakelist([]) try: # verify that the test file exists (it's not valid, because it has no # languages) assert(os.path.exists("cmake_test_compile/CMakeLists.txt")) except:
def __init__(self, generator=None, **defines): if generator: self.generator = generator else: self.generator = platform_specifics.get_platform()