@@ -121,10 +121,14 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
121121
122122include (${WAMR_ROOT_DIR} /build -scripts/runtime_lib.cmake)
123123
124- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow -Wno-unused-parameter -fvisibility=hidden" )
125- # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
126-
127- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused" )
124+ if (NOT WIN32 )
125+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security \
126+ -ffunction-sections -fdata-sections \
127+ -Wno-unused-parameter -Wno-pedantic" )
128+ # Remove the extra spaces for better make log
129+ string (REGEX REPLACE " *" " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS} )
130+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused" )
131+ endif ()
128132
129133if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64" )
130134 if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" ))
@@ -145,6 +149,10 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
145149set (THREADS_PREFER_PTHREAD_FLAG ON )
146150find_package (Threads REQUIRED)
147151
152+ if (MSVC )
153+ add_definitions (-DCOMPILING_WASM_RUNTIME_API=1)
154+ endif ()
155+
148156# STATIC LIBRARY
149157if (WAMR_BUILD_STATIC)
150158 add_library (iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE} )
@@ -155,6 +163,14 @@ if (WAMR_BUILD_STATIC)
155163 target_link_libraries (iwasm_static INTERFACE boringssl_crypto)
156164 endif ()
157165
166+ if (MINGW)
167+ target_link_libraries (iwasm_static PRIVATE ws2_32)
168+ endif ()
169+
170+ if (WIN32 )
171+ target_link_libraries (iwasm_static PRIVATE ntdll)
172+ endif ()
173+
158174 install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
159175endif ()
160176
@@ -169,9 +185,14 @@ if (WAMR_BUILD_SHARED)
169185 endif ()
170186
171187 if (MINGW)
172- target_link_libraries (iwasm_shared INTERFACE -lWs2_32 -lwsock32)
188+ target_link_libraries (iwasm_shared INTERFACE -lWs2_32 -lwsock32)
189+ target_link_libraries (iwasm_shared PRIVATE ws2_32)
173190 endif ()
174191
192+ if (WIN32 )
193+ target_link_libraries (iwasm_shared PRIVATE ntdll)
194+ endif ()
195+
175196 install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
176197endif ()
177198
0 commit comments