@@ -6,6 +6,8 @@ set(CMAKE_BUILD_TYPE Debug)
66set (CMAKE_CXX_STANDARD 14)
77
88find_package (LLVM 3.9 REQUIRED CONFIG)
9+ find_package (Clang REQUIRED CONFIG)
10+
911find_package (PythonLibs 2.7)
1012
1113message (STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} @ ${LLVM_DIR} " )
@@ -41,13 +43,22 @@ if (${PYTHONLIBS_FOUND})
4143 COMMAND clang -E ${LLVM_DEFINITIONS} -isystem ${LLVM_INCLUDE_DIRS} "${LLVM_INCLUDE_DIRS} /llvm-c/Core.h" | python "${CMAKE_SOURCE_DIR} /fcd/python/bindings.py" > ${pythonbindingsfile} )
4244endif ()
4345
46+ ### header search paths file ###
47+ execute_process (COMMAND clang++ -E -x c++ -v /dev/null OUTPUT_VARIABLE dummy ERROR_VARIABLE defaultHeaderSearchPathList)
48+ string (REGEX REPLACE ".*#include <...> search starts here:\n (.+)\n End of search list.*" "\\ 1" defaultHeaderSearchPathList "${defaultHeaderSearchPathList} " )
49+ string (REGEX REPLACE " (/[^\n ]+)" "\"\\ 1\" ," defaultHeaderSearchPathList "${defaultHeaderSearchPathList} " )
50+ set (defaultFrameworkSearchPathList)
51+ configure_file (fcd/systemIncludePath.c.tmpl "${CMAKE_CURRENT_BINARY_DIR} /systemIncludePath.c" )
52+
53+
4454# collect files
4555file (GLOB_RECURSE sources fcd/*.cpp)
4656file (GLOB_RECURSE headers fcd/*.h)
57+
4758# remove emulators
4859string (REGEX REPLACE "[^;]+.emulator.cpp;?" "" sources "${sources} " )
4960
50- add_executable (fcd ${sources} ${headers} $<TARGET_OBJECTS:emu> ${pythonbindingsfile} )
61+ add_executable (fcd ${sources} ${headers} $<TARGET_OBJECTS:emu> ${pythonbindingsfile} " ${CMAKE_CURRENT_BINARY_DIR} /systemIncludePath.c" )
5162
5263# NDEBUG must match llvm's build or it will crash
5364if (${LLVM_ENABLE_ASSERTIONS} )
@@ -64,7 +75,7 @@ target_compile_options(fcd PRIVATE -Wall -Werror=conversion -Wno-error=sign-conv
6475target_compile_options (fcd PRIVATE -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections)
6576
6677llvm_map_components_to_libnames(llvm_libs core analysis instcombine ipo irreader scalaropts transformutils vectorize support)
67- target_link_libraries (fcd ${llvm_libs} capstone -Wl,--gc-sections)
78+ target_link_libraries (fcd ${llvm_libs} clangIndex clangCodeGen libclang capstone -Wl,--gc-sections)
6879
6980if (${PYTHONLIBS_FOUND} )
7081 set_source_files_properties (${pythonbindingsfile} PROPERTIES COMPILE_FLAGS -w)
0 commit comments