aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2012-11-14 00:23:02 +0200
committerJukka Jylänki <jujjyl@gmail.com>2012-11-14 00:55:11 +0200
commitef0fa03b4bc2b3f2cc0f786443d61696774185ab (patch)
tree19e2be88d211a2a83568b35202a72bd54c888e72 /cmake
parentf6eaab6a2563efb3a541c324880b0219d288f4f9 (diff)
Try to locate emcc in cmake based on the cmake toolchain directory structure to avoid having to set EMSCRIPTEN environment variable on unix. Remove the temporary workaround for other.test_cmake, which shouldn't now be needed.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Platform/Emscripten.cmake8
-rw-r--r--cmake/Platform/Emscripten_unix.cmake25
2 files changed, 22 insertions, 11 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)