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 feb920b89b..746ab0835e 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 @@ -316,6 +317,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 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 diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index cf54f3d535..a06a05ff77 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -245,16 +245,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} + 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 @@ -299,8 +332,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}>" @@ -323,10 +354,11 @@ target_link_libraries(cuopt_cli ) set_property(TARGET cuopt_cli PROPERTY INSTALL_RPATH "$ORIGIN/../${lib_dir}") -# FIXME:: Is this the right way? +# adds the cuopt_cli executable to the runtime deb package install(TARGETS cuopt_cli - DESTINATION ${CMAKE_INSTALL_BINDIR}) - + COMPONENT runtime + RUNTIME DESTINATION ${_BIN_DEST} +) option(BUILD_BENCHMARKS "Build benchmarks" ON) if(BUILD_BENCHMARKS) @@ -341,3 +373,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)