Skip to content

Commit

Permalink
Refine codegen selection and remove backend's dependency on frontend (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vla5924 authored Apr 28, 2024
1 parent 8084aff commit b7d9c41
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
9 changes: 9 additions & 0 deletions compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ set(COMPILER_LIB_DIR ${CMAKE_SOURCE_DIR}/lib)

set(ENABLE_CODEGEN "" CACHE STRING "Enables low-level code generation")
set(AVAILABLE_CODEGEN "ast_to_llvmir")
if("${ENABLE_CODEGEN}^" STREQUAL "OFF^")
message(WARNING "All codegen backends were disabled because ENABLE_CODEGEN option was set to OFF. "
"Consider omitting its setting or using an empty string instead.")
set(ENABLE_CODEGEN "")
elseif("${ENABLE_CODEGEN}^" STREQUAL "ON^")
message(WARNING "All codegen backends were enabled because ENABLE_CODEGEN option was set to ON. "
"Consider using the string '${AVAILABLE_CODEGEN}' instead.")
set(ENABLE_CODEGEN "${AVAILABLE_CODEGEN}")
endif()

option(ENABLE_CLI "Enables command-line interface application" ON)
option(ENABLE_TESTS "Enables tests for components" ON)
Expand Down
1 change: 0 additions & 1 deletion compiler/lib/backend/ast/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ target_include_directories(${TARGET_NAME}

target_link_libraries(${TARGET_NAME} PUBLIC
ast
frontend
utils
)
16 changes: 7 additions & 9 deletions compiler/lib/codegen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
cmake_minimum_required(VERSION 3.22)

if(DEFINED ENABLE_CODEGEN AND NOT "${ENABLE_CODEGEN}^" STREQUAL "^" AND NOT "${ENABLE_CODEGEN}^" STREQUAL "OFF^")
foreach(TARGET IN LISTS ENABLE_CODEGEN)
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}")
add_subdirectory(${TARGET})
else()
message(FATAL_ERROR "${TARGET} is not a correct codegen backend")
endif()
endforeach()
endif()
foreach(TARGET IN LISTS ENABLE_CODEGEN)
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}")
add_subdirectory(${TARGET})
else()
message(FATAL_ERROR "${TARGET} is not a correct codegen backend")
endif()
endforeach()
1 change: 1 addition & 0 deletions compiler/tests/backend/ast/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ target_include_directories(${TARGET_NAME} PUBLIC
)

target_link_libraries(${TARGET_NAME} PUBLIC
frontend
backend_ast
gtest
gtest_main
Expand Down
1 change: 1 addition & 0 deletions compiler/tests/codegen/ast_to_llvmir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ file(GLOB_RECURSE TARGET_SRC
add_executable(${TARGET_NAME} ${TARGET_SRC})

target_link_libraries(${TARGET_NAME} PUBLIC
frontend
backend_ast
codegen_ast_to_llvmir
gtest
Expand Down

0 comments on commit b7d9c41

Please sign in to comment.