Browse Source

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

tobil4sk 3 years ago
parent
commit
55f3609330
2 changed files with 5 additions and 1 deletions
  1. 4 0
      CMakeLists.txt
  2. 1 1
      Makefile

+ 4 - 0
CMakeLists.txt

@@ -145,6 +145,10 @@ add_executable(hl
 	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)
 
 if(WIN32)

+ 1 - 1
Makefile

@@ -89,7 +89,7 @@ else
 
 # Linux
 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)
 CFLAGS += -I /usr/include/i386-linux-gnu