32
32
33
33
cmake_minimum_required (VERSION 3.5 )
34
34
35
+ cmake_policy (SET CMP0079 NEW )
36
+
37
+ # Include the NuttX kconfig parser to shared the configuration between the NuttX
38
+ # build and the Wasm build. And then parse the input KCONFIG_FILE_PATH to get
39
+ # the configuration.
40
+ include (${TOPDIR} /cmake/nuttx_kconfig.cmake )
41
+
42
+ # Parse the input KCONFIG_FILE_PATH to get the configuration.
43
+ nuttx_export_kconfig (${KCONFIG_FILE_PATH} )
44
+
45
+ # Include the WASI-SDK.cmake file to setup the necessary flags for building
35
46
include (WASI-SDK.cmake )
36
47
37
48
project (WasmApps )
38
49
50
+ # Add the wasm_interface library to hold all the Wasm libraries.
51
+ add_library (wasm_interface INTERFACE )
52
+
39
53
# Check whether the APPDIR is defined or not. If not, then set it to the parent
40
54
# directory of the current CMakeLists.txt file.
41
55
if (NOT DEFINED APPDIR )
@@ -47,18 +61,21 @@ if(NOT DEFINED TOPDIR)
47
61
message (FATAL_ERROR "TOPDIR is not defined" )
48
62
endif ()
49
63
64
+ # Check wether the TOPBINDIR is defined or not. If not, then raise an error.
65
+ if (NOT DEFINED TOPBINDIR )
66
+ message (FATAL_ERROR "TOPBINDIR is not defined" )
67
+ endif ()
68
+
69
+ if (NOT EXISTS ${TOPBINDIR} /wasm )
70
+ file (MAKE_DIRECTORY ${TOPBINDIR} /wasm )
71
+ endif ()
72
+
50
73
# Check wether the KCONFIG_FILE_PATH is defined or not. If not, then raise an
51
74
# error.
52
75
if (NOT DEFINED KCONFIG_FILE_PATH )
53
76
message (FATAL_ERROR "KCONFIG_FILE_PATH is not defined" )
54
77
endif ()
55
78
56
- # Include the NuttX kconfig parser to shared the configuration between the NuttX
57
- # build and the Wasm build. And then parse the input KCONFIG_FILE_PATH to get
58
- # the configuration.
59
- include (${TOPDIR} /cmake/nuttx_kconfig.cmake )
60
- nuttx_export_kconfig (${KCONFIG_FILE_PATH} )
61
-
62
79
# Provide FAR macro from command line since it is not supported in wasi-sdk, but
63
80
# it is used in NuttX code.
64
81
# ~~~
@@ -78,25 +95,11 @@ function(nuttx_add_library)
78
95
79
96
endfunction ()
80
97
81
- # Recursively find all the CMakeLists.txt files in the ${APPDIR} and add it by
82
- # add_subdirectory, but exclude the CMakeLists.txt file in the ${APPDIR}/tools
83
- # directory.
84
- file (GLOB_RECURSE WASM_APPS ${APPDIR} /*/CMakeLists.txt )
85
- list (FILTER WASM_APPS EXCLUDE REGEX ".*/tools/.*" )
86
-
87
- # Read and check if wasm_add_application is called in the CMakeLists.txt file in
88
- # WASM_APPS If true, then add the directory to the build process
89
- foreach (WASM_APP ${WASM_APPS} )
90
- file (READ ${WASM_APP} WASM_APP_CONTENTS )
91
- string (FIND "${WASM_APP_CONTENTS} " "wasm_add_application" WASM_APP_FOUND )
92
- string (FIND "${WASM_APP_CONTENTS} " "wasm_add_library" WASM_LIB_FOUND )
93
- if (WASM_APP_FOUND GREATER -1 OR WASM_LIB_FOUND GREATER -1 )
94
- get_filename_component (WASM_APP_DIR ${WASM_APP} DIRECTORY )
95
- # Add subdirectory to the build process and put the build directory in the
96
- # current build directory with the name same as the relative path of the
97
- # ${APPDIR}
98
- string (REPLACE ${APPDIR} "" WASM_APP_BUILD_DIR ${WASM_APP_DIR} )
99
- add_subdirectory (${WASM_APP_DIR}
100
- ${CMAKE_CURRENT_BINARY_DIR} /Wasm/${WASM_APP_BUILD_DIR} )
101
- endif ()
98
+ # ~~~
99
+ # Add all the Wasm apps to the build process.
100
+ foreach (WASM_APP ${WASM_DIRS} )
101
+ string (REPLACE ${APPDIR} "" WASM_APP_BUILD_DIR ${WASM_APP} )
102
+ add_subdirectory (${WASM_APP}
103
+ ${CMAKE_CURRENT_BINARY_DIR} /Wasm/${WASM_APP_BUILD_DIR} )
102
104
endforeach ()
105
+ # ~~~
0 commit comments