Cmake improvements (#4076)
- Utilizes the standard CMake variable BUILD_SHARED_LIBS to simplify the CMake configuration. - Allows the use of a single library definition for both static and shared library cases, improving maintainability and readability of the CMake configuration. - Install vmlib public header files - Installs the public header files for the vmlib target to the include/iwasm directory. - Install cmake package - Adds the necessary CMake configuration files (iwasmConfig.cmake and iwasmConfigVersion.cmake). - Configures the installation of these files to the appropriate directory (lib/cmake/iwasm). - Ensures compatibility with the same major version. - Improve windows product-mini CMakeLists.txt - Fix missing symbols when linking windows product-mini with shared vmlib - Improve Darwin product-mini CMakeLists.txt --------- Signed-off-by: Peter Tatrai <peter.tatrai.ext@siemens.com>
This commit is contained in:
@ -6,6 +6,8 @@ cmake_minimum_required (VERSION 2.9)
|
||||
project (iwasm C ASM CXX)
|
||||
# set (CMAKE_VERBOSE_MAKEFILE 1)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
||||
|
||||
set (WAMR_BUILD_PLATFORM "windows")
|
||||
|
||||
# Reset default linker flags
|
||||
@ -105,8 +107,6 @@ endif()
|
||||
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
||||
|
||||
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
|
||||
add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
|
||||
set_version_info(vmlib)
|
||||
|
||||
#set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN")
|
||||
if (NOT MINGW)
|
||||
@ -133,34 +133,46 @@ endif ()
|
||||
|
||||
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
|
||||
|
||||
add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE})
|
||||
add_executable (iwasm main.c ${PLATFORM_SHARED_SOURCE} ${UNCOMMON_SHARED_SOURCE} ${UTILS_SHARED_SOURCE})
|
||||
|
||||
set_version_info (iwasm)
|
||||
|
||||
install (TARGETS iwasm DESTINATION bin)
|
||||
|
||||
target_link_libraries (iwasm vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS})
|
||||
target_link_libraries (iwasm vmlib)
|
||||
|
||||
add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE})
|
||||
set_version_info (vmlib)
|
||||
|
||||
target_include_directories(vmlib INTERFACE
|
||||
$<INSTALL_INTERFACE:include/iwasm>
|
||||
)
|
||||
|
||||
set (WAMR_PUBLIC_HEADERS
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h
|
||||
)
|
||||
|
||||
set_target_properties (vmlib PROPERTIES
|
||||
OUTPUT_NAME libiwasm
|
||||
PUBLIC_HEADER "${WAMR_PUBLIC_HEADERS}"
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
)
|
||||
|
||||
target_link_libraries (vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS})
|
||||
if (MINGW)
|
||||
target_link_libraries (iwasm ws2_32)
|
||||
endif ()
|
||||
|
||||
add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE})
|
||||
|
||||
set_version_info (libiwasm)
|
||||
|
||||
install (TARGETS libiwasm DESTINATION lib)
|
||||
|
||||
set_target_properties (libiwasm PROPERTIES OUTPUT_NAME libiwasm)
|
||||
|
||||
target_link_libraries (libiwasm ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS})
|
||||
|
||||
if (MINGW)
|
||||
target_link_libraries (libiwasm ws2_32)
|
||||
target_link_libraries (vmlib ws2_32)
|
||||
endif ()
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(libiwasm ntdll)
|
||||
|
||||
target_link_libraries(iwasm ntdll)
|
||||
target_link_libraries(vmlib ntdll)
|
||||
endif()
|
||||
|
||||
install (TARGETS vmlib
|
||||
EXPORT iwasmTargets
|
||||
DESTINATION lib
|
||||
PUBLIC_HEADER DESTINATION include/iwasm
|
||||
)
|
||||
|
||||
install_iwasm_package ()
|
||||
|
||||
Reference in New Issue
Block a user