aboutsummaryrefslogtreecommitdiff
path: root/toolchain/hasMainSymbol.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'toolchain/hasMainSymbol.cmake')
-rw-r--r--toolchain/hasMainSymbol.cmake10
1 files changed, 10 insertions, 0 deletions
diff --git a/toolchain/hasMainSymbol.cmake b/toolchain/hasMainSymbol.cmake
new file mode 100644
index 00000000..9a041e73
--- /dev/null
+++ b/toolchain/hasMainSymbol.cmake
@@ -0,0 +1,10 @@
+execute_process(COMMAND nm --dynamic ${TARGET} ERROR_VARIABLE nm_errors OUTPUT_VARIABLE out RESULT_VARIABLE result)
+
+if (NOT result EQUAL 0)
+ message(FATAL_ERROR "nm failed on ${TARGET} exit(${result}): ${nm_errors}")
+endif()
+
+string(FIND ${out} " T main\n" found)
+if(found LESS 0)
+ message(FATAL_ERROR "Could not find a main() symbol on ${TARGET}")
+endif()