Skip to content

Commit 47f18d0

Browse files
committed
Add versioning support and update CMake configuration
1 parent 1d111a3 commit 47f18d0

File tree

6 files changed

+67
-0
lines changed

6 files changed

+67
-0
lines changed

CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ if (WAMR_BUILD_STATIC)
172172
target_link_libraries(iwasm_static PRIVATE ntdll)
173173
endif()
174174

175+
set_version_info (iwasm_static)
175176
install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
176177
endif ()
177178

@@ -194,6 +195,7 @@ if (WAMR_BUILD_SHARED)
194195
target_link_libraries(iwasm_shared PRIVATE ntdll)
195196
endif()
196197

198+
set_version_info (iwasm_shared)
197199
install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
198200
endif ()
199201

@@ -202,4 +204,5 @@ install (FILES
202204
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h
203205
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h
204206
${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h
207+
${WAMR_ROOT_DIR}/core/version.h
205208
DESTINATION include)

build-scripts/config_common.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ else ()
131131
unset (LLVM_AVAILABLE_LIBS)
132132
endif ()
133133

134+
# Version
135+
include (${WAMR_ROOT_DIR}/build-scripts/version.cmake)
136+
134137
# Sanitizers
135138

136139
if (NOT DEFINED WAMR_BUILD_SANITIZER)

build-scripts/version.cmake

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
# BE AWARE: This file depends on ${WAMR_ROOT_DIR}
5+
6+
set(WAMR_VERSION_MAJOR 2)
7+
set(WAMR_VERSION_MINOR 2)
8+
set(WAMR_VERSION_PATCH 0)
9+
10+
message("-- WAMR version: ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}")
11+
12+
# Configure the version header file
13+
configure_file(
14+
${WAMR_ROOT_DIR}/core/version.h.in
15+
${WAMR_ROOT_DIR}/core/version.h
16+
)
17+
18+
# Set the library version and SOVERSION
19+
function(set_version_info target)
20+
set_target_properties(${target}
21+
PROPERTIES
22+
VERSION ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}
23+
SOVERSION ${WAMR_VERSION_MAJOR}
24+
)
25+
endfunction()

core/version.h

+11
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@
33
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
*/
55

6+
/*
7+
* version.h.in is a template file. version.h is a generated file.
8+
* Please do not edit both files directly.
9+
*
10+
* Any changes to the version should be done in the version.cmake file.
11+
*/
12+
613
#ifndef _WAMR_VERSION_H_
714
#define _WAMR_VERSION_H_
15+
16+
/* clang-format off */
817
#define WAMR_VERSION_MAJOR 2
918
#define WAMR_VERSION_MINOR 2
1019
#define WAMR_VERSION_PATCH 0
20+
/* clang-format on */
21+
1122
#endif

core/version.h.in

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
*/
5+
6+
/*
7+
* version.h.in is a template file. version.h is a generated file.
8+
* Please do not edit both files directly.
9+
*
10+
* Any changes to the version should be done in the version.cmake file.
11+
*/
12+
13+
#ifndef _WAMR_VERSION_H_
14+
#define _WAMR_VERSION_H_
15+
16+
/* clang-format off */
17+
#define WAMR_VERSION_MAJOR @WAMR_VERSION_MAJOR@
18+
#define WAMR_VERSION_MINOR @WAMR_VERSION_MINOR@
19+
#define WAMR_VERSION_PATCH @WAMR_VERSION_PATCH@
20+
/* clang-format on */
21+
22+
#endif

product-mini/platforms/linux/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
142142
check_pie_supported()
143143
add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
144144
set_target_properties (vmlib PROPERTIES POSITION_INDEPENDENT_CODE ON)
145+
set_version_info (vmlib)
145146

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

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

171172
add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE})
173+
set_version_info (iwasm)
172174

173175
set_target_properties (iwasm PROPERTIES POSITION_INDEPENDENT_CODE ON)
174176

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

186188
add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE})
189+
set_version_info (libiwasm)
187190

188191
install (TARGETS libiwasm DESTINATION lib)
189192

0 commit comments

Comments
 (0)