CMakeLists.txt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. project(c_embed_test)
  15. cmake_minimum_required(VERSION 3.14)
  16. include(CheckPIESupported)
  17. string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
  18. if (APPLE)
  19. add_definitions(-DBH_PLATFORM_DARWIN)
  20. endif ()
  21. set (CMAKE_C_STANDARD 99)
  22. set (CMAKE_CXX_STANDARD 17)
  23. set(WAMR_BUILD_TARGET "X86_64")
  24. set(WAMR_BUILD_INTERP 1)
  25. set(WAMR_BUILD_FAST_INTERP 0)
  26. set(WAMR_BUILD_AOT 0)
  27. set(WAMR_BUILD_LIBC_BUILTIN 1)
  28. set(WAMR_BUILD_LIBC_WASI 1)
  29. set(WAMR_BUILD_SIMD 1)
  30. set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../..)
  31. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
  32. if (NOT WAMR_BUILD_PLATFORM STREQUAL "darwin")
  33. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
  34. endif ()
  35. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow")
  36. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
  37. # build out vmlib
  38. include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
  39. add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
  40. # application related
  41. include(${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
  42. add_executable(c_embed_test src/main.c ${UNCOMMON_SHARED_SOURCE})
  43. target_link_libraries(c_embed_test vmlib m ${LLVM_AVAILABLE_LIBS})
  44. add_custom_command(TARGET c_embed_test POST_BUILD
  45. COMMAND ${CMAKE_COMMAND} -E copy
  46. ${CMAKE_CURRENT_LIST_DIR}/../wasm-apps/mytest.wasm ${CMAKE_CURRENT_LIST_DIR}/../wasm-apps/hello.wasm
  47. ${CMAKE_CURRENT_BINARY_DIR}
  48. COMMENT "Copy main.wasm and hello.wasm to the build directory"
  49. )