浏览代码

Fix linux dynamic library issue when installing to `/usr/local/` (#483)

tobil4sk 3 年之前
父节点
当前提交
55f3609330
共有 2 个文件被更改,包括 5 次插入1 次删除
  1. 4 0
      CMakeLists.txt
  2. 1 1
      Makefile

+ 4 - 0
CMakeLists.txt

@@ -145,6 +145,10 @@ add_executable(hl
 	src/profile.c
 	src/profile.c
 )
 )
 
 
+if (UNIX AND NOT APPLE)
+    set_target_properties(hl PROPERTIES INSTALL_RPATH "$ORIGIN;${CMAKE_INSTALL_PREFIX}/lib")
+endif()
+
 target_link_libraries(hl libhl)
 target_link_libraries(hl libhl)
 
 
 if(WIN32)
 if(WIN32)

+ 1 - 1
Makefile

@@ -89,7 +89,7 @@ else
 
 
 # Linux
 # Linux
 CFLAGS += -m$(MARCH) -fPIC -pthread -fno-omit-frame-pointer
 CFLAGS += -m$(MARCH) -fPIC -pthread -fno-omit-frame-pointer
-LFLAGS += -lm -Wl,-rpath,. -Wl,--export-dynamic -Wl,--no-undefined
+LFLAGS += -lm -Wl,-rpath,.:'$$ORIGIN':$(INSTALL_LIB_DIR) -Wl,--export-dynamic -Wl,--no-undefined
 
 
 ifeq ($(MARCH),32)
 ifeq ($(MARCH),32)
 CFLAGS += -I /usr/include/i386-linux-gnu
 CFLAGS += -I /usr/include/i386-linux-gnu