|
| 1 | +cmake_minimum_required(VERSION 3.1) |
| 2 | + |
| 3 | +project("GodelScript" VERSION 0.1 DESCRIPTION "GodelScript compiler") |
| 4 | + |
| 5 | +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0") |
| 6 | +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0") |
| 7 | + |
| 8 | +set(CMAKE_CXX_STANDARD 17) |
| 9 | +set(CMAKE_CXX_STANDARD_REQUIRED True) |
| 10 | + |
| 11 | +if(UNIX AND NOT APPLE) |
| 12 | + set(LINUX TRUE) |
| 13 | +endif() |
| 14 | + |
| 15 | +set(GODEL_FRONTEND_HDR_FILES |
| 16 | + godel-frontend/src/cli.h |
| 17 | + godel-frontend/src/engine.h |
| 18 | + godel-frontend/src/lexer.h |
| 19 | + godel-frontend/src/parse.h |
| 20 | + godel-frontend/src/semantic.h |
| 21 | + godel-frontend/src/symbol.h |
| 22 | + godel-frontend/src/ir/aggregator_inline_remark.h |
| 23 | + godel-frontend/src/ir/flatten_block.h |
| 24 | + godel-frontend/src/ir/ir_gen.h |
| 25 | + godel-frontend/src/ir/ir_context.h |
| 26 | + godel-frontend/src/ir/lir.h |
| 27 | + godel-frontend/src/ir/inst_combine.h |
| 28 | + godel-frontend/src/ir/name_mangling.h |
| 29 | + godel-frontend/src/ir/pass.h |
| 30 | + godel-frontend/src/ir/pass_manager.h |
| 31 | + godel-frontend/src/ir/remove_unused.h |
| 32 | + godel-frontend/src/error/error.h |
| 33 | + godel-frontend/src/ast/ast_node.h |
| 34 | + godel-frontend/src/ast/ast_root.h |
| 35 | + godel-frontend/src/ast/ast_visitor.h |
| 36 | + godel-frontend/src/ast/decl.h |
| 37 | + godel-frontend/src/ast/expr.h |
| 38 | + godel-frontend/src/ast/stmt.h |
| 39 | + godel-frontend/src/ast/ast_dumper.h |
| 40 | + godel-frontend/src/ast/template_extractor.h |
| 41 | + godel-frontend/src/sema/ungrounded_checker.h |
| 42 | + godel-frontend/src/sema/fact_statement_checker.h |
| 43 | + godel-frontend/src/sema/self_reference_check.h |
| 44 | + godel-frontend/src/sema/context.h |
| 45 | + godel-frontend/src/sema/global_symbol_loader.h |
| 46 | + godel-frontend/src/sema/symbol_import.h |
| 47 | + godel-frontend/src/sema/data_structure_construct.h |
| 48 | + godel-frontend/src/sema/inherit_schema.h |
| 49 | + godel-frontend/src/sema/function_declaration.h |
| 50 | + godel-frontend/src/sema/annotation_checker.h |
| 51 | + godel-frontend/src/util/util.h |
| 52 | + godel-frontend/src/package/package.h |
| 53 | + godel-frontend/src/package/module_tree.h) |
| 54 | + |
| 55 | +set(GODEL_FRONTEND_SRC_FILES |
| 56 | + godel-frontend/src/cli.cpp |
| 57 | + godel-frontend/src/engine.cpp |
| 58 | + godel-frontend/src/lexer.cpp |
| 59 | + godel-frontend/src/parse.cpp |
| 60 | + godel-frontend/src/semantic.cpp |
| 61 | + godel-frontend/src/symbol.cpp |
| 62 | + godel-frontend/src/ir/aggregator_inline_remark.cpp |
| 63 | + godel-frontend/src/ir/flatten_block.cpp |
| 64 | + godel-frontend/src/ir/ir_gen.cpp |
| 65 | + godel-frontend/src/ir/ir_context.cpp |
| 66 | + godel-frontend/src/ir/lir.cpp |
| 67 | + godel-frontend/src/ir/inst_combine.cpp |
| 68 | + godel-frontend/src/ir/name_mangling.cpp |
| 69 | + godel-frontend/src/ir/pass.cpp |
| 70 | + godel-frontend/src/ir/pass_manager.cpp |
| 71 | + godel-frontend/src/ir/remove_unused.cpp |
| 72 | + godel-frontend/src/error/error.cpp |
| 73 | + godel-frontend/src/ast/ast_visitor.cpp |
| 74 | + godel-frontend/src/ast/ast_root.cpp |
| 75 | + godel-frontend/src/ast/decl.cpp |
| 76 | + godel-frontend/src/ast/expr.cpp |
| 77 | + godel-frontend/src/ast/stmt.cpp |
| 78 | + godel-frontend/src/ast/ast_dumper.cpp |
| 79 | + godel-frontend/src/ast/template_extractor.cpp |
| 80 | + godel-frontend/src/sema/ungrounded_checker.cpp |
| 81 | + godel-frontend/src/sema/fact_statement_checker.cpp |
| 82 | + godel-frontend/src/sema/self_reference_check.cpp |
| 83 | + godel-frontend/src/sema/context.cpp |
| 84 | + godel-frontend/src/sema/global_symbol_loader.cpp |
| 85 | + godel-frontend/src/sema/symbol_import.cpp |
| 86 | + godel-frontend/src/sema/data_structure_construct.cpp |
| 87 | + godel-frontend/src/sema/inherit_schema.cpp |
| 88 | + godel-frontend/src/sema/function_declaration.cpp |
| 89 | + godel-frontend/src/sema/annotation_checker.cpp |
| 90 | + godel-frontend/src/util/util.cpp |
| 91 | + godel-frontend/src/package/package.cpp |
| 92 | + godel-frontend/src/package/module_tree.cpp) |
| 93 | + |
| 94 | +execute_process(COMMAND mkdir -p install) |
| 95 | +set(ENV{CC} cc) |
| 96 | +set(ENV{CXX} c++) |
| 97 | +# build bison |
| 98 | +set(BISON_PKG bison-3.8.2) |
| 99 | +execute_process(COMMAND tar -xf ${CMAKE_CURRENT_SOURCE_DIR}/godel-backend/tools/${BISON_PKG}.tar) |
| 100 | +execute_process(COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/install WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${BISON_PKG}) |
| 101 | +execute_process(COMMAND make -j install WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${BISON_PKG}) |
| 102 | + |
| 103 | +# build flex |
| 104 | +set(FLEX_PKG flex-2.6.4) |
| 105 | +execute_process(COMMAND tar -xf ${CMAKE_CURRENT_SOURCE_DIR}/godel-backend/tools/${FLEX_PKG}.tar) |
| 106 | +execute_process(COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/install WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${FLEX_PKG}) |
| 107 | +execute_process(COMMAND make -j install WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${FLEX_PKG}) |
| 108 | + |
| 109 | +# set variables for souffle target |
| 110 | +set(FLEX_EXECUTABLE ${CMAKE_BINARY_DIR}/install/bin/flex) |
| 111 | +set(BISON_EXECUTABLE ${CMAKE_BINARY_DIR}/install/bin/bison) |
| 112 | + |
| 113 | +set(SOUFFLE_DOMAIN_64BIT ON) |
| 114 | +set(SOUFFLE_USE_CURSES OFF) |
| 115 | +set(SOUFFLE_ENABLE_TESTING OFF) |
| 116 | + |
| 117 | +add_subdirectory(godel-backend/souffle) |
| 118 | +add_subdirectory(godel-backend/extension) |
| 119 | + |
| 120 | +add_library(godel-frontend STATIC |
| 121 | + ${GODEL_FRONTEND_SRC_FILES}) |
| 122 | + |
| 123 | +target_link_libraries(godel-frontend PUBLIC |
| 124 | + libsouffle souffle_ext) |
| 125 | + |
| 126 | +target_include_directories(godel-frontend PUBLIC |
| 127 | + ${PROJECT_SOURCE_DIR}) |
| 128 | + |
| 129 | +# add binary target godel |
| 130 | +add_executable(godel godel-frontend/src/main.cpp) |
| 131 | +# avoid easylogging to generate myeasylog.log automatically |
| 132 | +add_definitions(-DELPP_NO_DEFAULT_LOG_FILE) |
| 133 | +# link static library |
| 134 | +target_link_libraries(godel |
| 135 | + PRIVATE godel-frontend) |
| 136 | +# link dynamic library |
| 137 | +target_link_libraries(godel PUBLIC |
| 138 | + libsouffle-shared souffle_ext) |
0 commit comments