From fb5fdb81b70ac4c49e9e356fd1dfb8aecbeb2c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20Schl=C3=B6mer?= Date: Wed, 8 Apr 2015 10:43:26 +0200 Subject: [PATCH] Prune export libraries and package lists from Config.cmake files (TriBITS #60) This trims down the generated Config.cmake files to only contain the direct libraries and include dirs for each SE package. This commit is a squash of several smaller commits shown below. 1) start cleaning up the export files 2 export files: INCLUDE() dependencies in FOREACH loop 3) export files: remove redundant definition of CMAKE_CURRENT_LIST_DIR This variable is intrinsic to CMake since 2.8.3. 4) don't use ALL dependencies in PACKAGE_LIST We really only need the direct dependencies of the respective package. 5) typo in variable name 6) fix for Makefile exports, adapt cmake export tests 7) fix unit test 8) fix unit test 125 9) fix unit test 127 --- test/core/ExamplesUnitTests/CMakeLists.txt | 12 ++-- ...bitsWriteClientExportFiles_UnitTests.cmake | 24 ++++---- .../TribitsPackageConfigTemplate.cmake.in | 12 ++-- .../TribitsWriteClientExportFiles.cmake | 60 +++++++++++++------ 4 files changed, 66 insertions(+), 42 deletions(-) diff --git a/test/core/ExamplesUnitTests/CMakeLists.txt b/test/core/ExamplesUnitTests/CMakeLists.txt index 49842334e..eee6f6e19 100644 --- a/test/core/ExamplesUnitTests/CMakeLists.txt +++ b/test/core/ExamplesUnitTests/CMakeLists.txt @@ -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 = ''" @@ -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" @@ -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'" ) diff --git a/test/core/TribitsWriteClientExportFiles_UnitTests.cmake b/test/core/TribitsWriteClientExportFiles_UnitTests.cmake index 5426cd0ef..210a39162 100644 --- a/test/core/TribitsWriteClientExportFiles_UnitTests.cmake +++ b/test/core/TribitsWriteClientExportFiles_UnitTests.cmake @@ -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}" @@ -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}" diff --git a/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in b/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in index 65ef7c51f..ba07e57fb 100644 --- a/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in +++ b/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in @@ -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 @@ -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} diff --git a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake index df3ebad81..c341f9f62 100644 --- a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake +++ b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake @@ -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() @@ -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) @@ -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}) @@ -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() @@ -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 "") @@ -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.