Skip to content

Commit 69e3df9

Browse files
authored
CMake 4.2.0-rc3 (#1628)
Add links to CMake 4.2.0-rc3 into the manifest, and a mechanism inside emsdk.py to look up an installed/activated CMake tool. This enables a simple way to run `emsdk install cmake-4.2.0-rc3-64bit` to acquire the CMake dependency needed for e.g. compiling LLVM and Binaryen. This removes one manual setup item for setting up Emscripten from source.
1 parent e4fe26e commit 69e3df9

2 files changed

Lines changed: 79 additions & 2 deletions

File tree

emsdk.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,14 +962,52 @@ def build_env(generator):
962962
return build_env
963963

964964

965+
# Find path to cmake executable, as one of the activated tools, in PATH, or from installed tools.
966+
def find_cmake():
967+
def locate_cmake_from_tool(tool):
968+
tool_path = get_required_path([tool])
969+
tool_path = tool_path[-1]
970+
cmake_exe = 'cmake.exe' if WINDOWS else 'cmake'
971+
cmake_exe = os.path.join(tool_path, cmake_exe)
972+
if os.path.isfile(cmake_exe):
973+
return cmake_exe
974+
975+
# 1. If user has activated a specific cmake tool, then use that tool to configure the build.
976+
for tool in reversed(tools):
977+
if tool.id == 'cmake' and tool.is_active():
978+
cmake_exe = locate_cmake_from_tool(tool)
979+
if cmake_exe:
980+
info('Found installed+activated CMake tool at "' + cmake_exe + '"')
981+
return cmake_exe
982+
983+
# 2. If cmake already exists in PATH, then use that cmake to configure the build.
984+
cmake_exe = which('cmake')
985+
if cmake_exe:
986+
info('Found CMake from PATH at "' + cmake_exe + '"')
987+
return cmake_exe
988+
989+
# 3. Finally, if user has installed a cmake tool, but has not activated that, then use
990+
# that tool. This enables a single-liner directive
991+
# "emsdk install cmake-4.2.0-rc3-64bit llvm-git-main-64bit" to first install CMake, and
992+
# then use it to configure to build LLVM.
993+
for tool in reversed(tools):
994+
if tool.id == 'cmake' and tool.is_installed():
995+
cmake_exe = locate_cmake_from_tool(tool)
996+
if cmake_exe:
997+
info('Found installed CMake tool at "' + cmake_exe + '"')
998+
return cmake_exe
999+
1000+
exit_with_error('Unable to find "cmake" in PATH, or as installed/activated tool! Please install CMake first')
1001+
1002+
9651003
def make_build(build_root, build_type):
9661004
debug_print('make_build(build_root=' + build_root + ', build_type=' + build_type + ')')
9671005
if CPU_CORES > 1:
9681006
print('Performing a parallel build with ' + str(CPU_CORES) + ' cores.')
9691007
else:
9701008
print('Performing a singlethreaded build.')
9711009

972-
make = ['cmake', '--build', '.', '--config', build_type]
1010+
make = [find_cmake(), '--build', '.', '--config', build_type]
9731011
if 'Visual Studio' in CMAKE_GENERATOR:
9741012
# Visual Studio historically has had a two-tier problem in its build system design. A single MSBuild.exe instance only governs
9751013
# the build of a single project (.exe/.lib/.dll) in a solution. Passing the -j parameter above will only enable multiple MSBuild.exe
@@ -1011,7 +1049,7 @@ def cmake_configure(generator, build_root, src_root, build_type, extra_cmake_arg
10111049
else:
10121050
generator = []
10131051

1014-
cmdline = ['cmake'] + generator + ['-DCMAKE_BUILD_TYPE=' + build_type, '-DPYTHON_EXECUTABLE=' + sys.executable]
1052+
cmdline = [find_cmake()] + generator + ['-DCMAKE_BUILD_TYPE=' + build_type, '-DPYTHON_EXECUTABLE=' + sys.executable]
10151053
# Target macOS 11.0 Big Sur at minimum, to support older Mac devices.
10161054
# See https://en.wikipedia.org/wiki/MacOS#Hardware_compatibility for min-spec details.
10171055
cmdline += ['-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0']

emsdk_manifest.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,45 @@
267267
},
268268

269269

270+
{
271+
"id": "cmake",
272+
"version": "4.2.0-rc3",
273+
"bitness": 64,
274+
"arch": "x86_64",
275+
"activated_cfg": "EMSDK_CMAKE='%installation_dir%/bin/cmake%.exe%'",
276+
"activated_path": "%installation_dir%/bin",
277+
"windows_url": "https://github.com/Kitware/CMake/releases/download/v4.2.0-rc3/cmake-4.2.0-rc3-windows-x86_64.zip",
278+
"linux_url": "https://github.com/Kitware/CMake/releases/download/v4.2.0-rc3/cmake-4.2.0-rc3-linux-x86_64.tar.gz"
279+
},
280+
{
281+
"id": "cmake",
282+
"version": "4.2.0-rc3",
283+
"bitness": 64,
284+
"arch": "x86_64",
285+
"activated_cfg": "EMSDK_CMAKE='%installation_dir%/CMake.app/Contents/bin/cmake%.exe%'",
286+
"activated_path": "%installation_dir%/CMake.app/Contents/bin",
287+
"macos_url": "https://github.com/Kitware/CMake/releases/download/v4.2.0-rc3/cmake-4.2.0-rc3-macos-universal.tar.gz"
288+
},
289+
{
290+
"id": "cmake",
291+
"version": "4.2.0-rc3",
292+
"bitness": 64,
293+
"arch": "arm64",
294+
"activated_cfg": "EMSDK_CMAKE='%installation_dir%/bin/cmake%.exe%'",
295+
"activated_path": "%installation_dir%/bin",
296+
"windows_url": "https://github.com/Kitware/CMake/releases/download/v4.2.0-rc3/cmake-4.2.0-rc3-windows-arm64.zip",
297+
"linux_url": "https://github.com/Kitware/CMake/releases/download/v4.2.0-rc3/cmake-4.2.0-rc3-linux-aarch64.tar.gz"
298+
},
299+
{
300+
"id": "cmake",
301+
"version": "4.2.0-rc3",
302+
"bitness": 64,
303+
"arch": "arm64",
304+
"activated_cfg": "EMSDK_CMAKE='%installation_dir%/CMake.app/Contents/bin/cmake%.exe%'",
305+
"activated_path": "%installation_dir%/CMake.app/Contents/bin",
306+
"macos_url": "https://github.com/Kitware/CMake/releases/download/v4.2.0-rc3/cmake-4.2.0-rc3-macos-universal.tar.gz"
307+
},
308+
270309
{
271310
"id": "python",
272311
"version": "3.9.2-nuget",

0 commit comments

Comments
 (0)