[Beignet] [PATCH 1/3] add option BUILD_STATIC_GBE_COMPILER to build static compiler

Guo Yejun yejun.guo at intel.com
Tue Dec 30 23:34:22 PST 2014


The offline compiler (gbe_bin_generater), depending on LLVM/clang,
could only be built with C++11 features. To make it workable within
old c/c++ version environment, add one CMAKE option to link against
all static libraries.

Signed-off-by: Guo Yejun <yejun.guo at intel.com>
---
 backend/src/CMakeLists.txt | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/backend/src/CMakeLists.txt b/backend/src/CMakeLists.txt
index bec0d2a..118a745 100644
--- a/backend/src/CMakeLists.txt
+++ b/backend/src/CMakeLists.txt
@@ -117,22 +117,22 @@ set (GBE_SRC
     backend/gen8_encoder.cpp
     )
 
+set (GBE_LINK_LIBRARIES
+    ${DRM_INTEL_LIBRARIES}
+    ${DRM_LIBRARIES}
+    ${CLANG_LIBRARIES}
+    ${LLVM_MODULE_LIBS}
+    ${LLVM_SYSTEM_LIBS}
+    ${CMAKE_THREAD_LIBS_INIT}
+    ${CMAKE_DL_LIBS}
+    )
 
 include_directories (.)
 link_directories (${LLVM_LIBRARY_DIRS} ${DRM_LIBDIR})
 include_directories(${LLVM_INCLUDE_DIRS})
 add_library (gbe SHARED ${GBE_SRC})
 
-
-target_link_libraries(
-                      gbe
-                      ${DRM_INTEL_LIBRARIES}
-                      ${DRM_LIBRARIES}
-                      ${CLANG_LIBRARIES}
-                      ${LLVM_MODULE_LIBS}
-                      ${LLVM_SYSTEM_LIBS}
-                      ${CMAKE_THREAD_LIBS_INIT}
-                      ${CMAKE_DL_LIBS})
+target_link_libraries(gbe ${GBE_LINK_LIBRARIES})
 
 add_library(gbeinterp SHARED gbe_bin_interpreter.cpp)
 
@@ -149,8 +149,21 @@ if (LLVM_VERSION_NODOT VERSION_EQUAL 34)
 endif(LLVM_VERSION_NODOT VERSION_EQUAL 34)
 
 link_directories (${LLVM_LIBRARY_DIR} ${DRM_LIBDIR})
+
+if (BUILD_STATIC_GBE_COMPILER STREQUAL "true")
+macro(remove_cxx_flag flag)
+  string(REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+endmacro()
+
+remove_cxx_flag("-Wl,-E")
+ADD_EXECUTABLE(gbe_bin_generater gbe_bin_generater.cpp ${GBE_SRC})
+set_target_properties(gbe_bin_generater PROPERTIES LINK_FLAGS "-static")
+TARGET_LINK_LIBRARIES(gbe_bin_generater ${GBE_LINK_LIBRARIES})
+else (BUILD_STATIC_GBE_COMPILER STREQUAL "true")
 ADD_EXECUTABLE(gbe_bin_generater gbe_bin_generater.cpp)
 TARGET_LINK_LIBRARIES(gbe_bin_generater gbe)
+endif (BUILD_STATIC_GBE_COMPILER STREQUAL "true")
+
 
 install (TARGETS gbe LIBRARY DESTINATION ${BEIGNET_INSTALL_DIR})
 install (TARGETS gbeinterp LIBRARY DESTINATION ${BEIGNET_INSTALL_DIR})
-- 
1.9.1



More information about the Beignet mailing list