|
1 | 1 | # Copyright (C) 2019 Intel Corporation. All rights reserved. |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
3 | 3 |
|
4 | | -cmake_minimum_required (VERSION 3.14) |
| 4 | +cmake_minimum_required(VERSION 3.14) |
5 | 5 |
|
6 | 6 | include(CheckPIESupported) |
7 | 7 |
|
8 | | -if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows") |
9 | | - project (custom_section) |
| 8 | +if(NOT WAMR_BUILD_PLATFORM STREQUAL "windows") |
| 9 | + project(custom_section) |
10 | 10 | else() |
11 | | - project (custom_section C ASM) |
| 11 | + project(custom_section C ASM) |
12 | 12 | endif() |
13 | 13 |
|
14 | | -################ runtime settings ################ |
15 | | -string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) |
16 | | -if (APPLE) |
| 14 | +# ############### runtime settings ################ |
| 15 | +string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) |
| 16 | + |
| 17 | +if(APPLE) |
17 | 18 | add_definitions(-DBH_PLATFORM_DARWIN) |
18 | | -endif () |
19 | | - |
20 | | -set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") |
21 | | -set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") |
22 | | - |
23 | | -if (NOT DEFINED WAMR_BUILD_TARGET) |
24 | | - if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)") |
25 | | - set (WAMR_BUILD_TARGET "AARCH64") |
26 | | - elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64") |
27 | | - set (WAMR_BUILD_TARGET "RISCV64") |
28 | | - elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) |
29 | | - set (WAMR_BUILD_TARGET "X86_64") |
30 | | - elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) |
31 | | - set (WAMR_BUILD_TARGET "X86_32") |
32 | | - else () |
| 19 | +endif() |
| 20 | + |
| 21 | +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") |
| 22 | +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") |
| 23 | + |
| 24 | +if(NOT DEFINED WAMR_BUILD_TARGET) |
| 25 | + if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)") |
| 26 | + set(WAMR_BUILD_TARGET "AARCH64") |
| 27 | + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64") |
| 28 | + set(WAMR_BUILD_TARGET "RISCV64") |
| 29 | + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 30 | + set(WAMR_BUILD_TARGET "X86_64") |
| 31 | + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) |
| 32 | + set(WAMR_BUILD_TARGET "X86_32") |
| 33 | + else() |
33 | 34 | message(SEND_ERROR "Unsupported build target platform!") |
34 | | - endif () |
35 | | -endif () |
| 35 | + endif() |
| 36 | +endif() |
36 | 37 |
|
37 | | -if (NOT CMAKE_BUILD_TYPE) |
38 | | - set (CMAKE_BUILD_TYPE Debug) |
39 | | -endif () |
| 38 | +if(NOT CMAKE_BUILD_TYPE) |
| 39 | + set(CMAKE_BUILD_TYPE Debug) |
| 40 | +endif() |
40 | 41 |
|
41 | | -set (WAMR_BUILD_INTERP 1) |
42 | | -set (WAMR_BUILD_AOT 1) |
43 | | -set (WAMR_BUILD_JIT 0) |
44 | | -set (WAMR_BUILD_LIBC_BUILTIN 1) |
45 | | -set (WAMR_BUILD_LOAD_CUSTOM_SECTION 1) |
| 42 | +set(WAMR_BUILD_INTERP 1) |
| 43 | +set(WAMR_BUILD_AOT 1) |
| 44 | +set(WAMR_BUILD_JIT 0) |
| 45 | +set(WAMR_BUILD_LIBC_BUILTIN 1) |
| 46 | +set(WAMR_BUILD_LOAD_CUSTOM_SECTION 1) |
46 | 47 |
|
47 | | -if (NOT MSVC) |
48 | | - set (WAMR_BUILD_LIBC_WASI 1) |
49 | | -endif () |
| 48 | +if(NOT MSVC) |
| 49 | + set(WAMR_BUILD_LIBC_WASI 1) |
| 50 | +endif() |
50 | 51 |
|
51 | | -if (NOT MSVC) |
52 | | - if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")) |
53 | | - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") |
54 | | - endif () |
55 | | -endif () |
| 52 | +if(NOT MSVC) |
| 53 | + if(NOT(CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")) |
| 54 | + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") |
| 55 | + endif() |
| 56 | +endif() |
56 | 57 |
|
57 | | -set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..) |
58 | | -include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) |
| 58 | +set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..) |
| 59 | +include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) |
59 | 60 |
|
60 | 61 | add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) |
61 | 62 |
|
62 | | -################ application related ################ |
| 63 | +# ############### application related ################ |
63 | 64 | include_directories(${CMAKE_CURRENT_LIST_DIR}/src) |
64 | | -include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) |
| 65 | +include(${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) |
65 | 66 |
|
66 | | -add_executable (custom_section |
| 67 | +add_executable(custom_section |
67 | 68 | src/main.c |
68 | 69 | src/native_impl.c |
69 | 70 | ${UNCOMMON_SHARED_SOURCE} |
70 | 71 | ) |
71 | 72 |
|
72 | 73 | check_pie_supported() |
73 | | -set_target_properties (custom_section PROPERTIES POSITION_INDEPENDENT_CODE ON) |
| 74 | +set_target_properties(custom_section PROPERTIES POSITION_INDEPENDENT_CODE ON) |
74 | 75 |
|
75 | | -if (APPLE) |
76 | | - target_link_libraries (custom_section vmlib -lm -ldl -lpthread) |
77 | | -else () |
78 | | - target_link_libraries (custom_section vmlib -lm -ldl -lpthread -lrt) |
79 | | -endif () |
| 76 | +if(APPLE) |
| 77 | + target_link_libraries(custom_section vmlib -lm -ldl -lpthread) |
| 78 | +else() |
| 79 | + target_link_libraries(custom_section vmlib -lm -ldl -lpthread -lrt) |
| 80 | +endif() |
0 commit comments