diff --git a/CMakeLists.txt b/CMakeLists.txt index 071e791..a792013 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,12 +8,16 @@ endif() set(CMAKE_BUILD_TYPE Debug) set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(LLVM 4.0 REQUIRED CONFIG) find_package(PythonLibs 2.7 REQUIRED) +set(CAPSTONE_INCLUDE_DIRS "${CAPSTONE_DIR}/include") + message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} @ ${LLVM_DIR}") message(STATUS "Found Python ${PYTHONLIBS_VERSION_STRING} @ ${PYTHON_INCLUDE_PATH}") +message(STATUS "Found capstone @ ${CAPSTONE_DIR}") ### emulator ### @@ -23,7 +27,7 @@ set(INCBIN_TEMPLATE ${CMAKE_SOURCE_DIR}/fcd/cpu/incbin.${CMAKE_SYSTEM_NAME}.tpl) foreach(emulatorsource ${emulatorsources}) string(REGEX REPLACE ".+/([^/]+)\.emulator\.cpp" "\\1" emulator_isa "${emulatorsource}") add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${emulator_isa}.emulator.s" - COMMAND "${CMAKE_CXX_COMPILER}" -c -emit-llvm --std=gnu++14 -O3 "${emulatorsource}" -o "${CMAKE_BINARY_DIR}/${emulator_isa}.emulator.bc" + COMMAND "${CMAKE_CXX_COMPILER}" -c -emit-llvm --std=gnu++14 -O3 "${emulatorsource}" -I "${CAPSTONE_INCLUDE_DIRS}" -o "${CMAKE_BINARY_DIR}/${emulator_isa}.emulator.bc" COMMAND sed -e "s/{CPU}/${emulator_isa}/" ${INCBIN_TEMPLATE} > "${CMAKE_BINARY_DIR}/${emulator_isa}.emulator.s" DEPENDS "${emulatorsource}" IMPLICIT_DEPENDS CXX "${emulatorsource}" @@ -41,7 +45,7 @@ add_custom_command(OUTPUT ${pythonbindingsfile} COMMAND "${CMAKE_C_COMPILER}" -E ${LLVM_DEFINITIONS} -isystem ${LLVM_INCLUDE_DIRS} "${LLVM_INCLUDE_DIRS}/llvm-c/Core.h" | python "${CMAKE_SOURCE_DIR}/fcd/python/bindings.py" > ${pythonbindingsfile}) ### header search paths file ### -execute_process(COMMAND "${CMAKE_CXX_COMPILER}" -E -x c++ -v /dev/null OUTPUT_VARIABLE dummy ERROR_VARIABLE defaultHeaderSearchPathList) +execute_process(COMMAND "${CMAKE_CXX_COMPILER}" -E -x c++ -std=gnu++14 -v /dev/null OUTPUT_VARIABLE dummy ERROR_VARIABLE defaultHeaderSearchPathList) string(REGEX REPLACE ".*#include <...> search starts here:\n(.+)\nEnd of search list.*" "\\1" defaultHeaderSearchPathList "${defaultHeaderSearchPathList}") string(REGEX REPLACE " (/[^\n]+)" "\"\\1\"," defaultHeaderSearchPathList "${defaultHeaderSearchPathList}") set(defaultFrameworkSearchPathList) @@ -65,7 +69,7 @@ endif() target_compile_definitions(fcd PRIVATE ${LLVM_DEFINITIONS} FCD_DEBUG=1) target_include_directories(fcd PRIVATE ${subdirs}) -target_include_directories(fcd SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}) +target_include_directories(fcd SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ${CAPSTONE_INCLUDE_DIRS}) target_compile_options(fcd PRIVATE --system-header-prefix=llvm/ --system-header-prefix=clang/ --system-header-prefix=clang-c/) target_compile_options(fcd PRIVATE -Wall -Werror=conversion -Wno-error=sign-conversion -Wshadow -Wunreachable-code -Wempty-body -Wconditional-uninitialized -Winvalid-offsetof -Wnewline-eof) target_compile_options(fcd PRIVATE -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections) @@ -83,9 +87,10 @@ else() llvm_map_components_to_libnames(llvm_libs analysis asmparser bitreader codegen core coverage instcombine instrumentation ipo irreader linker mc mcparser object option passes profiledata scalaropts support target transformutils vectorize) endif() +target_link_libraries(fcd "-L${CAPSTONE_DIR}/lib" capstone) # Ubuntu does not package ClangConfig target_link_libraries(fcd "-L${LLVM_LIBRARY_DIR}" clangIndex clangCodeGen clangFormat clangToolingCore clangRewrite clangFrontend clangDriver clangParse clangSerialization clangSema clangEdit clangAnalysis clangAST clangLex clangBasic) -target_link_libraries(fcd ${llvm_libs} capstone clang dl -Wl,--gc-sections) +target_link_libraries(fcd ${llvm_libs} clang dl -Wl,--gc-sections) set_source_files_properties(${pythonbindingsfile} PROPERTIES COMPILE_FLAGS -w) target_link_libraries(fcd ${PYTHON_LIBRARIES})