Fixed the build for web using CMake. (#1452)

* Fixed the build for web using CMake.

I found that the build for me was failing and I added some if defined checks in the core.c file where the glfwSetWindowAttrib was used. (error: implicit declaration of function 'glfwSetWindowAttrib' is invalid in C99 [-Werror,-Wimplicit-function-declaration])

I also changed some values in the toolchain file so that it correctly uses the .bat files when on windows.

* Cleaned up the additional variables (they are not important)

* Added more improvements to cmakelists

Added the option to use the system provided Emscripten toolchain to be more uniform with other libraries.

Fixed and issue which prevented example being built from cmake and also building with html extensions properly.

* Fixed ENUM to STRING because of a missed warning
This commit is contained in:
hristo 2020-12-13 21:29:47 +02:00 committed by GitHub
parent 11ebb54674
commit 6e79476650
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 9 deletions

View file

@ -1,12 +1,20 @@
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR x86)
if (CMAKE_HOST_WIN32)
SET(EMSCRIPTEN_EXTENSION ".bat")
else ()
SET(EMSCRIPTEN_EXTENSION "")
endif()
SET(CMAKE_C_COMPILER emcc${EMSCRIPTEN_EXTENSION})
SET(CMAKE_CXX_COMPILER em++${EMSCRIPTEN_EXTENSION})
SET(CMAKE_C_COMPILER emcc)
SET(CMAKE_CXX_COMPILER em++)
if(NOT DEFINED CMAKE_AR)
find_program(CMAKE_AR NAMES emar)
find_program(CMAKE_AR NAMES emar${EMSCRIPTEN_EXTENSION})
endif()
if(NOT DEFINED CMAKE_RANLIB)
find_program(CMAKE_RANLIB NAMES emranlib)
find_program(CMAKE_RANLIB NAMES emranlib${EMSCRIPTEN_EXTENSION})
endif()
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)