@@ -96,7 +96,21 @@ set(CMAKE_CXX_COMPILER_AR "${CMAKE_AR}" CACHE FILEPATH "Emscripten ar")
96
96
set (CMAKE_C_COMPILER_RANLIB "${CMAKE_RANLIB} " CACHE FILEPATH "Emscripten ranlib" )
97
97
set (CMAKE_CXX_COMPILER_RANLIB "${CMAKE_RANLIB} " CACHE FILEPATH "Emscripten ranlib" )
98
98
99
- # Don't allow CMake to autodetect the compiler, since it does not understand
99
+ # Capture the Emscripten version to EMSCRIPTEN_VERSION variable.
100
+ if (NOT EMSCRIPTEN_VERSION )
101
+ execute_process (COMMAND "${CMAKE_C_COMPILER} " "-v" RESULT_VARIABLE _cmake_compiler_result ERROR_VARIABLE _cmake_compiler_output OUTPUT_QUIET )
102
+ if (NOT _cmake_compiler_result EQUAL 0 )
103
+ message (FATAL_ERROR "Failed to fetch Emscripten version information with command \" '${CMAKE_C_COMPILER} ' -v\" ! Process returned with error code ${_cmake_compiler_result} ." )
104
+ endif ()
105
+ string (REGEX MATCH "emcc \\ (.*\\ ) ([0-9\\ .]+)" _dummy_unused "${_cmake_compiler_output} " )
106
+ if (NOT CMAKE_MATCH_1 )
107
+ message (FATAL_ERROR "Failed to regex parse Emscripten compiler version from version string: ${_cmake_compiler_output} " )
108
+ endif ()
109
+
110
+ set (EMSCRIPTEN_VERSION "${CMAKE_MATCH_1} " )
111
+ endif ()
112
+
113
+ # Don't allow CMake to autodetect the compiler, since this is quite slow with
100
114
# Emscripten.
101
115
# Pass -DEMSCRIPTEN_FORCE_COMPILERS=OFF to disable (sensible mostly only for
102
116
# testing/debugging purposes).
@@ -128,20 +142,6 @@ if (EMSCRIPTEN_FORCE_COMPILERS)
128
142
endif ()
129
143
endif ()
130
144
131
- # Capture the Emscripten version to EMSCRIPTEN_VERSION variable.
132
- if (NOT EMSCRIPTEN_VERSION )
133
- execute_process (COMMAND "${CMAKE_C_COMPILER} " "-v" RESULT_VARIABLE _cmake_compiler_result ERROR_VARIABLE _cmake_compiler_output OUTPUT_QUIET )
134
- if (NOT _cmake_compiler_result EQUAL 0 )
135
- message (FATAL_ERROR "Failed to fetch Emscripten version information with command \" '${CMAKE_C_COMPILER} ' -v\" ! Process returned with error code ${_cmake_compiler_result} ." )
136
- endif ()
137
- string (REGEX MATCH "emcc \\ (.*\\ ) ([0-9\\ .]+)" _dummy_unused "${_cmake_compiler_output} " )
138
- if (NOT CMAKE_MATCH_1 )
139
- message (FATAL_ERROR "Failed to regex parse Emscripten compiler version from version string: ${_cmake_compiler_output} " )
140
- endif ()
141
-
142
- set (EMSCRIPTEN_VERSION "${CMAKE_MATCH_1} " )
143
- endif ()
144
-
145
145
set (CMAKE_C_COMPILER_ID_RUN TRUE )
146
146
set (CMAKE_C_COMPILER_FORCED TRUE )
147
147
set (CMAKE_C_COMPILER_WORKS TRUE )
0 commit comments