Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add versioning support and update CMake configuration #3933

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,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 @@ -194,6 +195,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 @@ -202,4 +204,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
Loading