Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prune export libraries and package lists #60

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
12 changes: 6 additions & 6 deletions test/core/ExamplesUnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_ALL_ST_NoFortran
"WithSubpackages_AR = '.+'"
"WithSubpackages_INCLUDE_DIRS = .+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/b/src;.+/TribitsExampleProject/packages/with_subpackages/b/src;.+/TribitsExampleProject/packages/with_subpackages/a;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/simple_cxx/src;.+/TribitsExampleProject/packages/simple_cxx/src;.+/tpls/HeaderOnlyTpl;.+/TribitsExampleProject/packages/with_subpackages/c"
"WithSubpackages_LIBRARY_DIRS = '.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/b/src;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/a;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/simple_cxx/src;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/c'"
"WithSubpackages_LIBRARIES = 'pws_c.pws_b.pws_a.simplecxx'"
"WithSubpackages_TPL_INCLUDE_DIRS = '.+/tribits/examples/tpls/HeaderOnlyTpl'"
"WithSubpackages_LIBRARIES = 'pws_c.pws_b.pws_a'"
"WithSubpackages_TPL_INCLUDE_DIRS = ''"
"WithSubpackages_TPL_LIBRARY_DIRS = ''"
"WithSubpackages_TPL_LIBRARIES = ''"
"WithSubpackages_MPI_LIBRARIES = ''"
Expand All @@ -362,8 +362,8 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_ALL_ST_NoFortran
"WithSubpackages_MPI_EXEC = '${MPI_EXEC}'"
"WithSubpackages_MPI_EXEC_MAX_NUMPROCS = '${MPI_EXEC_MAX_NUMPROCS}'"
"WithSubpackages_MPI_EXEC_NUMPROCS_FLAG = '${MPI_EXEC_NUMPROCS_FLAG}'"
"WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'"
"WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'"
"WithSubpackages_PACKAGE_LIST = 'WithSubpackagesA.WithSubpackagesB.WithSubpackagesC'"
"WithSubpackages_TPL_LIST = ''"
"-- Configuring done"
"-- Generating done"

Expand Down Expand Up @@ -598,8 +598,8 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_ALL_PT_NoFortran
PASS_REGULAR_EXPRESSION_ALL
"WithSubpackages_INCLUDE_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../include'"
"WithSubpackages_LIBRARY_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../lib'"
"WithSubpackages_LIBRARIES = 'pws_a.simplecxx'"
"WithSubpackages_PACKAGE_LIST = 'WithSubpackagesA.SimpleCxx'"
"WithSubpackages_LIBRARIES = 'pws_a'"
"WithSubpackages_PACKAGE_LIST = 'WithSubpackagesA'"
)


Expand Down
24 changes: 12 additions & 12 deletions test/core/TribitsWriteClientExportFiles_UnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ FUNCTION(UNITTEST_WRITE_SPECIALIZED_PACKAGE_EXPORT_MAKEFILE_RTOP_BEFORE_LIBS)
"SET.RTOp1_CONFIG_INCLUDED TRUE."
"SET.RTOp1_INCLUDE_DIRS .teuchos/core/include.teuchos/numeric/include.."
"SET.RTOp1_LIBRARY_DIRS .teuchos/core/src.teuchos/numeric/src.."
"SET.RTOp1_LIBRARIES .teuchoscore.teuchosnumeric.."
"SET.RTOp1_TPL_INCLUDE_DIRS .lapackhpath/include.blaspath/include.."
"SET.RTOp1_TPL_LIBRARY_DIRS .lapackhpath/lib.blashpath/lib.."
"SET.RTOp1_TPL_LIBRARIES .lapackpath/lib/liblapack.a.blaspath/lib/libblas.a.."
"SET.RTOp1_PACKAGE_LIST .Teuchos.."
"SET.RTOp1_TPL_LIST .LAPACK.BLAS.."
"SET.RTOp1_LIBRARIES .."
"SET.RTOp1_TPL_INCLUDE_DIRS .."
"SET.RTOp1_TPL_LIBRARY_DIRS .."
"SET.RTOp1_TPL_LIBRARIES .."
"SET.RTOp1_PACKAGE_LIST Teuchos."
"SET.RTOp1_TPL_LIST .."
)

