@@ -245,16 +245,49 @@ endif(BUILD_TESTS)
245245
246246# ##################################################################################################
247247# - install targets -------------------------------------------------------------------------------
248+
249+ # allows for CPack component builds and install location
250+ set (CPACK_DEB_COMPONENT_INSTALL ON )
251+ set (CPACK_COMPONENTS_ALL runtime dev)
252+ set (CPACK_PACKAGING_INSTALL_PREFIX "/usr/local" )
253+
254+ #If using cpack to create a deb package
255+ if (CPACK_GENERATOR STREQUAL "DEB" )
256+ set (_BIN_DEST "bin" )
257+ set (_LIB_DEST "lib" )
258+ set (_INCLUDE_DEST "lib/cuopt" )
259+
260+ #If building locally use the Default install paths(e.g. for local development or other package types)
261+ else ()
262+ set (_BIN_DEST "${CMAKE_INSTALL_BINDIR} " )
263+ set (_LIB_DEST "${lib_dir} " )
264+ set (_INCLUDE_DEST include /cuopt/)
265+ endif ()
266+
267+ # adds the .so files to the runtime deb package
248268install (TARGETS cuopt mps_parser
249- DESTINATION ${lib_dir}
250- EXPORT cuopt-exports)
269+ DESTINATION ${_LIB_DEST}
270+ COMPONENT runtime
271+ EXPORT cuopt-exports
272+ )
273+
274+ # adds the .so files to the development deb package
275+ install (TARGETS cuopt mps_parser
276+ DESTINATION ${_LIB_DEST}
277+ COMPONENT dev
278+ )
251279
280+ # adds the header files to the development deb package
252281install (DIRECTORY include /cuopt/
253- DESTINATION include /cuopt)
282+ DESTINATION ${_INCLUDE_DEST}
283+ COMPONENT dev
284+ )
254285
286+ # adds the version header file to the development deb package
255287install (FILES ${CMAKE_CURRENT_BINARY_DIR} /include /cuopt/version_config.hpp
256- DESTINATION include /cuopt)
257-
288+ DESTINATION ${_INCLUDE_DEST}
289+ COMPONENT dev
290+ )
258291# ###############################################################################################
259292# - install export -------------------------------------------------------------------------------
260293set (doc_string
@@ -299,8 +332,6 @@ if(Doxygen_FOUND)
299332endif ()
300333
301334
302-
303- list (APPEND CUOPT_CXX_FLAGS -g -O0)
304335add_executable (cuopt_cli cuopt_cli.cpp)
305336target_compile_options (cuopt_cli
306337 PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUOPT_CXX_FLAGS} >"
@@ -323,10 +354,11 @@ target_link_libraries(cuopt_cli
323354)
324355set_property (TARGET cuopt_cli PROPERTY INSTALL_RPATH "$ORIGIN/../${lib_dir} " )
325356
326- # FIXME:: Is this the right way?
357+ # adds the cuopt_cli executable to the runtime deb package
327358install (TARGETS cuopt_cli
328- DESTINATION ${CMAKE_INSTALL_BINDIR} )
329-
359+ COMPONENT runtime
360+ RUNTIME DESTINATION ${_BIN_DEST}
361+ )
330362
331363option (BUILD_BENCHMARKS "Build benchmarks" ON )
332364if (BUILD_BENCHMARKS)
@@ -341,3 +373,38 @@ if(BUILD_BENCHMARKS)
341373 OpenMP::OpenMP_CXX
342374 )
343375endif ()
376+
377+
378+ # ##################################################################################################
379+ # - CPack has to be the last item in the cmake file-------------------------------------------------
380+ # Used to create an installable deb package for cuOpt
381+
382+ set (CPACK_GENERATOR "DEB" )
383+
384+ # Runtime package metadata
385+ execute_process (COMMAND dpkg --print-architecture OUTPUT_VARIABLE DEB_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
386+
387+ # general package metadata
388+ set (CPACK_DEBIAN_PACKAGE_NAME "cuOpt" )
389+ set (CPACK_PACKAGE_VERSION "${PROJECT_VERSION} " )
390+ set (CPACK_DEBIAN_PACKAGE_MAINTAINER "Nvidia" )
391+ set (CPACK_PACKAGE_FILE_NAME "cuOpt_${CPACK_PACKAGE_VERSION} _${DEB_ARCH} " )
392+
393+ # runtime package metadata
394+ set (CPACK_COMPONENT_RUNTIME_DESCRIPTION "cuOpt runtime components (binaries and shared libraries)" )
395+ set (CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "cuOpt Runtime" )
396+ set (CPACK_COMPONENT_RUNTIME_GROUP "Runtime" )
397+ set (CPACK_DEBIAN_RUNTIME_PACKAGE_MAINTAINER "NVIDIA" )
398+ set (CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "cuopt" )
399+ set (CPACK_DEBIAN_RUNTIME_PACKAGE_FILE_NAME "cuopt_${PROJECT_VERSION} _${DEB_ARCH} " )
400+
401+ # Dev package metadata
402+ set (CPACK_COMPONENT_DEV_DESCRIPTION "cuOpt development files (headers, symlinks, etc.)" )
403+ set (CPACK_COMPONENT_DEV_DISPLAY_NAME "cuOpt Development" )
404+ set (CPACK_COMPONENT_DEV_GROUP "Development" )
405+ set (CPACK_DEBIAN_DEV_PACKAGE_MAINTAINER "NVIDIA" )
406+ set (CPACK_DEBIAN_DEV_PACKAGE_NAME "cuopt-dev" )
407+ set (CPACK_DEBIAN_DEV_PACKAGE_FILE_NAME "cuopt-dev_${PROJECT_VERSION} _${DEB_ARCH} " )
408+
409+ # MUST BE THE LAST ITEM IN THE CMAKE FILE!!!
410+ include (CPack)
0 commit comments