diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c879949..8f8a73c7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,10 +109,8 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
 include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
 
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow -Wno-unused-parameter")
 # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
 
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
 
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
@@ -131,31 +129,34 @@ endif ()
 include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
 
 # STATIC LIBRARY
+if (NOT BUILD_SHARED_LIBS)
 add_library(iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE})
 set_target_properties (iwasm_static PROPERTIES OUTPUT_NAME vmlib)
 target_include_directories(iwasm_static INTERFACE ${WAMR_ROOT_DIR}/core/iwasm/include)
-target_link_libraries (iwasm_static INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread)
+target_link_libraries (iwasm_static INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS})
 if (WAMR_BUILD_WASM_CACHE EQUAL 1)
   target_link_libraries(iwasm_static INTERFACE boringssl_crypto)
 endif ()
 
 install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
-
+else ()
 # SHARED LIBRARY
 add_library (iwasm_shared SHARED ${WAMR_RUNTIME_LIB_SOURCE})
 set_target_properties (iwasm_shared PROPERTIES OUTPUT_NAME iwasm)
 target_include_directories(iwasm_shared INTERFACE ${WAMR_ROOT_DIR}/core/iwasm/include)
-target_link_libraries (iwasm_shared INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread)
+target_link_libraries (iwasm_shared INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS})
 if (WAMR_BUILD_WASM_CACHE EQUAL 1)
   target_link_libraries(iwasm_shared INTERFACE boringssl_crypto)
 endif ()
-
+if (WIN32)
+  target_link_libraries (iwasm_shared ntdll)
+endif ()
 if (MINGW)
   target_link_libraries (iwasm_shared -lWs2_32)
 endif ()
 
 install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
-
+endif ()
 # HEADERS
 install (FILES
     ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h
