diff options
Diffstat (limited to 'cmake/Platform/Emscripten_unix.cmake')
-rw-r--r-- | cmake/Platform/Emscripten_unix.cmake | 25 |
1 files changed, 18 insertions, 7 deletions
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) |