From 1f1c351156911e5fcad0a3de2b8c0bca09cbf12d Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Tue, 26 Dec 2023 23:18:34 +0100 Subject: [PATCH] build: refactor handling of lib/lib64 install directories --- .../custom-modules/ns3-cmake-package.cmake | 21 ++++++------------- ...-fetch-optional-modules-dependencies.cmake | 10 +++++---- .../custom-modules/ns3-output-directory.cmake | 12 ++++++++--- build-support/macros-and-definitions.cmake | 6 ++++-- doc/manual/source/python.rst | 2 +- setup.py | 1 - 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/build-support/custom-modules/ns3-cmake-package.cmake b/build-support/custom-modules/ns3-cmake-package.cmake index 5f583b97e..8b1a7ba09 100644 --- a/build-support/custom-modules/ns3-cmake-package.cmake +++ b/build-support/custom-modules/ns3-cmake-package.cmake @@ -15,21 +15,12 @@ # # Author: Gabriel Ferreira -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! diff --git a/build-support/custom-modules/ns3-fetch-optional-modules-dependencies.cmake b/build-support/custom-modules/ns3-fetch-optional-modules-dependencies.cmake index 90f774361..dbf13b5de 100644 --- a/build-support/custom-modules/ns3-fetch-optional-modules-dependencies.cmake +++ b/build-support/custom-modules/ns3-fetch-optional-modules-dependencies.cmake @@ -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) diff --git a/build-support/custom-modules/ns3-output-directory.cmake b/build-support/custom-modules/ns3-output-directory.cmake index e2171fae8..7d25e1726 100644 --- a/build-support/custom-modules/ns3-output-directory.cmake +++ b/build-support/custom-modules/ns3-output-directory.cmake @@ -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}) diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 804b15c6b..89fd6bca5 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -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 diff --git a/doc/manual/source/python.rst b/doc/manual/source/python.rst index 38dbf57ae..5b1a13173 100644 --- a/doc/manual/source/python.rst +++ b/doc/manual/source/python.rst @@ -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. diff --git a/setup.py b/setup.py index 7d39253bd..31997e8f8 100644 --- a/setup.py +++ b/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')}",