diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f2efb0..8c0baac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,17 @@ cmake_minimum_required(VERSION 3.8...3.22) -project(sapphire-compiler LANGUAGES CXX) +project(sapphire-compiler LANGUAGES CXX C) set(CXX_STANDARD_REQUIRED 17) +find_package(LLVM REQUIRED CONFIG) + +message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") +message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") + +include_directories(${LLVM_INCLUDE_DIRS}) +separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS}) +add_definitions(${LLVM_DEFINITIONS_LIST}) + add_executable( sapphirec src/sapphire.cpp @@ -47,3 +56,8 @@ add_executable( target_include_directories(sapphirec PUBLIC src) target_include_directories(sapphirec PUBLIC src/tclap-1.2.5/include) + +llvm_map_components_to_libnames(llvm_libs support core irreader) + +# Link against LLVM libraries +target_link_libraries(sapphirec ${llvm_libs})