Parcourir la source

Enhance cmake makefiles (#1390)

Upgrade `cmake_minimum_required` from `(VERSION 2.8)` to `(VERSION 2.9)` to
yield the warning:
"Compatibility with CMake < 2.8.12 will be removed from a future version of CMake"

Add "-Wno-unused" for CMAKE_CXX_FLAGS to yield the compilation warnings
when build LLVM JIT.

Fix the link error when code coverage is enabled.
Wenyong Huang il y a 3 ans
Parent
commit
9cf7b88bad

+ 13 - 4
CMakeLists.txt

@@ -1,10 +1,11 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8...3.16)
+cmake_minimum_required (VERSION 2.9)
 
 
 project (iwasm)
 project (iwasm)
-# set (CMAKE_VERBOSE_MAKEFILE 1)
+
+set (CMAKE_VERBOSE_MAKEFILE OFF)
 
 
 string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
 string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
 
 
@@ -52,6 +53,11 @@ if (NOT DEFINED WAMR_BUILD_JIT)
   set (WAMR_BUILD_JIT 0)
   set (WAMR_BUILD_JIT 0)
 endif ()
 endif ()
 
 
+if (NOT DEFINED WAMR_BUILD_FAST_JIT)
+  # Disable Fast JIT by default
+  set (WAMR_BUILD_FAST_JIT 0)
+endif ()
+
 if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN)
 if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN)
   # Enable libc builtin support by default
   # Enable libc builtin support by default
   set (WAMR_BUILD_LIBC_BUILTIN 1)
   set (WAMR_BUILD_LIBC_BUILTIN 1)
@@ -68,7 +74,7 @@ if (NOT DEFINED WAMR_BUILD_FAST_INTERP)
 endif ()
 endif ()
 
 
 if (NOT DEFINED WAMR_BUILD_MULTI_MODULE)
 if (NOT DEFINED WAMR_BUILD_MULTI_MODULE)
-  # Enable multiple modules
+  # Disable multiple modules by default
   set (WAMR_BUILD_MULTI_MODULE 0)
   set (WAMR_BUILD_MULTI_MODULE 0)
 endif ()
 endif ()
 
 
@@ -94,6 +100,7 @@ endif ()
 
 
 if (COLLECT_CODE_COVERAGE EQUAL 1)
 if (COLLECT_CODE_COVERAGE EQUAL 1)
   set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
   set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
+  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
 endif ()
 endif ()
 
 
 set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
@@ -102,9 +109,11 @@ include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
 
 
 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
 
 
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
+set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow")
 # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
 # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
 
 
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
+
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 1 - 1
product-mini/platforms/darwin/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 project (iwasm)
 project (iwasm)
 
 

+ 1 - 1
product-mini/platforms/linux-sgx/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 project (iwasm)
 project (iwasm)
 
 

+ 1 - 1
product-mini/platforms/linux-sgx/CMakeLists_minimal.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 project (iwasm)
 project (iwasm)
 
 

+ 6 - 4
product-mini/platforms/linux/CMakeLists.txt

@@ -1,10 +1,11 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 project (iwasm)
 project (iwasm)
-# set (CMAKE_VERBOSE_MAKEFILE 1)
+
+set (CMAKE_VERBOSE_MAKEFILE OFF)
 
 
 set (WAMR_BUILD_PLATFORM "linux")
 set (WAMR_BUILD_PLATFORM "linux")
 
 
@@ -73,7 +74,7 @@ if (NOT DEFINED WAMR_BUILD_FAST_INTERP)
 endif ()
 endif ()
 
 
 if (NOT DEFINED WAMR_BUILD_MULTI_MODULE)
 if (NOT DEFINED WAMR_BUILD_MULTI_MODULE)
-  # Enable multiple modules
+  # Disable multiple modules by default
   set (WAMR_BUILD_MULTI_MODULE 0)
   set (WAMR_BUILD_MULTI_MODULE 0)
 endif ()
 endif ()
 
 
@@ -110,6 +111,7 @@ endif ()
 
 
 if (COLLECT_CODE_COVERAGE EQUAL 1)
 if (COLLECT_CODE_COVERAGE EQUAL 1)
   set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
   set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
+  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
 endif ()
 endif ()
 
 
 set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
 set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
@@ -122,7 +124,7 @@ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -f
 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow")
 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow")
 # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
 # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
 
 
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
 
 
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))

+ 1 - 1
product-mini/platforms/vxworks/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 project (iwasm)
 project (iwasm)
 
 

+ 1 - 1
product-mini/platforms/windows/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 project (iwasm C ASM CXX)
 project (iwasm C ASM CXX)
 enable_language(ASM_MASM)
 enable_language(ASM_MASM)

+ 1 - 1
samples/basic/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows")
 if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows")
   project (basic)
   project (basic)

+ 1 - 1
samples/gui/wasm-runtime-wgl/linux-build/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 project (wasm_runtime_wgl)
 project (wasm_runtime_wgl)
 
 

+ 1 - 1
samples/littlevgl/vgl-native-ui-app/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8.2)
+cmake_minimum_required (VERSION 2.9)
 message ("vgl_native_ui_app...")
 message ("vgl_native_ui_app...")
 project (vgl_native_ui_app)
 project (vgl_native_ui_app)
 
 

+ 1 - 1
samples/littlevgl/vgl-wasm-runtime/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 project (vgl_wasm_runtime)
 project (vgl_wasm_runtime)
 
 

+ 1 - 1
samples/ref-types/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation. All rights reserved.
 # Copyright (C) 2019 Intel Corporation. All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows")
 if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows")
   project(ref-types)
   project(ref-types)

+ 1 - 1
samples/simple/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 project (simple)
 project (simple)
 
 

+ 1 - 1
samples/wasm-c-api/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation. All rights reserved.
 # Copyright (C) 2019 Intel Corporation. All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows")
 if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows")
   project(c-api)
   project(c-api)

+ 1 - 1
test-tools/binarydump-tool/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # Copyright (C) 2019 Intel Corporation.  All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 project(binarydump)
 project(binarydump)
 
 

+ 1 - 1
test-tools/host-tool/CMakeLists.txt

@@ -2,7 +2,7 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 #
 #
 
 
-cmake_minimum_required (VERSION 2.8.3)
+cmake_minimum_required (VERSION 2.9)
 project (host-agent)
 project (host-agent)
 
 
 if (NOT CMAKE_BUILD_TYPE)
 if (NOT CMAKE_BUILD_TYPE)

+ 1 - 1
wamr-compiler/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Copyright (C) 2019 Intel Corporation. All rights reserved.
 # Copyright (C) 2019 Intel Corporation. All rights reserved.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 2.9)
 
 
 string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
 string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)