Skip to content

Commit

Permalink
Add versioning support and update CMake configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
lum1n0us committed Dec 23, 2024
1 parent 040e776 commit c38af70
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ if (WAMR_BUILD_STATIC)
target_link_libraries(iwasm_static PRIVATE ntdll)
endif()

set_version_info (iwasm_static)
install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
endif ()

Expand All @@ -196,6 +197,7 @@ if (WAMR_BUILD_SHARED)
target_link_libraries(iwasm_shared PRIVATE ntdll)
endif()

set_version_info (iwasm_shared)
install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
endif ()

Expand All @@ -204,4 +206,5 @@ install (FILES
${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
${WAMR_ROOT_DIR}/core/version.h
DESTINATION include)
3 changes: 3 additions & 0 deletions build-scripts/config_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ else ()
unset (LLVM_AVAILABLE_LIBS)
endif ()

# Version
include (${WAMR_ROOT_DIR}/build-scripts/version.cmake)

# Sanitizers

if (NOT DEFINED WAMR_BUILD_SANITIZER)
Expand Down
25 changes: 25 additions & 0 deletions build-scripts/version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# BE AWARE: This file depends on ${WAMR_ROOT_DIR}

set(WAMR_VERSION_MAJOR 2)
set(WAMR_VERSION_MINOR 2)
set(WAMR_VERSION_PATCH 0)

message("-- WAMR version: ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}")

# Configure the version header file
configure_file(
${WAMR_ROOT_DIR}/core/version.h.in
${WAMR_ROOT_DIR}/core/version.h
)

# Set the library version and SOVERSION
function(set_version_info target)
set_target_properties(${target}
PROPERTIES
VERSION ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}
SOVERSION ${WAMR_VERSION_MAJOR}
)
endfunction()
11 changes: 11 additions & 0 deletions core/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/

/*
* version.h.in is a template file. version.h is a generated file.
* Please do not edit both files directly.
*
* Any changes to the version should be done in the version.cmake file.
*/

#ifndef _WAMR_VERSION_H_
#define _WAMR_VERSION_H_

/* clang-format off */
#define WAMR_VERSION_MAJOR 2
#define WAMR_VERSION_MINOR 2
#define WAMR_VERSION_PATCH 0
/* clang-format on */

#endif
22 changes: 22 additions & 0 deletions core/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/

/*
* version.h.in is a template file. version.h is a generated file.
* Please do not edit both files directly.
*
* Any changes to the version should be done in the version.cmake file.
*/

#ifndef _WAMR_VERSION_H_
#define _WAMR_VERSION_H_

/* clang-format off */
#define WAMR_VERSION_MAJOR @WAMR_VERSION_MAJOR@
#define WAMR_VERSION_MINOR @WAMR_VERSION_MINOR@
#define WAMR_VERSION_PATCH @WAMR_VERSION_PATCH@
/* clang-format on */

#endif
3 changes: 3 additions & 0 deletions product-mini/platforms/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
check_pie_supported()
add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
set_target_properties (vmlib PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_version_info (vmlib)

set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")

Expand Down Expand Up @@ -169,6 +170,7 @@ endif ()
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)

add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE})
set_version_info (iwasm)

set_target_properties (iwasm PROPERTIES POSITION_INDEPENDENT_CODE ON)

Expand All @@ -184,6 +186,7 @@ target_link_libraries(iwasm
install (TARGETS iwasm DESTINATION bin)

add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE})
set_version_info (libiwasm)

install (TARGETS libiwasm DESTINATION lib)

Expand Down

0 comments on commit c38af70

Please sign in to comment.