# NOTE: This file is _not_ used as part of the main build process. # It exists to help IDE tools provide auto-hinting while developing the C++ bridge cmake_minimum_required(VERSION 3.22) project(slang_compiler) find_program(CXXBRIDGE cxxbridge) set(SLANG_COMPILER_CXXBRIDGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/cxxbridge) # Generate the Rust bridge stubs header # This is used by the C++ header to define an interface for Rust file(MAKE_DIRECTORY ${SLANG_COMPILER_CXXBRIDGE_DIR}/rust) set(SLANG_COMPILER_CXXBRIDGE_RUST ${SLANG_COMPILER_CXXBRIDGE_DIR}/rust/cxx.h) add_custom_command( OUTPUT ${SLANG_COMPILER_CXXBRIDGE_RUST} COMMAND ${CXXBRIDGE} --header -o ${SLANG_COMPILER_CXXBRIDGE_RUST} ) # Generate the Rust bridge header # This is used by the C++ implementation to interact with Rust file(MAKE_DIRECTORY ${SLANG_COMPILER_CXXBRIDGE_DIR}/slang-compiler-sys/src) set(SLANG_COMPILER_CXXBRIDGE_INPUT ${CMAKE_CURRENT_LIST_DIR}/src/lib.rs) set(SLANG_COMPILER_CXXBRIDGE_OUTPUT ${SLANG_COMPILER_CXXBRIDGE_DIR}/slang-compiler-sys/src/lib.rs.h) add_custom_command( OUTPUT ${SLANG_COMPILER_CXXBRIDGE_OUTPUT} COMMAND ${CXXBRIDGE} ${SLANG_COMPILER_CXXBRIDGE_INPUT} --header -o ${SLANG_COMPILER_CXXBRIDGE_OUTPUT} DEPENDS ${SLANG_COMPILER_CXXBRIDGE_INPUT} ) add_custom_target(slang_compiler_bridge DEPENDS ${SLANG_COMPILER_CXXBRIDGE_RUST} ${SLANG_COMPILER_CXXBRIDGE_OUTPUT}) add_library(slang_compiler "src/lib.cpp") # Find the bridge headers add_dependencies(slang_compiler slang_compiler_bridge) target_include_directories(slang_compiler PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src ${SLANG_COMPILER_CXXBRIDGE_DIR}) # Find the slang headers add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/slang" EXCLUDE_FROM_ALL) target_link_libraries(slang_compiler PRIVATE slang)