build: refactor handling of lib/lib64 install directories
This commit is contained in:
@@ -15,21 +15,12 @@
|
||||
#
|
||||
# Author: Gabriel Ferreira <gabrielcarvfer@gmail.com>
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Set RPATH not too need LD_LIBRARY_PATH after installing
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:$ORIGIN/:$ORIGIN/../lib")
|
||||
|
||||
# Add the 64 suffix to the library path when manually requested with the
|
||||
# -DNS3_USE_LIB64=ON flag. May be necessary depending on the target platform.
|
||||
# This is used to properly build the manylinux pip wheel.
|
||||
set(NS3_USE_LIB64 FALSE)
|
||||
if(${NS3_USE_LIB64})
|
||||
link_directories(${CMAKE_OUTPUT_DIRECTORY}/lib64)
|
||||
set(CMAKE_INSTALL_RPATH
|
||||
"${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib64:$ORIGIN/:$ORIGIN/../lib64"
|
||||
)
|
||||
endif()
|
||||
# Set RPATH not too need LD_LIBRARY_PATH after installing. Add the lib64 variant
|
||||
# to support all platforms, such as alma linux, used to build the manylinux pip
|
||||
# wheel.
|
||||
set(CMAKE_INSTALL_RPATH
|
||||
"${CMAKE_INSTALL_PREFIX}/lib:$ORIGIN/:$ORIGIN/../lib:${CMAKE_INSTALL_PREFIX}/lib64:$ORIGIN/:$ORIGIN/../lib64"
|
||||
)
|
||||
|
||||
# cmake-format: off
|
||||
# You are a wizard, Harry!
|
||||
|
||||
@@ -18,8 +18,9 @@ ExternalProject_Add(
|
||||
PREFIX click_dep
|
||||
BUILD_IN_SOURCE TRUE
|
||||
UPDATE_DISCONNECTED TRUE
|
||||
CONFIGURE_COMMAND ./configure --disable-linuxmodule --enable-nsclick
|
||||
--enable-wifi --prefix ${CMAKE_OUTPUT_DIRECTORY}
|
||||
CONFIGURE_COMMAND
|
||||
./configure --disable-linuxmodule --enable-nsclick --enable-wifi --prefix
|
||||
${CMAKE_OUTPUT_DIRECTORY} --libdir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
BUILD_COMMAND make -j${NumThreads}
|
||||
INSTALL_COMMAND make install
|
||||
)
|
||||
@@ -56,11 +57,12 @@ install(
|
||||
USE_SOURCE_PERMISSIONS
|
||||
PATTERN "boost/*"
|
||||
)
|
||||
|
||||
install(
|
||||
DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/lib/
|
||||
DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/${libdir}/
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
USE_SOURCE_PERMISSIONS
|
||||
PATTERN "lib/*"
|
||||
PATTERN "${libdir}/*"
|
||||
)
|
||||
|
||||
macro(add_dependency_to_optional_modules_dependencies)
|
||||
|
||||
@@ -66,11 +66,17 @@ else()
|
||||
)
|
||||
set(CMAKE_OUTPUT_DIRECTORY ${absolute_ns3_output_directory})
|
||||
endif()
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/lib)
|
||||
|
||||
set(libdir "lib")
|
||||
if(${CMAKE_INSTALL_LIBDIR} MATCHES "lib64")
|
||||
set(libdir "lib64")
|
||||
endif()
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/${libdir})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/${libdir})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_HEADER_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/include/ns3)
|
||||
set(THIRD_PARTY_DIRECTORY ${PROJECT_SOURCE_DIR}/3rd-party)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
link_directories(${CMAKE_OUTPUT_DIRECTORY}/lib)
|
||||
link_directories(${CMAKE_OUTPUT_DIRECTORY}/lib ${CMAKE_OUTPUT_DIRECTORY}/lib64)
|
||||
file(MAKE_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY})
|
||||
|
||||
@@ -39,11 +39,13 @@ include(ns3-hidden-settings)
|
||||
# as possible
|
||||
include(colored-messages)
|
||||
|
||||
# Get installation folder default values
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Define output directories
|
||||
include(ns3-output-directory)
|
||||
|
||||
# Get installation folder default values for each platform and include package
|
||||
# configuration macro
|
||||
# Configure packaging related settings
|
||||
include(ns3-cmake-package)
|
||||
|
||||
# Windows, Linux and Mac related checks
|
||||
|
||||
@@ -632,7 +632,7 @@ in the ``ns-3-dev/setup.py`` file.
|
||||
.. sourcecode:: yaml
|
||||
|
||||
# Configure and build wheel
|
||||
- $PYTHON setup.py bdist_wheel build_ext "-DNS3_USE_LIB64=TRUE"
|
||||
- $PYTHON setup.py bdist_wheel build_ext
|
||||
|
||||
At this point, we have a wheel that only works in the current system,
|
||||
since external libraries are not shipped.
|
||||
|
||||
1
setup.py
1
setup.py
@@ -24,7 +24,6 @@ setuptools.setup(
|
||||
"-DNS3_BINDINGS_INSTALL_DIR:STRING=INSTALL_PREFIX",
|
||||
"-DNS3_FETCH_OPTIONAL_COMPONENTS:BOOL=ON",
|
||||
"-DNS3_PIP_PACKAGING:BOOL=ON",
|
||||
"-DNS3_USE_LIB64:BOOL=ON",
|
||||
# Make CMake find python components from the currently running python
|
||||
# https://catherineh.github.io/programming/2021/11/16/python-binary-distributions-whls-with-c17-cmake-auditwheel-and-manylinux
|
||||
f"-DPython3_LIBRARY_DIRS={sysconfig.get_config_var('LIBDIR')}",
|
||||
|
||||
Reference in New Issue
Block a user