From: Christoph Egger Date: Tue, 10 Mar 2015 11:38:13 +0000 (+0100) Subject: Move LLVM logic to extra cmake module X-Git-Tag: v0.1~56 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=f44ed1e33c85254a6176b1db3775b9b13baaaa29;p=frida%2Ffrida.git Move LLVM logic to extra cmake module --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ae7acd7..c88c46a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,10 +7,10 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules") - find_package(Qt5Widgets) find_package(Qt5 CONFIG REQUIRED Widgets Gui) find_package(QuaZip REQUIRED) +find_package(LLVM REQUIRED) find_package(PkgConfig) pkg_check_modules(LOG4CXX REQUIRED liblog4cxx) pkg_check_modules(GUILE REQUIRED guile-2.0) @@ -19,24 +19,6 @@ pkg_check_modules(GUILE REQUIRED guile-2.0) add_definitions(${LOG4CXX_CFLAGS}) add_definitions(${GUILE_CFLAGS}) -find_program(LLVM_CONFIG llvm-config-3.5) - -if(NOT LLVM_CONFIG) - message(FATAL_ERROR "LLVM not found") -endif() - -execute_process(COMMAND ${LLVM_CONFIG} --cxxflags OUTPUT_VARIABLE LLVM_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND ${LLVM_CONFIG} --ldflags OUTPUT_VARIABLE LLVM_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND ${LLVM_CONFIG} --libs OUTPUT_VARIABLE LLVM_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND ${LLVM_CONFIG} --system-libs OUTPUT_VARIABLE LLVM_SYSTEM_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE) - -string(REPLACE -O2 "" LLVM_CFLAGS ${LLVM_CFLAGS}) -string(REPLACE -fno-exceptions "" LLVM_CFLAGS ${LLVM_CFLAGS}) -string(REPLACE -fno-rtti "" LLVM_CFLAGS ${LLVM_CFLAGS}) -string(REPLACE -DNDEBUG "" LLVM_CFLAGS ${LLVM_CFLAGS}) -string(REPLACE -I "-isystem" LLVM_CFLAGS ${LLVM_CFLAGS}) - -separate_arguments(LLVM_CFLAGS) add_definitions(${LLVM_CFLAGS}) add_definitions(-std=c++11 -Wall -Wextra) add_definitions(-DQT_NO_KEYWORDS) diff --git a/cmake/Modules/FindLLVM.cmake b/cmake/Modules/FindLLVM.cmake new file mode 100644 index 0000000..ba2dd15 --- /dev/null +++ b/cmake/Modules/FindLLVM.cmake @@ -0,0 +1,32 @@ +find_program(LLVM_CONFIG NAMES llvm-config-3.5 llvm-config) + +if(LLVM_CONFIG) + execute_process(COMMAND ${LLVM_CONFIG} --version + OUTPUT_VARIABLE LLVM_VERSION) + + if(((${LLVM_VERSION} VERSION_LESS 3.6.0) + AND (${LLVM_VERSION} VERSION_GREATER 3.5)) + OR (${LLVM_VERSION} VERSION_EQUAL 3.5)) + + execute_process(COMMAND ${LLVM_CONFIG} --cxxflags + OUTPUT_VARIABLE LLVM_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LLVM_CONFIG} --ldflags + OUTPUT_VARIABLE LLVM_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LLVM_CONFIG} --libs + OUTPUT_VARIABLE LLVM_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LLVM_CONFIG} --system-libs + OUTPUT_VARIABLE LLVM_SYSTEM_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE) + + string(REPLACE -O2 "" LLVM_CFLAGS ${LLVM_CFLAGS}) + string(REPLACE -fno-exceptions "" LLVM_CFLAGS ${LLVM_CFLAGS}) + string(REPLACE -fno-rtti "" LLVM_CFLAGS ${LLVM_CFLAGS}) + string(REPLACE -DNDEBUG "" LLVM_CFLAGS ${LLVM_CFLAGS}) + string(REPLACE -I "-isystem" LLVM_CFLAGS ${LLVM_CFLAGS}) + + separate_arguments(LLVM_CFLAGS) + endif() +endif() + +if(NOT DEFINED LLVM_CFLAGS) + message(SEND_ERROR "LLVM 3.5 required but not found") +endif() \ No newline at end of file