# HG changeset patch # User Sebastien Jodogne # Date 1647795192 -3600 # Node ID 7947565ed2b76d7e5908b87ed42e4e986328da8e # Parent 898774b4e02d32fc8baea0e33884cad9ecd873ef use Python 3 for clang if available diff -r 898774b4e02d -r 7947565ed2b7 Applications/StoneWebViewer/WebAssembly/CMakeLists.txt --- a/Applications/StoneWebViewer/WebAssembly/CMakeLists.txt Sun Mar 20 15:13:57 2022 +0100 +++ b/Applications/StoneWebViewer/WebAssembly/CMakeLists.txt Sun Mar 20 17:53:12 2022 +0100 @@ -31,7 +31,12 @@ # --------------------------------------------------------------- set(USE_WASM ON CACHE BOOL "") -set(WASM_FLAGS "${WASM_FLAGS} -s WASM=1 -s FETCH=1 -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0") +# "-Wno-unused-command-line-argument" is used to avoid annoying +# warnings about setting WASM, FETCH and ASSERTIONS, which was +# required for earlier versions of emsdk: +# https://groups.google.com/g/emscripten-discuss/c/VX4enWfadUE +set(WASM_FLAGS "${WASM_FLAGS} -s WASM=1 -s FETCH=1 -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0 -Wno-unused-command-line-argument") + if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1") endif() @@ -96,9 +101,18 @@ set(LIBCLANG "libclang-4.0.so.1" CACHE PATH "Version of clang to generate the code model") set(STONE_WRAPPER ${CMAKE_CURRENT_BINARY_DIR}/stone.js) +include(FindPython3 OPTIONAL RESULT_VARIABLE HAS_CMAKE_PYTHON3) +if (HAS_CMAKE_PYTHON3 STREQUAL "NOTFOUND" OR + NOT Python3_FOUND) + # CMake <= 3.12 or Python 3 not available: Fallback to Python 2.7 + set(CLANG_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) +else() + set(CLANG_PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) +endif() + add_custom_command( COMMAND - ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/ParseWebAssemblyExports.py --libclang=${LIBCLANG} ${CMAKE_SOURCE_DIR}/StoneWebViewer.cpp > ${STONE_WRAPPER} + ${CLANG_PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/ParseWebAssemblyExports.py --libclang=${LIBCLANG} ${CMAKE_SOURCE_DIR}/StoneWebViewer.cpp > ${STONE_WRAPPER} DEPENDS ${CMAKE_SOURCE_DIR}/StoneWebViewer.cpp ${CMAKE_SOURCE_DIR}/ParseWebAssemblyExports.py