aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-11-13 16:51:30 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-11-13 16:51:30 -0800
commit81fba7f602257a6ff682f6193eec251b52c1031b (patch)
treea33faa5f56fbe0dca02b992460891e4144b37675
parented177cf59f029a6229128fce308aa6c78873d30d (diff)
parentef0fa03b4bc2b3f2cc0f786443d61696774185ab (diff)
Merge pull request #710 from juj/cmake
Try to locate emcc in cmake based on the cmake toolchain directory struc...
-rw-r--r--cmake/Platform/Emscripten.cmake8
-rw-r--r--cmake/Platform/Emscripten_unix.cmake25
-rwxr-xr-xtests/runner.py2
3 files changed, 22 insertions, 13 deletions
diff --git a/cmake/Platform/Emscripten.cmake b/cmake/Platform/Emscripten.cmake
index e050d8a6..fde45b3e 100644
--- a/cmake/Platform/Emscripten.cmake
+++ b/cmake/Platform/Emscripten.cmake
@@ -16,12 +16,12 @@
set(CMAKE_SYSTEM_NAME Emscripten)
set(CMAKE_SYSTEM_VERSION 1)
-if ("$ENV{EMSCRIPTEN}" STREQUAL "")
- message(ERROR "Environment variable EMSCRIPTEN has not been set! Please point it to Emscripten root directory!")
+if ("${EMSCRIPTEN_ROOT_PATH}" STREQUAL "")
+ set(CMAKE_FIND_ROOT_PATH "$ENV{EMSCRIPTEN}")
+else()
+ set(CMAKE_FIND_ROOT_PATH "${EMSCRIPTEN_ROOT_PATH}")
endif()
-set(CMAKE_FIND_ROOT_PATH $ENV{EMSCRIPTEN})
-
# Specify the compilers to use for C and C++
if ("${CMAKE_C_COMPILER}" STREQUAL "")
set(CMAKE_C_COMPILER "emcc")
diff --git a/cmake/Platform/Emscripten_unix.cmake b/cmake/Platform/Emscripten_unix.cmake
index 5358138f..92a21fd1 100644
--- a/cmake/Platform/Emscripten_unix.cmake
+++ b/cmake/Platform/Emscripten_unix.cmake
@@ -1,13 +1,24 @@
# On Unix platforms, we must specify the absolute path to emcc for cmake, having emcc in PATH will cause cmake to fail finding it.
# The user must set the EMSCRIPTEN variable to point to the Emscripten root folder.
-if ("$ENV{EMSCRIPTEN}" STREQUAL "")
- message(ERROR "Environment variable EMSCRIPTEN has not been set! Please point it to Emscripten root directory!")
+# Try locating Emscripten root directory based on the location of this toolchain file.
+get_filename_component(GUESS_EMSCRIPTEN_ROOT_PATH "${CMAKE_CURRENT_LIST_FILE}/../../.." ABSOLUTE)
+if (EXISTS "${GUESS_EMSCRIPTEN_ROOT_PATH}/emcc")
+ set(EMSCRIPTEN_ROOT_PATH "${GUESS_EMSCRIPTEN_ROOT_PATH}")
endif()
-set(CMAKE_C_COMPILER "$ENV{EMSCRIPTEN}/emcc")
-set(CMAKE_CXX_COMPILER "$ENV{EMSCRIPTEN}/em++")
-set(CMAKE_AR "$ENV{EMSCRIPTEN}/emar")
-set(CMAKE_RANLIB "$ENV{EMSCRIPTEN}/emranlib")
+# If not found, try if the environment variable Emscripten was set.
+if ("${EMSCRIPTEN_ROOT_PATH}" STREQUAL "")
+ if ("$ENV{EMSCRIPTEN}" STREQUAL "")
+ message(ERROR "Could not locate emcc and the environment variable EMSCRIPTEN has not been set! Please point it to Emscripten root directory!")
+ else()
+ set(EMSCRIPTEN_ROOT_PATH "$ENV{EMSCRIPTEN}")
+ endif()
+endif()
+
+set(CMAKE_C_COMPILER "${EMSCRIPTEN_ROOT_PATH}/emcc")
+set(CMAKE_CXX_COMPILER "${EMSCRIPTEN_ROOT_PATH}/em++")
+set(CMAKE_AR "${EMSCRIPTEN_ROOT_PATH}/emar")
+set(CMAKE_RANLIB "${EMSCRIPTEN_ROOT_PATH}/emranlib")
-include($ENV{EMSCRIPTEN}/cmake/Platform/Emscripten.cmake)
+include(${EMSCRIPTEN_ROOT_PATH}/cmake/Platform/Emscripten.cmake)
diff --git a/tests/runner.py b/tests/runner.py
index 12ab6203..b2249dac 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7542,8 +7542,6 @@ f.close()
# understands Windows paths, and cygwin make additionally produces a cryptic 'not valid bitcode file' errors on files that
# *are* valid bitcode files.
- os.environ['EMSCRIPTEN'] = path_from_root('') # XXX FIXME this should be done in emconfigure
-
if os.name == 'nt':
make_command = 'mingw32-make'
emscriptencmaketoolchain = path_from_root('cmake', 'Platform', 'Emscripten.cmake')