diff --git a/CMakeLists.txt b/CMakeLists.txt index fac4a8fc9..374773296 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,13 @@ cmake_policy(SET CMP0048 NEW) set_property(GLOBAL PROPERTY USE_FOLDERS ON) +if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") + set(CMAKE_CXX_COMPILER_WORKS TRUE) + set(CMAKE_C_COMPILER_WORKS TRUE) + set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + set(VCPKG_TARGET_TRIPLET wasm32-emscripten) +endif() + # Automatically set the vcpkg toolchain file if vcpkg exists as a submodule if (EXISTS "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake") message("Using VCPKG Toolchain") @@ -116,10 +123,17 @@ endif() ######################################################### # Shared library -add_library(${PROJECT_NAME} SHARED ${SRCS_COMMON} ${HDRS_COMMON} - ${ACT_GENERATED_SOURCE} - ${VERSION_FILES_OUTPUTLOCATION} -) +if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") + add_library(${PROJECT_NAME} STATIC ${SRCS_COMMON} ${HDRS_COMMON} + ${ACT_GENERATED_SOURCE} + ${VERSION_FILES_OUTPUTLOCATION} + ) +else() + add_library(${PROJECT_NAME} SHARED ${SRCS_COMMON} ${HDRS_COMMON} + ${ACT_GENERATED_SOURCE} + ${VERSION_FILES_OUTPUTLOCATION} + ) +endif () SOURCE_GROUP("Source Files\\Autogenerated" FILES ${ACT_GENERATED_SOURCE}) diff --git a/emscripten_build_notes.txt b/emscripten_build_notes.txt new file mode 100644 index 000000000..7321f7fb9 --- /dev/null +++ b/emscripten_build_notes.txt @@ -0,0 +1,3 @@ +# Building a static library using emscripten compiler + +cmake .. -DCMAKE_SYSTEM_NAME=Emscripten \ No newline at end of file