Skip to content

Commit

Permalink
chore: Update CMake to use presets and configurations
Browse files Browse the repository at this point in the history
Bump versions
Tweaked emscripten settings (enable "some" STRICT mode settings)

Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
  • Loading branch information
GordonSmith committed Dec 22, 2023
1 parent b606dc8 commit f1179f7
Show file tree
Hide file tree
Showing 14 changed files with 1,024 additions and 379 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/npmPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- run: npm run lint
- run: sudo apt-get update
- run: sudo apt-get install -y build-essential
- run: sudo apt-get install -y git cmake wget
- run: sudo apt-get install -y git cmake ninja-build wget
- run: sudo apt-get install -y gcc-multilib g++-multilib pkg-config autoconf bison libtool flex zlib1g-dev
- run: sudo apt-get install -y python3 python3-pip
- run: npm run install-build-deps
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testPullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- run: npm run lint
- run: sudo apt-get update
- run: sudo apt-get install -y build-essential
- run: sudo apt-get install -y git cmake wget zip
- run: sudo apt-get install -y git cmake ninja-build wget
- run: sudo apt-get install -y gcc-multilib g++-multilib pkg-config autoconf bison libtool flex
- run: sudo apt-get install -y python3 python3-pip
- run: npm run install-build-deps
Expand Down
31 changes: 16 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
cmake_minimum_required(VERSION 3.9.2)

set(REPO_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(VCPKG_FILES_DIR "${CMAKE_BINARY_DIR}" CACHE STRING "Folder for vcpkg download, build and installed files")
set(CMAKE_TOOLCHAIN_FILE ${REPO_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${REPO_DIR}/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake)
set(VCPKG_ROOT ${REPO_DIR}/vcpkg)
set(VCPKG_OVERLAY_PORTS ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg-overlays)
set(VCPKG_TARGET_TRIPLET "wasm32-emscripten")
# file(REMOVE ${REPO_DIR}/vcpkg/vcpkg)
cmake_minimum_required(VERSION 3.10)

project(cpp)

Expand All @@ -23,22 +14,31 @@ set(EM_LINK_FLAGS
"-sASSERTIONS=0"
"-sINVOKE_RUN=0"
"-sALLOW_MEMORY_GROWTH=1"
"-sWASM=1"
# "-sWASM=1"
"-sENVIRONMENT=webview"
"-sFILESYSTEM=0"
# "-sMINIMAL_RUNTIME=1"
"-sMODULARIZE=1"
"-sEXPORT_ES6=1"
"-sIGNORE_CLOSURE_COMPILER_ERRORS=0"
# "-sIGNORE_CLOSURE_COMPILER_ERRORS=0"
# "-sWASM_BIGINT=1"
"-sSTANDALONE_WASM=0"
"-sBINARYEN_ASYNC_COMPILATION=1"
# "-sSTANDALONE_WASM=0"
# "-sBINARYEN_ASYNC_COMPILATION=1"
# "-sDYNAMIC_EXECUTION=0"
"-sPOLYFILL=0"
# "-sSTRICT=0"
"-sIGNORE_MISSING_MAIN=0"
"-sAUTO_JS_LIBRARIES=0"
"-sAUTO_NATIVE_LIBRARIES=0"
"-sAUTO_ARCHIVE_INDEXES=0"
"-sDEFAULT_TO_CXX=0"
"-sUSE_GLFW=0"
"-sALLOW_UNIMPLEMENTED_SYSCALLS=1"
"-sINCOMING_MODULE_JS_API=\"['wasmBinary']\""
"--pre-js ${CMAKE_CURRENT_SOURCE_DIR}/src-cpp/src/pre.js"
"--post-js ${CMAKE_CURRENT_SOURCE_DIR}/src-cpp/src/post.js"
)


if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(EM_LINK_FLAGS
${EM_LINK_FLAGS}
Expand Down Expand Up @@ -81,6 +81,7 @@ endif ()

function(packWasm targetID)
add_custom_target(sfx-${targetID} ALL
COMMAND cmake -E make_directory ${REPO_DIR}/lib-esm
COMMAND node ./utils/sfx-wasm.js ${PACK_MODE} ${CMAKE_CURRENT_BINARY_DIR}/${targetID}.wasm > ${REPO_DIR}/lib-esm/${targetID}.wasm.js
WORKING_DIRECTORY ${REPO_DIR}
COMMENT "SFX Wasm ${targetID}"
Expand Down
36 changes: 36 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": 3,
"configurePresets": [
{
"name": "vcpkg",
"hidden": true,
"generator": "Ninja",
"cacheVariables": {
"REPO_DIR": "${sourceDir}",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake"
}
},
{
"name": "vcpkg-emscripten",
"inherits": [
"vcpkg"
],
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "MinSizeRel",
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
"VCPKG_TARGET_TRIPLET": "wasm32-emscripten"
}
},
{
"name": "vcpkg-emscripten-debug",
"inherits": [
"vcpkg-emscripten"
],
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
}
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This repository contains a collection of useful c++ libraries compiled to WASM f
- ...more to follow...

Built with:
- [emsdk](https://github.com/emscripten-core/emsdk) - v3.1.47
- [emsdk](https://github.com/emscripten-core/emsdk) - v3.1.51

## Homepage and Documents

Expand Down

0 comments on commit f1179f7

Please sign in to comment.