UNITTEST_FILE_REGEX("${GENERATED_EXPORT_MAKEFILE}"
Expand Down Expand Up @@ -207,12 +207,12 @@ FUNCTION(UNITTEST_WRITE_SPECIALIZED_PACKAGE_EXPORT_MAKEFILE_RTOP_AFTER_LIBS)
"SET.RTOp2_CONFIG_INCLUDED TRUE."
"SET.RTOp2_INCLUDE_DIRS .rtop/include.teuchos/core/include.teuchos/numeric/include.."
"SET.RTOp2_LIBRARY_DIRS .rtop/src.teuchos/core/src.teuchos/numeric/src.."
"SET.RTOp2_LIBRARIES .rtop.teuchoscore.teuchosnumeric.."
"SET.RTOp2_TPL_INCLUDE_DIRS .lapackhpath/include.blaspath/include.."
"SET.RTOp2_TPL_LIBRARY_DIRS .lapackhpath/lib.blashpath/lib.."
"SET.RTOp2_TPL_LIBRARIES .lapackpath/lib/liblapack.a.blaspath/lib/libblas.a.."
"SET.RTOp2_PACKAGE_LIST .RTOp.Teuchos.."
"SET.RTOp2_TPL_LIST .LAPACK.BLAS.."
"SET.RTOp2_LIBRARIES .rtop."
"SET.RTOp2_TPL_INCLUDE_DIRS .."
"SET.RTOp2_TPL_LIBRARY_DIRS .."
"SET.RTOp2_TPL_LIBRARIES .."
"SET.RTOp2_PACKAGE_LIST Teuchos."
"SET.RTOp2_TPL_LIST .."
)

