@@ -16,6 +16,13 @@ if (NOT DEFINED WAMR_BUILD_PLATFORM)
1616 string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
1717endif ()
1818
19+ if (NOT DEFINED WAMR_BUILD_STATIC)
20+ set (WAMR_BUILD_STATIC 1)
21+ endif ()
22+ if (NOT DEFINED WAMR_BUILD_SHARED)
23+ set (WAMR_BUILD_SHARED 1)
24+ endif ()
25+
1926# Reset default linker flags
2027set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" )
2128set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "" )
@@ -136,30 +143,34 @@ endif ()
136143include (${SHARED_DIR} /utils/uncommon/shared_uncommon.cmake )
137144
138145# STATIC LIBRARY
139- add_library (iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE} )
140- set_target_properties (iwasm_static PROPERTIES OUTPUT_NAME vmlib )
141- target_include_directories (iwasm_static INTERFACE ${WAMR_ROOT_DIR} /core/iwasm/include )
142- target_link_libraries (iwasm_static INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread )
143- if (WAMR_BUILD_WASM_CACHE EQUAL 1)
144- target_link_libraries (iwasm_static INTERFACE boringssl_crypto )
145- endif ()
146+ if (WAMR_BUILD_STATIC)
147+ add_library (iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE} )
148+ set_target_properties (iwasm_static PROPERTIES OUTPUT_NAME vmlib )
149+ target_include_directories (iwasm_static INTERFACE ${WAMR_ROOT_DIR} /core/iwasm/include )
150+ target_link_libraries (iwasm_static INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread )
151+ if (WAMR_BUILD_WASM_CACHE EQUAL 1)
152+ target_link_libraries (iwasm_static INTERFACE boringssl_crypto )
153+ endif ()
146154
147- install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
155+ install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
156+ endif ()
148157
149158# SHARED LIBRARY
150- add_library (iwasm_shared SHARED ${WAMR_RUNTIME_LIB_SOURCE} )
151- set_target_properties (iwasm_shared PROPERTIES OUTPUT_NAME iwasm )
152- target_include_directories (iwasm_shared INTERFACE ${WAMR_ROOT_DIR} /core/iwasm/include )
153- target_link_libraries (iwasm_shared INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread )
154- if (WAMR_BUILD_WASM_CACHE EQUAL 1)
155- target_link_libraries (iwasm_shared INTERFACE boringssl_crypto )
156- endif ()
159+ if (WAMR_BUILD_SHARED)
160+ add_library (iwasm_shared SHARED ${WAMR_RUNTIME_LIB_SOURCE} )
161+ set_target_properties (iwasm_shared PROPERTIES OUTPUT_NAME iwasm )
162+ target_include_directories (iwasm_shared INTERFACE ${WAMR_ROOT_DIR} /core/iwasm/include )
163+ target_link_libraries (iwasm_shared INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread )
164+ if (WAMR_BUILD_WASM_CACHE EQUAL 1)
165+ target_link_libraries (iwasm_shared INTERFACE boringssl_crypto )
166+ endif ()
157167
158- if (MINGW)
159- target_link_libraries (iwasm_shared INTERFACE -lWs2_32 -lwsock32 )
160- endif ()
168+ if (MINGW)
169+ target_link_libraries (iwasm_shared INTERFACE -lWs2_32 -lwsock32 )
170+ endif ()
161171
162- install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
172+ install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
173+ endif ()
163174
164175# HEADERS
165176install (FILES
0 commit comments