From f49a5a24f79dba05df2e74e71589ad68da05b341 Mon Sep 17 00:00:00 2001 From: carl Date: Tue, 19 Feb 2019 00:37:26 +0800 Subject: [PATCH] * Initial support of CMake --- util/LLgen/CMakeLists.txt | 99 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 util/LLgen/CMakeLists.txt diff --git a/util/LLgen/CMakeLists.txt b/util/LLgen/CMakeLists.txt new file mode 100644 index 000000000..64e75c209 --- /dev/null +++ b/util/LLgen/CMakeLists.txt @@ -0,0 +1,99 @@ +cmake_minimum_required (VERSION 2.9) +project(LLgen) + +enable_testing() + +set(SRC + src/main.c + src/gencode.c + src/compute.c + src/LLgen.c + src/tokens.c + src/check.c + src/reach.c + src/global.c + src/name.c + src/sets.c + src/Lpars.c + src/alloc.c + src/machdep.c + src/cclass.c + src/savegram.c + src/cclass.h + src/extern.h + src/io.h + src/Lpars.h + src/sets.h + src/types.h +) + +set(INCLUDE_DIRS src) + +include_directories(${INCLUDE_DIRS}) + +add_executable(${PROJECT_NAME} ${SRC}) +target_compile_definitions(${PROJECT_NAME} PUBLIC NDEBUG=1 NON_CORRECTING=1 NORCSID=1) + +# Correcting version. +add_executable(llgen_c ${SRC}) +target_compile_definitions(llgen_c PUBLIC NORCSID=1) + +file(COPY lib DESTINATION .) + +############################################# +# Regenerate the actual grammar files +############################################# +add_custom_target(regenerate + COMMAND + ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/src/tokens.g + ${CMAKE_CURRENT_BINARY_DIR}/tokens.g + COMMAND + ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/src/Llgen.g + ${CMAKE_CURRENT_BINARY_DIR}/Llgen.g + COMMAND ${PROJECT_NAME} -vvv tokens.g LLgen.g + COMMAND + ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/Llgen.c ${CMAKE_CURRENT_SOURCE_DIR}/src/LLgen.c + COMMAND + ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/tokens.c ${CMAKE_CURRENT_SOURCE_DIR}/src/tokens.c + COMMAND + ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/Lpars.c ${CMAKE_CURRENT_SOURCE_DIR}/src/Lpars.c + COMMAND + ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/Lpars.h ${CMAKE_CURRENT_SOURCE_DIR}/src/Lpars.h + COMMENT "Regenerate grammar files and copy them to source" +) +add_dependencies(regenerate ${PROJECT_NAME}) + + + + +############################################# +# Test targets +############################################# + +# Try to rebuild the own LLgen grammar. +add_test(NAME llgentest COMMAND ${PROJECT_NAME} -vvv + ${CMAKE_CURRENT_SOURCE_DIR}/src/tokens.g + ${CMAKE_CURRENT_SOURCE_DIR}/src/LLgen.g) + +############################################ +# Install targets +############################################# + +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/LLgen.1 DESTINATION man OPTIONAL) +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/lib/incl + ${CMAKE_CURRENT_SOURCE_DIR}/lib/nc_incl + ${CMAKE_CURRENT_SOURCE_DIR}/lib/nc_rec + ${CMAKE_CURRENT_SOURCE_DIR}/lib/rec + DESTINATION lib) + \ No newline at end of file