public inbox for dwarves@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH dwarves v4] Respect CMAKE_INSTALL_LIBDIR
@ 2024-11-25 21:35 Ben Olson
  2024-11-26 16:11 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Olson @ 2024-11-25 21:35 UTC (permalink / raw)
  To: dwarves; +Cc: alan.maguire, acme, brandon.kammerdiener

This patch changes the `cmake` configuration to honor `CMAKE_INSTALL_LIBDIR`
and use either `lib` or `lib64` by default so that installations match the
conventional placement of libraries.
For example, it will now install `libdwarves.so` into `${PREFIX}/lib` or
`${PREFIX}/lib64`, depending on the distribution.

Signed-off-by: Brandon Kammerdiener <brandon.kammerdiener@intel.com>
Signed-off-by: Ben Olson <matthew.olson@intel.com>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Tested-by: Alan Maguire <alan.maguire@oracle.com>
---
 CMakeLists.txt | 19 ++++++-------------
 README         |  4 ++--
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ca1bf2..1d0dadf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,18 +21,9 @@ else()
 	LINK_DIRECTORIES(${LIBBPF_LIBRARY_DIRS})
 endif()
 
-# Try to parse this later, Helio just showed me a KDE4 example to support
-# x86-64 builds.
-# the following are directories where stuff will be installed to
-set(__LIB "" CACHE STRING "Define suffix of directory name (32/64)" )
-
-macro(_set_fancy _var _value _comment)
-	if (NOT DEFINED ${_var})
-		set(${_var} ${_value})
-	else (NOT DEFINED ${_var})
-		set(${_var} "${${_var}}" CACHE PATH "${_comment}")
-	endif (NOT DEFINED ${_var})
-endmacro(_set_fancy)
+# Use the standard library installation directory
+include(GNUInstallDirs)
+set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "libdir name")
 
 # where to look first for cmake modules,
 # before ${CMAKE_ROOT}/Modules/ is checked
@@ -84,7 +75,9 @@ if(NOT LIBBPF_FOUND AND NOT EXISTS "${PROJECT_SOURCE_DIR}/lib/bpf/src/btf.h")
 	message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
 endif()
 
-_set_fancy(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${__LIB}" "libdir")
+if (NOT DEFINED LIB_INSTALL_DIR)
+    set(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+endif()
 
 # libbpf uses reallocarray, which is not available in all versions of glibc
 # libbpf's include/tools/libc_compat.h provides implementation, but needs
diff --git a/README b/README
index f9aeef7..7ee3b87 100644
--- a/README
+++ b/README
@@ -3,7 +3,7 @@ Build instructions:
 1. install cmake
 2. mkdir build
 3. cd build
-4. cmake -D__LIB=lib ..
+4. cmake ..
 5. make install
 
 cmake Options:
@@ -12,7 +12,7 @@ cmake Options:
     Use -DBUILD_SHARED_LIBS=OFF while invoking cmake to create STATIC libraries
     and link applications to it.
 
-    Ex. cmake -D__LIB=lib -DBUILD_SHARED_LIBS=OFF ..
+    Ex. cmake -DBUILD_SHARED_LIBS=OFF ..
 
   -DCMAKE_INSTALL_PREFIX
     Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
-- 
2.47.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH dwarves v4] Respect CMAKE_INSTALL_LIBDIR
  2024-11-25 21:35 [PATCH dwarves v4] Respect CMAKE_INSTALL_LIBDIR Ben Olson
@ 2024-11-26 16:11 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-11-26 16:11 UTC (permalink / raw)
  To: Ben Olson; +Cc: dwarves, alan.maguire, brandon.kammerdiener

On Mon, Nov 25, 2024 at 03:35:25PM -0600, Ben Olson wrote:
> This patch changes the `cmake` configuration to honor `CMAKE_INSTALL_LIBDIR`
> and use either `lib` or `lib64` by default so that installations match the
> conventional placement of libraries.
> For example, it will now install `libdwarves.so` into `${PREFIX}/lib` or
> `${PREFIX}/lib64`, depending on the distribution.
> 
> Signed-off-by: Brandon Kammerdiener <brandon.kammerdiener@intel.com>
> Signed-off-by: Ben Olson <matthew.olson@intel.com>
> Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
> Tested-by: Alan Maguire <alan.maguire@oracle.com>

Thanks, applied.

- Arnaldo

> ---
>  CMakeLists.txt | 19 ++++++-------------
>  README         |  4 ++--
>  2 files changed, 8 insertions(+), 15 deletions(-)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 8ca1bf2..1d0dadf 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -21,18 +21,9 @@ else()
>  	LINK_DIRECTORIES(${LIBBPF_LIBRARY_DIRS})
>  endif()
>  
> -# Try to parse this later, Helio just showed me a KDE4 example to support
> -# x86-64 builds.
> -# the following are directories where stuff will be installed to
> -set(__LIB "" CACHE STRING "Define suffix of directory name (32/64)" )
> -
> -macro(_set_fancy _var _value _comment)
> -	if (NOT DEFINED ${_var})
> -		set(${_var} ${_value})
> -	else (NOT DEFINED ${_var})
> -		set(${_var} "${${_var}}" CACHE PATH "${_comment}")
> -	endif (NOT DEFINED ${_var})
> -endmacro(_set_fancy)
> +# Use the standard library installation directory
> +include(GNUInstallDirs)
> +set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "libdir name")
>  
>  # where to look first for cmake modules,
>  # before ${CMAKE_ROOT}/Modules/ is checked
> @@ -84,7 +75,9 @@ if(NOT LIBBPF_FOUND AND NOT EXISTS "${PROJECT_SOURCE_DIR}/lib/bpf/src/btf.h")
>  	message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
>  endif()
>  
> -_set_fancy(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${__LIB}" "libdir")
> +if (NOT DEFINED LIB_INSTALL_DIR)
> +    set(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
> +endif()
>  
>  # libbpf uses reallocarray, which is not available in all versions of glibc
>  # libbpf's include/tools/libc_compat.h provides implementation, but needs
> diff --git a/README b/README
> index f9aeef7..7ee3b87 100644
> --- a/README
> +++ b/README
> @@ -3,7 +3,7 @@ Build instructions:
>  1. install cmake
>  2. mkdir build
>  3. cd build
> -4. cmake -D__LIB=lib ..
> +4. cmake ..
>  5. make install
>  
>  cmake Options:
> @@ -12,7 +12,7 @@ cmake Options:
>      Use -DBUILD_SHARED_LIBS=OFF while invoking cmake to create STATIC libraries
>      and link applications to it.
>  
> -    Ex. cmake -D__LIB=lib -DBUILD_SHARED_LIBS=OFF ..
> +    Ex. cmake -DBUILD_SHARED_LIBS=OFF ..
>  
>    -DCMAKE_INSTALL_PREFIX
>      Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
> -- 
> 2.47.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-26 16:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-25 21:35 [PATCH dwarves v4] Respect CMAKE_INSTALL_LIBDIR Ben Olson
2024-11-26 16:11 ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox