summaryrefslogtreecommitdiff
path: root/simple-c/CMakeLists.txt
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2025-01-04 22:56:24 +0300
committerOxore <oxore@protonmail.com>2025-01-04 22:58:43 +0300
commitca8f17077af731cea01234530bf8c528481c7876 (patch)
treedaf214bb4df75d3339c6c8b7255544e49aa49154 /simple-c/CMakeLists.txt
Initial commitHEADmaster
Diffstat (limited to 'simple-c/CMakeLists.txt')
-rw-r--r--simple-c/CMakeLists.txt38
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})