summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt16
1 files changed, 15 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 17c70ec..12bc35a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -90,8 +90,22 @@ configure_file (${PROJECT_SOURCE_DIR}/config.h.in
${PROJECT_BINARY_DIR}/config.h)
include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
+# Assuming a Unix-compatible system with a standalone preprocessor
+set (actions ${PROJECT_BINARY_DIR}/nncmpp-actions.h)
+add_custom_command (OUTPUT ${actions}
+ COMMAND cpp -I${PROJECT_BINARY_DIR} -P ${PROJECT_SOURCE_DIR}/nncmpp.actions
+ | grep . | tr [[\n]] [[\t]] | sed -ne [[y/\t/\n/]] > ${actions}
+ -e [[h; s/,[^\n]*/,/g]] -e [[s/$/COUNT/]]
+ -e [[s/[^\n]*/\tACTION_&/g]] -e [[s/.*/enum action {\n&\n};\n/p]]
+ -e [[g; s/,[^\n]*//g; y/_/-/]] -e [[s/[^\n]\{1,\}/\t"&",/g]]
+ -e [[s/.*/static const char *g_action_names[] = {\n&};\n/p]]
+ -e [[g; s/[^\n]*, //g;]] -e [[s/[^\n]\{1,\}/\t"&",/g]]
+ -e [[s/.*/static const char *g_action_descriptions[] = {\n&};/p]]
+ COMMAND test -s ${actions}
+ DEPENDS ${PROJECT_BINARY_DIR}/config.h VERBATIM)
+
# Build the main executable and link it
-add_executable (${PROJECT_NAME} ${PROJECT_NAME}.c)
+add_executable (${PROJECT_NAME} ${PROJECT_NAME}.c ${actions})
target_link_libraries (${PROJECT_NAME} ${Unistring_LIBRARIES}
${Ncursesw_LIBRARIES} termo-static ${curl_LIBRARIES} ${extra_libraries})
add_threads (${PROJECT_NAME})