cmake.patch 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index fbea2616..a1952ca8 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -108,16 +108,12 @@ endif ()
  6. set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
  7. # Set the strip command based on the system (GNU or Clang)
  8. -if (CMAKE_STRIP)
  9. - set (CMAKE_STRIP_FLAGS "--strip-all")
  10. -endif ()
  11. +
  12. include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
  13. -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow -Wno-unused-parameter")
  14. # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
  15. -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
  16. if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
  17. if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
  18. @@ -134,42 +130,37 @@ endif ()
  19. #set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack,-z,relro,-z,now")
  20. include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
  21. -
  22. +if (NOT BUILD_SHARED_LIBS)
  23. # STATIC LIBRARY
  24. add_library(iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE})
  25. set_target_properties (iwasm_static PROPERTIES OUTPUT_NAME vmlib)
  26. target_include_directories(iwasm_static INTERFACE ${WAMR_ROOT_DIR}/core/iwasm/include)
  27. -target_link_libraries (iwasm_static INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread)
  28. +target_link_libraries (iwasm_static INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS})
  29. if (WAMR_BUILD_WASM_CACHE EQUAL 1)
  30. target_link_libraries(iwasm_static INTERFACE boringssl_crypto)
  31. endif ()
  32. install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
  33. -# If it's a Release build, strip the static library
  34. -if (CMAKE_STRIP AND CMAKE_BUILD_TYPE STREQUAL "Release")
  35. - # Strip static library
  36. - message (STATUS "Stripping static library after build!")
  37. - add_custom_command (TARGET iwasm_static POST_BUILD
  38. - COMMAND ${CMAKE_STRIP} ${CMAKE_STRIP_FLAGS} $<TARGET_FILE:iwasm_static>
  39. - )
  40. -endif ()
  41. +else ()
  42. # SHARED LIBRARY
  43. add_library (iwasm_shared SHARED ${WAMR_RUNTIME_LIB_SOURCE})
  44. set_target_properties (iwasm_shared PROPERTIES OUTPUT_NAME iwasm)
  45. target_include_directories(iwasm_shared INTERFACE ${WAMR_ROOT_DIR}/core/iwasm/include)
  46. -target_link_libraries (iwasm_shared INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread)
  47. +target_link_libraries (iwasm_shared INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS})
  48. if (WAMR_BUILD_WASM_CACHE EQUAL 1)
  49. target_link_libraries(iwasm_shared INTERFACE boringssl_crypto)
  50. endif ()
  51. -
  52. +if (WIN32)
  53. +target_link_libraries (iwasm_shared ntdll)
  54. +endif ()
  55. if (MINGW)
  56. target_link_libraries (iwasm_shared -lWs2_32)
  57. endif ()
  58. install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
  59. -
  60. +endif ()
  61. # HEADERS
  62. install (FILES
  63. ${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h
  64. @@ -177,11 +168,4 @@ install (FILES
  65. ${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h
  66. DESTINATION include)
  67. -# If it's a Release build, strip the shared library
  68. -if (CMAKE_STRIP AND CMAKE_BUILD_TYPE STREQUAL "Release")
  69. - # Strip shared library
  70. - message (STATUS "Stripping shared library after build!")
  71. - add_custom_command (TARGET iwasm_shared POST_BUILD
  72. - COMMAND ${CMAKE_STRIP} ${CMAKE_STRIP_FLAGS} $<TARGET_FILE:iwasm_shared>
  73. - )
  74. -endif ()
  75. +