Skip to content

Commit

Permalink
[CMake] Merge and move the simdjson fetching.
Browse files Browse the repository at this point in the history
Signed-off-by: YiYing He <yiying@secondstate.io>
  • Loading branch information
q82419 committed May 24, 2024
1 parent 5b7a8de commit e69cc89
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 88 deletions.
47 changes: 47 additions & 0 deletions cmake/Helper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,50 @@ if((WASMEDGE_LINK_LLVM_STATIC OR WASMEDGE_BUILD_STATIC_LIB) AND WASMEDGE_USE_LLV
endif()
endif()
endif()

function(wasmedge_setup_simdjson)
# setup simdjson
find_package(simdjson QUIET)
if(simdjson_FOUND)
message(STATUS "SIMDJSON found")
else()
message(STATUS "Downloading SIMDJSON source")
include(FetchContent)
FetchContent_Declare(
simdjson
GIT_REPOSITORY https://github.com/simdjson/simdjson.git
GIT_TAG tags/v3.9.1
GIT_SHALLOW TRUE)

if(MSVC)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(
-Wno-undef
-Wno-suggest-override
-Wno-documentation
-Wno-sign-conversion
-Wno-extra-semi-stmt
-Wno-old-style-cast
-Wno-error=unused-parameter
-Wno-error=unused-template
-Wno-conditional-uninitialized
-Wno-implicit-int-conversion
-Wno-shorten-64-to-32
-Wno-range-loop-bind-reference
-Wno-format-nonliteral
-Wno-unused-exception-parameter
-Wno-unused-member-function
)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(
/wd4100 # unreferenced formal parameter
)
endif()
endif()

FetchContent_MakeAvailable(simdjson)
set_property(TARGET simdjson PROPERTY POSITION_INDEPENDENT_CODE ON)

message(STATUS "Downloading SIMDJSON source -- done")
endif()
endfunction()
45 changes: 1 addition & 44 deletions plugins/wasi_nn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,50 +104,7 @@ if(BACKEND STREQUAL "ggml")
set_property(TARGET common PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET llama PROPERTY POSITION_INDEPENDENT_CODE ON)

# setup simdjson
find_package(simdjson QUIET)
if(simdjson_FOUND)
message(STATUS "SIMDJSON found")
else()
message(STATUS "Downloading SIMDJSON source")
include(FetchContent)
FetchContent_Declare(
simdjson
GIT_REPOSITORY https://github.com/simdjson/simdjson.git
GIT_TAG tags/v3.9.1
GIT_SHALLOW TRUE)

if(MSVC)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(
-Wno-undef
-Wno-suggest-override
-Wno-documentation
-Wno-sign-conversion
-Wno-extra-semi-stmt
-Wno-old-style-cast
-Wno-error=unused-parameter
-Wno-error=unused-template
-Wno-conditional-uninitialized
-Wno-implicit-int-conversion
-Wno-shorten-64-to-32
-Wno-range-loop-bind-reference
-Wno-format-nonliteral
-Wno-unused-exception-parameter
-Wno-unused-member-function
)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(
/wd4100 # unreferenced formal parameter
)
endif()
endif()

FetchContent_MakeAvailable(simdjson)
set_property(TARGET simdjson PROPERTY POSITION_INDEPENDENT_CODE ON)

message(STATUS "Downloading SIMDJSON source -- done")
endif()
wasmedge_setup_simdjson()
endif()

wasmedge_add_library(wasmedgePluginWasiNN
Expand Down
46 changes: 2 additions & 44 deletions test/spec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

include(FetchContent)

wasmedge_setup_simdjson()

message(STATUS "Downloading the WASM spec test suite")
FetchContent_Declare(
wasmedge_unit_test
Expand All @@ -12,50 +14,6 @@ FetchContent_Declare(
FetchContent_MakeAvailable(wasmedge_unit_test)
message(STATUS "Downloading the WASM spec test suite -- done")

find_package(simdjson QUIET)
if(simdjson_FOUND)
message(STATUS "SIMDJSON found")
else()
message(STATUS "Downloading SIMDJSON source")
include(FetchContent)
FetchContent_Declare(
simdjson
GIT_REPOSITORY https://github.com/simdjson/simdjson.git
GIT_TAG tags/v3.2.1
GIT_SHALLOW TRUE)

if(MSVC)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(
-Wno-undef
-Wno-suggest-override
-Wno-documentation
-Wno-sign-conversion
-Wno-extra-semi-stmt
-Wno-old-style-cast
-Wno-error=unused-parameter
-Wno-error=unused-template
-Wno-conditional-uninitialized
-Wno-implicit-int-conversion
-Wno-shorten-64-to-32
-Wno-range-loop-bind-reference
-Wno-format-nonliteral
-Wno-unused-exception-parameter
-Wno-unused-member-function
-Wno-missing-prototypes
)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(
/wd4100 # unreferenced formal parameter
/wd4505 # unreferenced local function has been removed
)
endif()
endif()

FetchContent_MakeAvailable(simdjson)
message(STATUS "Downloading SIMDJSON source -- done")
endif()

function(wasmedge_copy_spec_testsuite proposal)
message(STATUS "Copying test suite to ${CMAKE_CURRENT_BINARY_DIR}/testSuites/${proposal}")
file(COPY
Expand Down

0 comments on commit e69cc89

Please sign in to comment.