Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,15 @@ function(detect_arch arch)
elseif(host_arch MATCHES "AMD64|amd64|x86_64|x64")
set(_arch x86_64)
endif()
# https://github.com/emscripten-core/emscripten/blob/4.0.6/cmake/Modules/Platform/Emscripten.cmake#L294
if(EMSCRIPTEN)
# https://github.com/emscripten-core/emscripten/blob/4.0.6/cmake/Modules/Platform/Emscripten.cmake#L294C1-L294C80
set(_arch wasm)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
# https://github.com/emscripten-core/emscripten/blob/4.0.6/cmake/Modules/Platform/Emscripten.cmake#L225
set(_arch wasm64)
else()
# https://github.com/emscripten-core/emscripten/blob/4.0.6/cmake/Modules/Platform/Emscripten.cmake#L230
set(_arch wasm)
endif()
endif()
message(STATUS "CMake-Conan: cmake_system_processor=${_arch}")
set(${arch} ${_arch} PARENT_SCOPE)
Expand Down Expand Up @@ -217,7 +223,7 @@ function(detect_lib_cxx lib_cxx)
endfunction()


function(detect_compiler compiler compiler_version compiler_runtime compiler_runtime_type)
function(detect_compiler compiler compiler_version compiler_runtime compiler_runtime_type compiler_threads)
if(DEFINED CMAKE_CXX_COMPILER_ID)
set(_compiler ${CMAKE_CXX_COMPILER_ID})
set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
Expand Down Expand Up @@ -281,6 +287,19 @@ function(detect_compiler compiler compiler_version compiler_runtime compiler_run
set(_compiler "clang")
string(REPLACE "." ";" VERSION_LIST ${_compiler_version})
list(GET VERSION_LIST 0 _compiler_version)

if(EMSCRIPTEN)
set(_compiler "emcc")
string(FIND "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}" "-pthread" _pthread_index)
if(NOT _pthread_index EQUAL -1)
set(_compiler_threads "posix")
else()
string(FIND "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}" "WASM_WORKERS=1" _wasm_workers_index)
if(NOT _wasm_workers_index EQUAL -1)
set(_compiler_threads "wasm_workers")
endif()
endif()
endif()
elseif(_compiler MATCHES GNU)
set(_compiler "gcc")
string(REPLACE "." ";" VERSION_LIST ${_compiler_version})
Expand All @@ -295,11 +314,15 @@ function(detect_compiler compiler compiler_version compiler_runtime compiler_run
if (_compiler_runtime_type)
message(STATUS "CMake-Conan: [settings] compiler.runtime_type=${_compiler_runtime_type}")
endif()
if (_compiler_threads)
message(STATUS "CMake-Conan: [settings] compiler.threads=${_compiler_threads}")
endif()

set(${compiler} ${_compiler} PARENT_SCOPE)
set(${compiler_version} ${_compiler_version} PARENT_SCOPE)
set(${compiler_runtime} ${_compiler_runtime} PARENT_SCOPE)
set(${compiler_runtime_type} ${_compiler_runtime_type} PARENT_SCOPE)
set(${compiler_threads} ${_compiler_threads} PARENT_SCOPE)
endfunction()


Expand Down Expand Up @@ -369,7 +392,7 @@ endmacro()
function(detect_host_profile output_file)
detect_os(os os_api_level os_sdk os_subsystem os_version)
detect_arch(arch)
detect_compiler(compiler compiler_version compiler_runtime compiler_runtime_type)
detect_compiler(compiler compiler_version compiler_runtime compiler_runtime_type compiler_threads)
detect_cxx_standard(compiler_cppstd)
detect_lib_cxx(compiler_libcxx)
detect_build_type(build_type)
Expand Down Expand Up @@ -406,6 +429,9 @@ function(detect_host_profile output_file)
if(compiler_runtime_type)
string(APPEND profile compiler.runtime_type=${compiler_runtime_type} "\n")
endif()
if(compiler_threads)
string(APPEND profile compiler.threads=${compiler_threads} "\n")
endif()
if(compiler_cppstd)
string(APPEND profile compiler.cppstd=${compiler_cppstd} "\n")
endif()
Expand Down