emscripten-core / emscripten-core/emscripten
find_package(Threads REQUIRED) error on Windows10 with VS2022
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Please include the following in your bug report:
**Version of emscripten/emsdk:**
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.67 (2c4461731b8c0bffbdecebc0030e0489712f9886)
clang version 20.0.0git (https:/github.com/llvm/llvm-project b9198a17315757dc0c2e831c9df0498dcab55285)
Target: wasm32-unknown-emscripten
Thread model: posix
Here is a minimal example.
```CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
project(TestFindThread)
# -----------------------------------------------------------------------------
# EMSCRIPTEN only
# -----------------------------------------------------------------------------
if (NOT EMSCRIPTEN)
message("Skipping example: This needs to run inside an Emscripten build environment")
return ()
endif ()
# -----------------------------------------------------------------------------
# Handle VTK dependency
# -----------------------------------------------------------------------------
find_package(Threads REQUIRED)
# -----------------------------------------------------------------------------
# Compile example code
# -----------------------------------------------------------------------------
add_executable(TestFindThread
main.cxx
)
# -----------------------------------------------------------------------------
# WebAssembly build options
# -----------------------------------------------------------------------------
set(emscripten_link_options)
set(emscripten_compile_options)
list(APPEND emscripten_link_options
"-lembind"
"-sASYNCIFY=1" # for webgpu async APIs
"-sASYNCIFY_STACK_SIZE=81920" #~297 nesting levels
"-sMODULARIZE=1"
"-sEXPORT_ES6=1"
"-sEXPORT_NAME=createTestFindThreadModule"
"-sENVIRONMENT=web"
"-sALLOW_MEMORY_GROWTH=1"
"-sMAXIMUM_MEMORY=4GB"
"-sSINGLE_FILE=1"
#"--memoryprofiler"
#"--cpuprofiler"
"-sEXPORTED_FUNCTIONS=['_malloc', '_free']"
"-sEXPORTED_RUNTIME_METHODS=['ENV', 'UTF8ToString']"
)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND emscripten_link_options
"-sWASM_BIGINT=1"
"-sMAXIMUM_MEMORY=16GB")
endif ()
set(emscripten_debug_options)
if(DEBUGINFO STREQUAL "NONE")
list(APPEND emscripten_debug_options
"-g0"
)
elseif(DEBUGINFO STREQUAL "READABLE_JS")
list(APPEND emscripten_debug_options
"-g1"
)
list(APPEND emscripten_link_options
"-sDEMANGLE_SUPPORT=1"
)
elseif(DEBUGINFO STREQUAL "PROFILE")
list(APPEND emscripten_debug_options
"-g2"
)
list(APPEND emscripten_link_options
"-sDEMANGLE_SUPPORT=1"
)
elseif(DEBUGINFO STREQUAL "DEBUG_NATIVE")
list(APPEND emscripten_debug_options
"-g3"
)
list(APPEND emscripten_link_options
"-sASSERTIONS=1"
"-sDEMANGLE_SUPPORT=1"
)
endif()
# -----------------------------------------------------------------------------
# Build options
# -----------------------------------------------------------------------------
set(emscripten_optimizations)
if(OPTIMIZE STREQUAL "NO_OPTIMIZATION")
list(APPEND emscripten_optimizations
"-O0"
)
elseif(OPTIMIZE STREQUAL "LITTLE")
list(APPEND emscripten_optimizations
"-O1"
)
elseif(OPTIMIZE STREQUAL "MORE")
list(APPEND emscripten_optimizations
"-O2"
)
elseif(OPTIMIZE STREQUAL "BEST")
list(APPEND emscripten_optimizations
"-O3"
)
elseif(OPTIMIZE STREQUAL "SMALL")
list(APPEND emscripten_optimizations
"-Os"
)
elseif(OPTIMIZE STREQUAL "SMALLEST")
list(APPEND emscripten_optimizations
"-Oz"
)
elseif(OPTIMIZE STREQUAL "SMALLEST_WITH_CLOSURE")
list(APPEND emscripten_optimizations
"-Oz"
)
list(APPEND emscripten_link_options
"--closure=1"
)
endif()
target_compile_options(TestFindThread
PUBLIC
${emscripten_compile_options}
${emscripten_optimizations}
${emscripten_debug_options}
)
target_link_options(TestFindThread
PUBLIC
${emscripten_link_options}
${emscripten_optimizations}
${emscripten_debug_options}
)
```
```cpp
#include
#include
void main()
{
std::cout << "Hello from main thread" << std::endl;
}
```
Just do cmake and error happens:
```
CMake Error at C:/Program Files/CMake/share/cmake-3.30/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.30/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.30/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:17 (find_package)
```
Is it possible to use emsdk on Windows10 with VS2022? Thanks for any comments.
Contributor guide
Assessment
This issue has not been assessed yet.