diff options
author | Oxore <oxore@protonmail.com> | 2025-01-04 22:56:24 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2025-01-04 22:58:43 +0300 |
commit | ca8f17077af731cea01234530bf8c528481c7876 (patch) | |
tree | daf214bb4df75d3339c6c8b7255544e49aa49154 /simple-c/CMakeLists.txt |
Diffstat (limited to 'simple-c/CMakeLists.txt')
-rw-r--r-- | simple-c/CMakeLists.txt | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/simple-c/CMakeLists.txt b/simple-c/CMakeLists.txt new file mode 100644 index 0000000..db41628 --- /dev/null +++ b/simple-c/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 3.20) +project("simple-c") + +find_package(BISON REQUIRED) +find_package(FLEX REQUIRED) + +if (WIN32) + set (ADDITIONAL_FLEX_FLAGS "--wincompat") +else() + set (ADDITIONAL_FLEX_FLAGS "") +endif() + +flex_target(lexer + lexer.l + ${CMAKE_CURRENT_BINARY_DIR}/lexer.c + DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/lexer.h + COMPILE_FLAGS ${ADDITIONAL_FLEX_FLAGS} +) + +bison_target(parser + parser.y + ${CMAKE_CURRENT_BINARY_DIR}/parser.c + COMPILE_FLAGS "-d -v" +) + +add_flex_bison_dependency(lexer parser) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) + +set(source_files + ${CMAKE_CURRENT_BINARY_DIR}/parser.c + ${CMAKE_CURRENT_BINARY_DIR}/lexer.c +) + +add_executable(${PROJECT_NAME} ${source_files} ${BISON_PARSER_OUTPUTS} ${FLEX_LEXER_OUTPUTS}) |