aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2012-11-12 22:25:12 +0200
committerJukka Jylänki <jujjyl@gmail.com>2012-11-12 22:25:12 +0200
commitf77bffef097538bd7889a62e818cd00f771d6c43 (patch)
treef0e9dbd3dc011c44135611a41cce731519ed7aae /cmake
parentb8b117d4341a66317fc956dc0779229ef6882dd5 (diff)
Make separate cmake files for unix and windows cmake toolchains. On Windows, specifying the absolute path to emcc causes cmake to fail. On Linux, one must specify absolute path to emcc, or cmake fails. Moreover, since this is a toolchain file that is describing the system, no cmake variables seem to be available to query the platform, so make these separate.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Platform/Emscripten.cmake28
-rw-r--r--cmake/Platform/Emscripten_unix.cmake5
2 files changed, 17 insertions, 16 deletions
diff --git a/cmake/Platform/Emscripten.cmake b/cmake/Platform/Emscripten.cmake
index 9addafc6..63b8da78 100644
--- a/cmake/Platform/Emscripten.cmake
+++ b/cmake/Platform/Emscripten.cmake
@@ -13,24 +13,20 @@
# After that, build the generated Makefile with the command 'make'. On Windows, you may download and use 'mingw32-make' instead.
# the name of the target operating system
-SET(CMAKE_SYSTEM_NAME Emscripten)
-SET(CMAKE_SYSTEM_VERSION 1)
+set(CMAKE_SYSTEM_NAME Emscripten)
+set(CMAKE_SYSTEM_VERSION 1)
-if ("$ENV{EMCC_BIN}" STREQUAL "")
- message(ERROR "Environment variable EMCC_BIN has not been set! Please point it to Emscripten root directory!")
+if ("$ENV{EMSCRIPTEN}" STREQUAL "")
+ message(ERROR "Environment variable EMSCRIPTEN has not been set! Please point it to Emscripten root directory!")
endif()
-#message(STATUS "CMake is using Emscripten toolchain file, Emscripten root path '$ENV{EMCC_BIN}'.")
-
-SET(CMAKE_FIND_ROOT_PATH $ENV{EMCC_BIN})
-
-FILE(TO_CMAKE_PATH "$ENV{EMCC_BIN}" EMCC_PATH)
+set(CMAKE_FIND_ROOT_PATH $ENV{EMSCRIPTEN})
# Specify the compilers to use for C and C++
-SET(CMAKE_C_COMPILER ${EMCC_PATH}/emcc)
-SET(CMAKE_CXX_COMPILER ${EMCC_PATH}/em++)
-SET(CMAKE_AR ${EMCC_PATH}/emar)
-SET(CMAKE_RANLIB ${EMCC_PATH}/emranlib)
+set(CMAKE_C_COMPILER "${EMCC_PATH}emcc")
+set(CMAKE_CXX_COMPILER "${EMCC_PATH}em++")
+set(CMAKE_AR "${EMCC_PATH}emar")
+set(CMAKE_RANLIB "${EMCC_PATH}emranlib")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
@@ -38,9 +34,9 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# Specify the program to use when building static libraries. Force Emscripten-related command line options to clang.
-SET(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_CXX_COMPILER} -o <TARGET> -emit-llvm <LINK_FLAGS> <OBJECTS>")
-SET(CMAKE_C_ARCHIVE_CREATE "${CMAKE_C_COMPILER} -o <TARGET> -emit-llvm <LINK_FLAGS> <OBJECTS>")
+set(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_CXX_COMPILER} -o <TARGET> -emit-llvm <LINK_FLAGS> <OBJECTS>")
+set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_C_COMPILER} -o <TARGET> -emit-llvm <LINK_FLAGS> <OBJECTS>")
# Set a global EMSCRIPTEN variable that can be used in client CMakeLists.txt to detect when building using Emscripten.
# There seems to be some kind of bug with CMake, so you might need to define this manually on the command line with "-DEMSCRIPTEN=1".
-SET(EMSCRIPTEN 1)
+set(EMSCRIPTEN 1)
diff --git a/cmake/Platform/Emscripten_unix.cmake b/cmake/Platform/Emscripten_unix.cmake
new file mode 100644
index 00000000..1e1d7fa9
--- /dev/null
+++ b/cmake/Platform/Emscripten_unix.cmake
@@ -0,0 +1,5 @@
+# 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.
+
+file(TO_CMAKE_PATH "$ENV{EMSCRIPTEN/}" EMCC_PATH)
+include(Emscripten.cmake)