diff --git a/CMakeLists.txt b/CMakeLists.txt index f3f0dde6..a5c15ef4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,8 @@ set(DDS_PROTOCOL_VERSION "2") # # Check if cmake has the required version # -cmake_minimum_required( VERSION 3.11.0 FATAL_ERROR ) +cmake_minimum_required( VERSION 3.16.0 FATAL_ERROR ) +cmake_policy(VERSION 3.16) string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) @@ -409,68 +410,31 @@ set( WN_PKG_DIR "${CMAKE_BINARY_DIR}/dds-wrk-bin" ) set( WN_PKG_NAME_ARCH "${WN_PKG_NAME}.tar.gz" ) set( WN_PKG_REMOTE_DIR "/u/ddswww/web-docs/releases/add/${DDS_VERSION}" ) -set(DDS_BOOST_LIB_DIR ${Boost_LIBRARY_DIR}) -if("${DDS_BOOST_LIB_DIR}" STREQUAL "") - set(DDS_BOOST_LIB_DIR ${Boost_LIBRARY_DIR_RELEASE}) -endif() - -if(ENV{DDS_LD_LIBRARY_PATH}) - # because of SIP on macOS we can't use (DY)LD_LIBRARY_PATH. - # But we need to search also in custom location for libstdc++ in case if user installs a custom version of gcc/clang. - # WORKAROUND: We therefore introduce DDS_LD_LIBRARY_PATH, which user can use to specify custom library path(s) - file(TO_CMAKE_PATH "$ENV{DDS_LD_LIBRARY_PATH}" ENV_LD_LIBRARY_PATH) -else() - file(TO_CMAKE_PATH "$ENV{LD_LIBRARY_PATH}" ENV_LD_LIBRARY_PATH) +# top-level executables to package in wn pkg +list(APPEND WN_PKG_EXECUTABLES + $ + $ ) +if(BUILD_TESTS) + list(APPEND $) endif() +separate_arguments(CLI_WN_PKG_EXECUTABLES + UNIX_COMMAND "${WN_PKG_EXECUTABLES}" ) -set(PREREQ_DIRS "$::$::$::$::$::${DDS_BOOST_LIB_DIR}") -foreach(p IN LISTS ENV_LD_LIBRARY_PATH) - set(PREREQ_DIRS "${PREREQ_DIRS}::${p}") -endforeach() - -set(DDS_AGENT_BIN_PATH $) -set(DDS_PREREQ_SOURCE_BIN_PATH $) - -set(PREREQ_DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}") - -# WORKAROUND: don't generate helper script when building an xcode project -# The reason: "Evaluation file to be written multiple times for different configurations or languages with different content" -if (NOT CMAKE_GENERATOR STREQUAL "Xcode") - # - # WORKAROUND: the issue is configure_file currently does not appear to honor generator expressions, - # but it is still needed to configure @...@ expressions. - # We therefore use two-step procedure to configure a file. - # - # 1. Deal with @...@ configurable items: - configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/DDS_CollectPrerequisitesGen.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/modules/DDS_CollectPrerequisitesGen.cmake.configured @ONLY) - # 2. Deal with items configured with generator expressions (variables like "$) - # - # WORKAROUND: the issue is configure_file currently does not appear to honor generator expressions, - # but it is still needed to configure @...@ expressions. - # We therefore use two-step procedure to configure a file. - # - # 1. Deal with @...@ configurable items: - configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/DDS_CollectPrerequisitesGen.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/modules/DDS_CollectPrerequisitesGen_Tests.cmake.configured @ONLY) - # 2. Deal with items configured with generator expressions (variables like "$ "${WN_PKG_DIR}" - COMMAND ${CMAKE_COMMAND} -E copy $ "${WN_PKG_DIR}" - COMMAND ${CMAKE_COMMAND} -DPREREQ_DESTINATION=${WN_PKG_DIR} -DDDS_AGENT_BIN_PATH=${DDS_AGENT_BIN_PATH} - -DPREREQ_DIRS=${PREREQ_DIRS} -DDDS_BOOST_LIB_DIR=${DDS_BOOST_LIB_DIR} -P "${CMAKE_SOURCE_DIR}/cmake/modules/DDS_CollectPrerequisites.cmake" + COMMAND ${CMAKE_COMMAND} + -DEXECUTABLES=${CLI_WN_PKG_EXECUTABLES} + -DDESTINATION=${WN_PKG_DIR} + -DEXCLUDED_SYSTEM_PREFIXES=${CLI_WN_PKG_EXCLUDED_SYSTEM_PREFIXES} + -P "${CMAKE_SOURCE_DIR}/cmake/DDSCollectWNPkgFiles.cmake" COMMAND ${CMAKE_COMMAND} -E tar czf ${WN_PKG_NAME_ARCH} "${WN_PKG_DIR}" COMMAND chmod go+xr ${WN_PKG_NAME_ARCH} COMMENT "Generate WN binary package" @@ -493,19 +457,6 @@ add_dependencies( wn_bin_upload INSTALL(FILES ${CMAKE_BINARY_DIR}/${WN_PKG_NAME_ARCH} DESTINATION "${PROJECT_INSTALL_BINDIR}/wn_bins" OPTIONAL) - -# WORKAROUND: don't generate helper script when building an xcode project -# The reason: "Evaluation file to be written multiple times for different configurations or languages with different content" -if (NOT CMAKE_GENERATOR STREQUAL "Xcode") - # WORKAROUND: create destination "lib" directory. - # INSTALL SCRIPT is called before any other lib is installed, therefore we need to create a dest. dir. - INSTALL(DIRECTORY DESTINATION "${PROJECT_INSTALL_LIBDIR}") - INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/cmake/modules/DDS_CollectPrerequisitesGen.cmake) - if( BUILD_TESTS ) - INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/cmake/modules/DDS_CollectPrerequisitesGen_Tests.cmake) - endif( BUILD_TESTS ) -endif() - # # Package # diff --git a/cmake/DDSCollectWNPkgFiles.cmake b/cmake/DDSCollectWNPkgFiles.cmake new file mode 100644 index 00000000..b360928c --- /dev/null +++ b/cmake/DDSCollectWNPkgFiles.cmake @@ -0,0 +1,24 @@ +# Copyright 2017-2021 GSI, Inc. All rights reserved. +# +# + +################################################### +## Collect WN PKG files +################################################### + +# Collect non-system dependencies +file(GET_RUNTIME_DEPENDENCIES + RESOLVED_DEPENDENCIES_VAR deps + EXECUTABLES ${EXECUTABLES} ) + +# Generate regex that excludes system prefixes +list(JOIN EXCLUDED_SYSTEM_PREFIXES "|" excluded_system_prefix_regex) +set(excluded_system_prefix_regex "^(${excluded_system_prefix_regex})/") + +# Copy dependencies to wn pkg staging directory +foreach(file IN LISTS EXECUTABLES deps) + if(NOT file MATCHES ${excluded_system_prefix_regex}) + message("WN PKG prerequisite='${file}'") + file(COPY ${file} DESTINATION ${DESTINATION}) + endif() +endforeach() diff --git a/cmake/modules/DDS_CollectPrerequisites.cmake b/cmake/modules/DDS_CollectPrerequisites.cmake deleted file mode 100644 index 27c7a052..00000000 --- a/cmake/modules/DDS_CollectPrerequisites.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2017 GSI, Inc. All rights reserved. -# -# -include(GetPrerequisites) - -# WORKAROUND: if "macro" is used it doesn't outoup "message" messages. -#macro(DDS_CollectPrerequisites) - - ################################################### - ## Collect prerequisites for WN PKG - ################################################### - message( STATUS "Using BOOST Library dir: " ${DDS_BOOST_LIB_DIR}) - string(REPLACE "::" ";" PREREQ_DIRS_LIST ${PREREQ_DIRS}) - message( STATUS "prerequisite dirs: " "${PREREQ_DIRS_LIST}") - - # WORKAROUND: the list comes broken into the macro, we need to rebuild it - # if we don't do that, the get_prerequisites doesn't use all avaliable directories. - # I didn't find anyother way, but rebuilt the list. - set(PREREQ_DIRS_LIST_REBUILT "") - foreach(dir ${PREREQ_DIRS_LIST}) - # message(STATU "DEBUG: " ${dir}) - LIST(APPEND PREREQ_DIRS_LIST_REBUILT ${dir}) - endforeach() - - get_prerequisites(${DDS_AGENT_BIN_PATH} DEPENDENCIES 1 1 "" "${PREREQ_DIRS_LIST_REBUILT}") - - - foreach(DEPENDENCY_FILE ${DEPENDENCIES}) - # get file name to be able to resolve files with @rpath on macOS - get_filename_component(PREREQNAME "${DEPENDENCY_FILE}" NAME) - gp_resolve_item(${DDS_AGENT_BIN_PATH} "${PREREQNAME}" "" "${PREREQ_DIRS_LIST_REBUILT}" resolved_file) - message("WN PKG prerequisite='${resolved_file}'") - file(COPY ${resolved_file} DESTINATION ${PREREQ_DESTINATION}) - endforeach() - ################################################### - -#endmacro(DDS_CollectPrerequisites) \ No newline at end of file diff --git a/cmake/modules/DDS_CollectPrerequisitesGen.cmake.in b/cmake/modules/DDS_CollectPrerequisitesGen.cmake.in deleted file mode 100644 index 67595852..00000000 --- a/cmake/modules/DDS_CollectPrerequisitesGen.cmake.in +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2017 GSI, Inc. All rights reserved. -# -# -include(GetPrerequisites) - -# WORKAROUND: if "macro" is used it doesn't outoup "message" messages. -#macro(DDS_CollectPrerequisites) - - ################################################### - ## Collect prerequisites for WN PKG - ################################################### - message( STATUS "Using BOOST Library dir: " @DDS_BOOST_LIB_DIR@) - string(REPLACE "::" ";" PREREQ_DIRS_LIST @PREREQ_DIRS@) - message( STATUS "prerequisite dirs: " "${PREREQ_DIRS_LIST}") - - # WORKAROUND: the list comes broken into the macro, we need to rebuild it - # if we don't do that, the get_prerequisites doesn't use all avaliable directories. - # I didn't find anyother way, but rebuilt the list. - set(PREREQ_DIRS_LIST_REBUILT "") - foreach(dir ${PREREQ_DIRS_LIST}) - # message(STATU "DEBUG: " ${dir}) - LIST(APPEND PREREQ_DIRS_LIST_REBUILT ${dir}) - endforeach() - - get_prerequisites(@DDS_PREREQ_SOURCE_BIN_PATH@ DEPENDENCIES 1 1 "" "${PREREQ_DIRS_LIST_REBUILT}") - - - foreach(DEPENDENCY_FILE ${DEPENDENCIES}) - # get file name to be able to resolve files with @rpath on macOS - get_filename_component(PREREQNAME "${DEPENDENCY_FILE}" NAME) - gp_resolve_item(@DDS_PREREQ_SOURCE_BIN_PATH@ "${PREREQNAME}" "" "${PREREQ_DIRS_LIST_REBUILT}" resolved_file) - # link only third-party libs - # Skip DDS libs - if(NOT ${resolved_file} STREQUAL "@PREREQ_DESTINATION@/${PREREQNAME}") - if(${PREREQNAME} MATCHES "^libboost_*") - # skip existing files. Fixes GH-323 - if(EXISTS "@PREREQ_DESTINATION@/${PREREQNAME}") - message("DDS Commander prerequisite: creating a symlink: destination exists. SKIPPING: @PREREQ_DESTINATION@/${PREREQNAME}") - continue() - endif() - - message("DDS Commander prerequisite: creating a symlink: @PREREQ_DESTINATION@/${PREREQNAME} -> ${resolved_file}") - execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${resolved_file} "@PREREQ_DESTINATION@/${PREREQNAME}") - else() - message("DDS Commander prerequisite: skipping: ${PREREQNAME}") - endif() - endif() - endforeach() - ################################################### - -#endmacro(DDS_CollectPrerequisites)