Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=\\\"<args>\\\"] [--cache-tool=<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=\\\"<args>\\\"] [--cache-tool=<tool>] -n --allgpuarch --ci-only-arch --show_depr_warn -h --help"
HELP="$0 [<target> ...] [<flag> ...]
where <target> is:
clean - remove all existing build artifacts and configuration (start over)
Expand All @@ -38,6 +38,7 @@ HELP="$0 [<target> ...] [<flag> ...]
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 <flag> is:
-v - verbose build mode
-g - build for debug
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/libcuopt/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
87 changes: 77 additions & 10 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "$<$<COMPILE_LANGUAGE:CXX>:${CUOPT_CXX_FLAGS}>"
Expand All @@ -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)
Expand All @@ -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)