1

I wanted to compile EnergyPlus (https://github.com/NREL/EnergyPlus) to a WASM module.

These are steps I followed:

  1. Installed Emscripton on system. emcc --check produces the output
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.37-git
shared:INFO: (Emscripten: Running sanity checks)
  1. Cloned the EnergyPlus from GitHub git clone https://github.com/NREL/EnergyPlus
  2. cd EnergyPlus
  3. mkdir build
  4. cd build
  5. emcmake cmake .. This gave the error
-- Using X11 for window creation
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find X11 (missing: X11_X11_LIB)
Call Stack (most recent call first):
  /Applications/CMake.app/Contents/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /Applications/CMake.app/Contents/share/cmake-3.26/Modules/FindX11.cmake:481 (find_package_handle_standard_args)
  third_party/penumbra/vendor/glfw/CMakeLists.txt:196 (find_package)

Since the EnergyPlus (https://github.com/NREL/EnergyPlus) project is using Cmake as the build system, I followed the section Integrating with a build system from the official documentation of Emscripton.

If emcmake cmake .. succeeds, I would be able to run emcc [-Ox] project.o -o project.js and this would generate the WASM (WebAssembly) module?

Update: For step 6, instead of using cmake .. -DGLFW_USE_OSMESA=1 -DBUILD_STATIC_ENERGYPLUS_API=1 gets rid of the previous error and instead the error I get now is,

CMake Error in src/EnergyPlus/CMakeLists.txt:
  export called with target "energyplusapi" which requires target
  "energypluslib" that is not in any export set.


CMake Error in src/EnergyPlus/CMakeLists.txt:
  export called with target "energyplusapi" which requires target
  "project_options" that is not in any export set.


CMake Error in src/EnergyPlus/CMakeLists.txt:
  export called with target "energyplusapi" which requires target
  "project_fp_options" that is not in any export set.


CMake Error in src/EnergyPlus/CMakeLists.txt:
  export called with target "energyplusapi" which requires target
  "project_warnings" that is not in any export set.
  • related: https://github.com/NREL/EnergyPlus/search?l=CMake&q=find_package+X11 and https://github.com/NREL/EnergyPlus/search?l=CMake&q=_GLFW_X11 in particular, "`elseif (UNIX) set(_GLFW_X11 1)`", then see https://cmake.org/cmake/help/latest/variable/UNIX.html. I'm not sure, but this might boil down to modifying those files to make it more Emscripten-friendly. – starball May 03 '23 at 22:13
  • 1
    your new problem just sounds like a bug with the CMake config of that project. I'd encourage you to raise a bug report to the maintainers. That's the best way to get the problem fixed once and for all. If you do, please add a link here to that bug ticket for posterity. – starball May 04 '23 at 06:37
  • 1
    Yes, I just opened an issue on GitHub. Here it is https://github.com/NREL/EnergyPlus/issues/9997 – Siddhant Sahu May 04 '23 at 06:40

0 Answers0