From 624474747f4423c81ecfe568deb1326d172db2ae Mon Sep 17 00:00:00 2001 From: Mark Ostroot Date: Mon, 7 Jul 2025 16:36:15 -0500 Subject: [PATCH 1/4] Feat: rework cmakelists.txt to facilitate deb file creation. --- cpp/CMakeLists.txt | 88 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 10 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index fe80843d0d..f01ce5440d 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -252,16 +252,49 @@ endif(BUILD_TESTS) # ################################################################################################## # - install targets ------------------------------------------------------------------------------- + +# allows for CPack component builds and install location +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_COMPONENTS_ALL runtime dev) +set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local") + +#If using cpack to create a deb package +if(CPACK_GENERATOR STREQUAL "DEB") + set(_BIN_DEST "bin") + set(_LIB_DEST "lib") + set(_INCLUDE_DEST "lib/cuopt") + +#If building locally use the Default install paths(e.g. for local development or other package types) +else() + set(_BIN_DEST "${CMAKE_INSTALL_BINDIR}") + set(_LIB_DEST "${lib_dir}") + set(_INCLUDE_DEST include/cuopt/) +endif() + +# adds the .so files to the runtime deb package install(TARGETS cuopt mps_parser - DESTINATION ${lib_dir} - EXPORT cuopt-exports) + DESTINATION ${_LIB_DEST}z + COMPONENT runtime + EXPORT cuopt-exports +) + +# adds the .so files to the development deb package +install(TARGETS cuopt mps_parser + DESTINATION ${_LIB_DEST} + COMPONENT dev +) +# adds the header files to the development deb package install(DIRECTORY include/cuopt/ - DESTINATION include/cuopt) + DESTINATION ${_INCLUDE_DEST} + COMPONENT dev +) +# adds the version header file to the development deb package install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/cuopt/version_config.hpp - DESTINATION include/cuopt) - + DESTINATION ${_INCLUDE_DEST} + COMPONENT dev +) # ############################################################################################### # - install export ------------------------------------------------------------------------------- set(doc_string @@ -306,8 +339,6 @@ if(Doxygen_FOUND) endif() - -list(APPEND CUOPT_CXX_FLAGS -g -O0) add_executable(cuopt_cli cuopt_cli.cpp) target_compile_options(cuopt_cli PRIVATE "$<$:${CUOPT_CXX_FLAGS}>" @@ -330,10 +361,12 @@ target_link_libraries(cuopt_cli ) set_property(TARGET cuopt_cli PROPERTY INSTALL_RPATH "$ORIGIN/../${lib_dir}") -# FIXME:: Is this the right way? -install(TARGETS cuopt_cli - DESTINATION ${CMAKE_INSTALL_BINDIR}) +# adds the cuopt_cli executable to the runtime deb package +install(TARGETS cuopt_cli + COMPONENT runtime + RUNTIME DESTINATION ${_BIN_DEST} +) option(BUILD_BENCHMARKS "Build benchmarks" ON) if(BUILD_BENCHMARKS) @@ -348,3 +381,38 @@ if(BUILD_BENCHMARKS) OpenMP::OpenMP_CXX ) endif() + + +# ################################################################################################## +# - CPack has to be the last item in the cmake file------------------------------------------------- +# Used to create an installable deb package for cuOpt + +set(CPACK_GENERATOR "DEB") + +# Runtime package metadata +execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE DEB_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE) + +# general package metadata +set(CPACK_DEBIAN_PACKAGE_NAME "cuOpt") +set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Nvidia") +set(CPACK_PACKAGE_FILE_NAME "cuOpt_${CPACK_PACKAGE_VERSION}_${DEB_ARCH}") + +# runtime package metadata +set(CPACK_COMPONENT_RUNTIME_DESCRIPTION "cuOpt runtime components (binaries and shared libraries)") +set(CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "cuOpt Runtime") +set(CPACK_COMPONENT_RUNTIME_GROUP "Runtime") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_MAINTAINER "NVIDIA") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "cuopt") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_FILE_NAME "cuopt_${PROJECT_VERSION}_${DEB_ARCH}") + +# Dev package metadata +set(CPACK_COMPONENT_DEV_DESCRIPTION "cuOpt development files (headers, symlinks, etc.)") +set(CPACK_COMPONENT_DEV_DISPLAY_NAME "cuOpt Development") +set(CPACK_COMPONENT_DEV_GROUP "Development") +set(CPACK_DEBIAN_DEV_PACKAGE_MAINTAINER "NVIDIA") +set(CPACK_DEBIAN_DEV_PACKAGE_NAME "cuopt-dev") +set(CPACK_DEBIAN_DEV_PACKAGE_FILE_NAME "cuopt-dev_${PROJECT_VERSION}_${DEB_ARCH}") + +# MUST BE THE LAST ITEM IN THE CMAKE FILE!!! +include(CPack) From 9df8bac07ebb1127f4f4c78d193a7ad2fbd76b0f Mon Sep 17 00:00:00 2001 From: Ramakrishna Prabhu Date: Mon, 28 Jul 2025 12:20:03 -0500 Subject: [PATCH 2/4] update receipe --- CONTRIBUTING.md | 9 +++++++++ build.sh | 2 +- conda/recipes/libcuopt/recipe.yaml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3129e71907..c141d3162b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -143,6 +143,15 @@ cd $CUOPT_HOME ./build.sh --help ``` +#### Deb package + +`libcuopt.so` can be packaged as a deb package with option deb. This is a beta-feature and dependecies of libcuopt needs to be installed manually while installing it using deb package. +This is only available to be built through source code and libcuopt is not being released as deb package in any official space. + +```bash +./build.sh libmps_parser libcuopt deb +``` + #### Building for development To build all libraries and tests, simply run diff --git a/build.sh b/build.sh index 7cb9aa82c2..f3d693aa7b 100755 --- a/build.sh +++ b/build.sh @@ -273,7 +273,7 @@ else echo "Building for Volta and Ampere architectures..." else CUOPT_CMAKE_CUDA_ARCHITECTURES="RAPIDS" - echo "Building for Volta, Ampere and Hopper architectures..." + echo "Building for RAPIDS supported architectures..." fi else CUOPT_CMAKE_CUDA_ARCHITECTURES="NATIVE" diff --git a/conda/recipes/libcuopt/recipe.yaml b/conda/recipes/libcuopt/recipe.yaml index fbdcfd5e8c..b507a35fb3 100644 --- a/conda/recipes/libcuopt/recipe.yaml +++ b/conda/recipes/libcuopt/recipe.yaml @@ -29,7 +29,7 @@ cache: export CXXFLAGS=$(echo $CXXFLAGS | sed -E 's@\-fdebug\-prefix\-map[^ ]*@@g') set +x - ./build.sh -n -v -a libmps_parser libcuopt --ci-only-arch --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" + ./build.sh -n -v -a libmps_parser libcuopt deb --allgpuarch --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" secrets: - AWS_ACCESS_KEY_ID - AWS_SECRET_ACCESS_KEY From fe399c2182ec6a6b75ea1db5bd68abb70ca1101c Mon Sep 17 00:00:00 2001 From: Ramakrishna Prabhu Date: Mon, 28 Jul 2025 13:26:18 -0500 Subject: [PATCH 3/4] add deb option to build.sh --- build.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index f3d693aa7b..956d37b063 100755 --- a/build.sh +++ b/build.sh @@ -27,7 +27,7 @@ REPODIR=$(cd "$(dirname "$0")"; pwd) LIBCUOPT_BUILD_DIR=${LIBCUOPT_BUILD_DIR:=${REPODIR}/cpp/build} LIBMPS_PARSER_BUILD_DIR=${LIBMPS_PARSER_BUILD_DIR:=${REPODIR}/cpp/libmps_parser/build} -VALIDARGS="clean libcuopt libmps_parser cuopt_mps_parser cuopt cuopt_server cuopt_sh_client docs -a -b -g -v -l= --verbose-pdlp [--cmake-args=\\\"\\\"] [--cache-tool=] -n --allgpuarch --ci-only-arch --show_depr_warn -h --help" +VALIDARGS="clean libcuopt libmps_parser cuopt_mps_parser cuopt cuopt_server cuopt_sh_client docs deb -a -b -g -v -l= --verbose-pdlp [--cmake-args=\\\"\\\"] [--cache-tool=] -n --allgpuarch --ci-only-arch --show_depr_warn -h --help" HELP="$0 [ ...] [ ...] where is: clean - remove all existing build artifacts and configuration (start over) @@ -38,6 +38,7 @@ HELP="$0 [ ...] [ ...] cuopt_server - build the cuopt_server Python package cuopt_sh_client - build cuopt self host client docs - build the docs + deb - build deb package (requires libcuopt to be built first) and is: -v - verbose build mode -g - build for debug @@ -321,6 +322,21 @@ if buildAll || hasArg libcuopt; then fi fi +################################################################################ +# Build deb package +if hasArg deb; then + # Check if libcuopt has been built + if [ ! -d "${LIBCUOPT_BUILD_DIR}" ]; then + echo "Error: libcuopt must be built before creating deb package. Run with 'libcuopt' target first." + exit 1 + fi + + echo "Building deb package..." + cd "${LIBCUOPT_BUILD_DIR}" + cpack -G DEB + echo "Deb package created in ${LIBCUOPT_BUILD_DIR}" +fi + # Build and install the cuopt Python package if buildAll || hasArg cuopt; then From da80a851ed57612de37fa184e018765c2c99901a Mon Sep 17 00:00:00 2001 From: Mark Ostroot Date: Mon, 28 Jul 2025 15:10:49 -0500 Subject: [PATCH 4/4] fix: remove typo --- cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index d948038401..cb87db1d35 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -273,7 +273,7 @@ endif() # adds the .so files to the runtime deb package install(TARGETS cuopt mps_parser - DESTINATION ${_LIB_DEST}z + DESTINATION ${_LIB_DEST} COMPONENT runtime EXPORT cuopt-exports )