meta/CMakeLists.txt
2024-03-03 17:19:41 +08:00

42 lines
1.4 KiB
CMake

cmake_minimum_required(VERSION 3.10)
project(meta LANGUAGES CXX VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_subdirectory(3rdparty/sled EXCLUDE_FROM_ALL)
add_executable(meta
src/main.cc
src/clang/cursor.cc
src/clang/cursor_type.cc
src/clang/parser.cc
src/types/base_type.cc
src/types/class.cc
src/types/field.cc
src/types/method.cc
src/registry.cc
)
### add clang
set(CLANG_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/LLVM/include")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CLANG_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/LLVM/bin/Linux")
set(CLANG_LIB_LIBRARIES "${CLANG_LIB_DIR}/libclang.so.12")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
message(FATAL "${CMAKE_SYSTEM_NAME} is not supported")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(OSX_DEVELOPER_ROOT "/Applications/Xcode.app/Contents/Developer/")
set(CLANG_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/LLVM/bin/macOS")
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(CLANG_LIB_LIBRARIES ${OSX_DEVELOPER_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib)
else()
set(CLANG_LIB_LIBRARIES "${CLANG_LIB_DIR}/libclang.dylib")
endif()
endif()
target_include_directories(meta PRIVATE ${CLANG_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_link_libraries(meta PRIVATE sled ${CLANG_LIB_LIBRARIES})