]> git.siccegge.de Git - frida/frida.git/commitdiff
Move LLVM logic to extra cmake module
authorChristoph Egger <Christoph.Egger@fau.de>
Tue, 10 Mar 2015 11:38:13 +0000 (12:38 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Tue, 10 Mar 2015 11:38:13 +0000 (12:38 +0100)
CMakeLists.txt
cmake/Modules/FindLLVM.cmake [new file with mode: 0644]

index ae7acd742a6a7c72319c71652154f26c0787e889..c88c46a75ab99240fe2f7aeb034c679e186ecf1c 100644 (file)
@@ -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 (file)
index 0000000..ba2dd15
--- /dev/null
@@ -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