cmake_minimum_required(VERSION 3.5)
project(LiteGoCompiler)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -O2 -g")

# library in subdirectory
add_subdirectory(antlr)
add_subdirectory(src)

# executable
add_executable(LiteGoCompiler main.cpp)

target_include_directories(LiteGoCompiler
    PUBLIC
        ${CMAKE_SOURCE_DIR}/include
)

target_link_libraries(LiteGoCompiler
    PUBLIC
        common
        icg
        tcg
)

# Custom clean target to remove all directories
add_custom_target(clean-all
    COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_SOURCE_DIR}/*
    COMMENT "Removing all directories and files in the current directory"
)

# Make 'clean' depend on 'clean-all'
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*")