UNITTEST_FILE_REGEX("${GENERATED_EXPORT_MAKEFILE}"
Expand Down
12 changes: 6 additions & 6 deletions tribits/core/installation/TribitsPackageConfigTemplate.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ SET(${EXPORT_FILE_VAR_PREFIX}_INCLUDE_DIRS "${FULL_INCLUDE_DIRS_SET}")
SET(${EXPORT_FILE_VAR_PREFIX}_LIBRARY_DIRS "${FULL_LIBRARY_DIRS_SET}")

## List of package libraries
SET(${EXPORT_FILE_VAR_PREFIX}_LIBRARIES "${FULL_LIBRARY_SET}")
SET(${EXPORT_FILE_VAR_PREFIX}_LIBRARIES "${${PACKAGE_NAME}_LIBRARIES}")

## Specification of directories for TPL headers
SET(${EXPORT_FILE_VAR_PREFIX}_TPL_INCLUDE_DIRS "${${PACKAGE_NAME}_TPL_INCLUDE_DIRS}")
SET(${EXPORT_FILE_VAR_PREFIX}_TPL_INCLUDE_DIRS "${MY_${PACKAGE_NAME}_TPL_INCLUDE_DIRS}")

## Specification of directories for TPL libraries
SET(${EXPORT_FILE_VAR_PREFIX}_TPL_LIBRARY_DIRS "${${PACKAGE_NAME}_TPL_LIBRARY_DIRS}")
SET(${EXPORT_FILE_VAR_PREFIX}_TPL_LIBRARY_DIRS "${MY_${PACKAGE_NAME}_TPL_LIBRARY_DIRS}")

## List of required TPLs
SET(${EXPORT_FILE_VAR_PREFIX}_TPL_LIBRARIES "${${PACKAGE_NAME}_TPL_LIBRARIES}")
SET(${EXPORT_FILE_VAR_PREFIX}_TPL_LIBRARIES "${MY_${PACKAGE_NAME}_TPL_LIBRARIES}")

## ---------------------------------------------------------------------------
## MPI specific variables
Expand All @@ -121,9 +121,9 @@ SET(${EXPORT_FILE_VAR_PREFIX}_MPI_EXEC_NUMPROCS_FLAG "${MPI_EXEC_NUMPROCS_FLAG}"
## ---------------------------------------------------------------------------

## The packages enabled for this project
SET(${EXPORT_FILE_VAR_PREFIX}_PACKAGE_LIST "${FULL_PACKAGE_SET}")
SET(${EXPORT_FILE_VAR_PREFIX}_PACKAGE_LIST ${MY_DEP_SET})

## The TPLs enabled for this project
SET(${EXPORT_FILE_VAR_PREFIX}_TPL_LIST "${ORDERED_FULL_TPL_SET}")
SET(${EXPORT_FILE_VAR_PREFIX}_TPL_LIST "${MY_TPL_SET}")

${PACKAGE_CONFIG_CODE}
60 changes: 42 additions & 18 deletions tribits/core/package_arch/TribitsWriteClientExportFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ IF (${EXPORT_FILE_VAR_PREFIX}_CONFIG_INCLUDED)
RETURN()
ENDIF()
SET(${EXPORT_FILE_VAR_PREFIX}_CONFIG_INCLUDED TRUE)

# Make sure CMAKE_CURRENT_LIST_DIR is usable
IF (NOT DEFINED CMAKE_CURRENT_LIST_DIR)
GET_FILENAME_COMPONENT(_THIS_SCRIPT_PATH \${CMAKE_CURRENT_LIST_FILE} PATH)
SET(CMAKE_CURRENT_LIST_DIR \${_THIS_SCRIPT_PATH})
ENDIF()
"
PARENT_SCOPE )
ENDFUNCTION()
Expand Down Expand Up @@ -233,15 +227,14 @@ FUNCTION(TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES)

SET(FULL_PACKAGE_SET "")
SET(FULL_LIBRARY_SET "")
SET(FULL_INCLUDE_DIRS_SET "")
SET(FULL_LIBRARY_DIRS_SET "")

SET(SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM TRUE)
IF (${PACKAGE_NAME}_INCLUDE_DIRS)
SET(FULL_INCLUDE_DIRS_SET ${${PACKAGE_NAME}_INCLUDE_DIRS})
SET(FULL_LIBRARY_DIRS_SET ${${PACKAGE_NAME}_LIBRARY_DIRS})
SET(SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM FALSE)
ELSE()
SET(FULL_INCLUDE_DIRS_SET "")
SET(FULL_LIBRARY_DIRS_SET "")
ENDIF()

IF (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP)
Expand Down Expand Up @@ -322,12 +315,28 @@ FUNCTION(TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES)
PRINT_VAR(FULL_LIBRARY_DIRS_SET)
ENDIF()

SET(MY_DEP_SET "")
LIST(APPEND MY_DEP_SET ${${PACKAGE_NAME}_LIB_REQUIRED_DEP_PACKAGES})
FOREACH(DEP ${${PACKAGE_NAME}_LIB_OPTIONAL_DEP_PACKAGES})
IF(${PACKAGE_NAME}_ENABLE_${DEP})
LIST(APPEND MY_DEP_SET ${DEP})
ENDIF()
ENDFOREACH()

#
# C) Get the set of TPLs for this package that are enabled
#

# C.1) Get the set of enabled TPLs

SET(MY_TPL_SET "")
LIST(APPEND MY_TPL_SET ${${PACKAGE_NAME}_LIB_REQUIRED_DEP_TPLS})
FOREACH(TPL ${${PACKAGE_NAME}_LIB_OPTIONAL_DEP_TPLS})
IF(${PACKAGE_NAME}_ENABLE_${TPL})
LIST(APPEND MY_TPL_SET ${TPL})
ENDIF()
ENDFOREACH()

SET(FULL_TPL_SET "")
FOREACH(TRIBITS_PACKAGE ${FULL_PACKAGE_SET})
LIST(APPEND FULL_TPL_SET ${${TRIBITS_PACKAGE}_LIB_REQUIRED_DEP_TPLS})
Expand All @@ -340,6 +349,17 @@ FUNCTION(TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES)
ENDIF()
ENDFOREACH()
ENDFOREACH()
FOREACH(TRIBITS_PACKAGE ${FULL_PACKAGE_SET})
LIST(APPEND FULL_TPL_SET ${${TRIBITS_PACKAGE}_LIB_REQUIRED_DEP_TPLS})
SET(OPTIONAL_TPLS ${${TRIBITS_PACKAGE}_LIB_OPTIONAL_DEP_TPLS})
FOREACH(TPL ${OPTIONAL_TPLS})
# Only add if support for the optional TPL is enabled in this
# package. Don't just check if the TPL is enabled!
IF(${TRIBITS_PACKAGE}_ENABLE_${TPL})
LIST(APPEND FULL_TPL_SET ${TPL})
ENDIF()
ENDFOREACH()
ENDFOREACH()
IF (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP)
PRINT_VAR(FULL_TPL_SET)
ENDIF()
Expand All @@ -362,6 +382,14 @@ FUNCTION(TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES)
# D) Get the libraries, library dirs, and the include dirs for the
# upstream enabled TPLs
#
SET(MY_${PACKAGE_NAME}_TPL_LIBRARIES "")
SET(MY_${PACKAGE_NAME}_TPL_INCLUDE_DIRS "")
SET(MY_${PACKAGE_NAME}_TPL_LIBRARY_DIRS "")
FOREACH(TPL ${MY_TPL_SET})
LIST(APPEND MY_${PACKAGE_NAME}_TPL_LIBRARIES ${TPL_${TPL}_LIBRARIES})
LIST(APPEND MY_${PACKAGE_NAME}_TPL_INCLUDE_DIRS ${TPL_${TPL}_INCLUDE_DIRS})
LIST(APPEND MY_${PACKAGE_NAME}_TPL_LIBRARY_DIRS ${TPL_${TPL}_LIBRARY_DIRS})
ENDFOREACH()

SET(${PACKAGE_NAME}_TPL_LIBRARIES "")
SET(${PACKAGE_NAME}_TPL_INCLUDE_DIRS "")
Expand Down Expand Up @@ -514,15 +542,11 @@ INCLUDE(\"${${PROJECT_NAME}_BINARY_DIR}/${PROJECT_NAME}Targets.cmake\")"

IF (${PACKAGE_NAME}_FULL_ENABLED_DEP_PACKAGES)
SET(PACKAGE_CONFIG_CODE "${PACKAGE_CONFIG_CODE}
# Include configuration of dependent packages")
ENDIF()
FOREACH(DEP_PACKAGE ${${PACKAGE_NAME}_FULL_ENABLED_DEP_PACKAGES})
SET(PACKAGE_CONFIG_CODE "${PACKAGE_CONFIG_CODE}
INCLUDE(\"\${CMAKE_CURRENT_LIST_DIR}/../${DEP_PACKAGE}/${DEP_PACKAGE}Config.cmake\")"
)
ENDFOREACH()
IF(${PACKAGE_NAME}_FULL_ENABLED_DEP_PACKAGES)
SET(PACKAGE_CONFIG_CODE "${PACKAGE_CONFIG_CODE}\n")
# Include configuration of dependent packages
FOREACH(DEP_PACKAGE \${${PACKAGE_NAME}_PACKAGE_LIST})
INCLUDE(\"\${CMAKE_CURRENT_LIST_DIR}/../\${DEP_PACKAGE}/\${DEP_PACKAGE}Config.cmake\")
ENDFOREACH()
")
ENDIF()

# Import install tree targets into applications.
Expand Down