diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-02-03 10:30:35 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-02-03 10:30:35 -0800 |
commit | 1bb034f764022f3da1894f9d84fb5517020eef23 (patch) | |
tree | 4233f63f857dc161fc8809819ef4084480d15bfb | |
parent | 95f4d1d817975a949bbf28da69ed6f613c1e64f3 (diff) | |
parent | 43c7d8a24ee94dff752036585a3a8711df61c7c4 (diff) |
Merge pull request #212 from ehsan/cmake_support_2
Support CMake in emconfigure
-rw-r--r-- | tools/shared.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/shared.py b/tools/shared.py index aedf054b..db783e39 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -1,5 +1,6 @@ import shutil, time, os, sys, json, tempfile, copy from subprocess import Popen, PIPE, STDOUT +from tempfile import mkstemp __rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) def path_from_root(*pathelems): @@ -366,10 +367,36 @@ class Building: return env @staticmethod + def handle_CMake_toolchain(args): + CMakeToolchain = '''# the name of the target operating system +SET(CMAKE_SYSTEM_NAME Linux) + +# which C and C++ compiler to use +SET(CMAKE_C_COMPILER $EMSCRIPTEN_ROOT/emcc) +SET(CMAKE_CXX_COMPILER $EMSCRIPTEN_ROOT/em++) + +# here is the target environment located +SET(CMAKE_FIND_ROOT_PATH $EMSCRIPTEN_ROOT/system/include ) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)'''.replace('$EMSCRIPTEN_ROOT', path_from_root('')) + toolchainFile = mkstemp(suffix='.txt')[1] + open(toolchainFile, 'w').write(CMakeToolchain) + args.append('-DCMAKE_TOOLCHAIN_FILE=%s' % os.path.abspath(toolchainFile)) + return args + + @staticmethod def configure(args, stdout=None, stderr=None, env=None): if env is None: env = Building.get_building_env() env['EMMAKEN_JUST_CONFIGURE'] = '1' + if args[0].find('cmake') > -1: + args = Building.handle_CMake_toolchain(args) Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()[0] del env['EMMAKEN_JUST_CONFIGURE'] |