Move CMake toolchain variable unset higher up in the file, and document it better.
When using emconfigure/emcmake to invoke cmake toolchain, don't pass in EMMAKEN_JUST_CONFIGURE=1, since that breaks CMake configuration because CMake expects to be able to build identically at config and build time. This fixes CMake check_include_file() with Emscripten. Add tests to make sure that it doesn't regress.
Fix a long-standing CMake toolchain issue where the toolchain was not able to specify a default suffix (.js) for generated executables and the suffix that was set got silently erased. Previously the default suffix was empty "", which meant all user CMakeLists.txt files had to explicitly specify the suffix. Fixing this adds support for CMake built-in check_function_exists() detection macro which is used e.g. by SDL2 CMakeLists.txt path. To build html files, add the directive 'SET(CMAKE_EXECUTABLE_SUFFIX ".html")' like before.
Add CMake directive CMAKE_SIZEOF_INT=4 which openjpeg CMake detection was missing.
Add explicit support for CMake CMakeBackwardsCompatibilityC.cmake detection logic for Emscripten, without running through test builds which have issues with endianness detection.
After previous toolchain directory/include structure change, UNIX=1 was not getting set by default, so set that to Emscripten CMake toolchain manually now.
Now that CMake CHECK_INCLUDE_FILE() macro works, don't unconditionally include getopt() to openjpeg CMake build, but let it get detected via CMake.
Restore the soname symlink generation feature when using CMAKE_SYSTEM_NAME "Emscripten", like the previous CMAKE_SYSTEM_NAME "Linux" did. This lets test_openjpeg generate output files with same file names as before the system name change.
Merge pull request #2513 from juj/improve_cmake_for_sdl2

Improve cmake for sdl2