Skip to content

Commit

Permalink
Remove worthless if (TARGET <Pkg>::all_libs) checks (TriBITSPub#299)
Browse files Browse the repository at this point in the history
Now that the MPI TPL produces MPI::all_libs, there is no more need for these
silly checks.  This also makes the code have stronger checking in case of
mistakes.
  • Loading branch information
bartlettroscoe committed May 28, 2022
1 parent 9206994 commit 700f916
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 37 deletions.
8 changes: 2 additions & 6 deletions tribits/core/package_arch/TribitsAddExecutable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,10 @@ function(tribits_add_executable EXE_NAME)

target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES})
foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES)
if (TARGET ${depPkg}::all_libs)
target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs)
endif()
target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs)
endforeach()
foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES)
if (TARGET ${depPkg}::all_libs)
target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs)
endif()
target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs)
endforeach()
foreach(testOnlyLib ${PARSE_TESTONLYLIBS})
target_link_libraries(${EXE_BINARY_NAME} PUBLIC
Expand Down
8 changes: 2 additions & 6 deletions tribits/core/package_arch/TribitsAddLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,11 @@ function(tribits_add_library LIBRARY_NAME_IN)
target_link_libraries(${LIBRARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES})
# ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES
foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES)
if (TARGET ${depPkg}::all_libs)
target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs)
endif()
target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs)
endforeach()
# ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES
foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES)
if (TARGET ${depPkg}::all_libs)
target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs)
endif()
target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs)
endforeach()
# IMPORTEDLIBS
foreach(importedLib ${PARSE_IMPORTEDLIBS})
Expand Down
24 changes: 11 additions & 13 deletions tribits/core/package_arch/TribitsProcessEnabledTpl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,17 @@ function(tribits_process_enabled_tpl TPL_NAME)

# Generate the <tplName>ConfigVersion.cmake file if it has not been
# created yet and add install targets for <tplName>Config[Version].cmake
if (TARGET ${TPL_NAME}::all_libs)
set(buildDirExternalPkgsDir
"${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}")
set(tplConfigFile
"${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}Config.cmake")
set(tplConfigVersionFile
"${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}ConfigVersion.cmake")
tribits_external_package_write_config_version_file(${TPL_NAME}
"${tplConfigVersionFile}")
tribits_external_package_install_config_file(${TPL_NAME} "${tplConfigFile}")
tribits_external_package_install_config_version_file(${TPL_NAME}
"${tplConfigVersionFile}")
endif()
set(buildDirExternalPkgsDir
"${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}")
set(tplConfigFile
"${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}Config.cmake")
set(tplConfigVersionFile
"${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}ConfigVersion.cmake")
tribits_external_package_write_config_version_file(${TPL_NAME}
"${tplConfigVersionFile}")
tribits_external_package_install_config_file(${TPL_NAME} "${tplConfigFile}")
tribits_external_package_install_config_version_file(${TPL_NAME}
"${tplConfigVersionFile}")

endif()

Expand Down
13 changes: 1 addition & 12 deletions tribits/core/package_arch/TribitsWriteClientExportFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,7 @@ function(tribits_append_dependent_package_config_file_includes_and_enables packa
if (${depPkg}_PACKAGE_BUILD_STATUS STREQUAL "INTERNAL")
set(packageConfigBaseDir "${pkgConfigFileBaseDir}/${depPkg}")
elseif (${depPkg}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL")
if (TARGET ${depPkg}::all_libs) # See below NOTE for this if() statement
set(packageConfigBaseDir "${extPkgConfigFileBaseDir}/${depPkg}")
endif()
set(packageConfigBaseDir "${extPkgConfigFileBaseDir}/${depPkg}")
else()
message(FATAL_ERROR "ERROR: ${depPkg}_PACKAGE_BUILD_STATUS='${${depPkg}_PACKAGE_BUILD_STATUS}' invalid!")
endif()
Expand All @@ -596,15 +594,6 @@ function(tribits_append_dependent_package_config_file_includes_and_enables packa
"include(\"${packageConfigBaseDir}/${depPkg}Config.cmake\")\n")
endif()
endforeach()
# NOTE: Above, every external package/TPL does not have a
# <tplName>Config.cmake file written for it. For example, special TPLs like
# "MPI" don't have this file created or have an MPI::all_libs target
# created. Therefore, we check for the definition of the target
# <tplName>::all_libs before we include the file above. Also, note that in
# the future, compliant external packages that don't need a wrapper
# <tplName>Config.cmake file created for them will not have a wrapper
# located under "${extPkgConfigFileBaseDir}/". In that case, we will need
# to refactor the code to set <tplName>_DIR and then run find_dependency().

# Set the output
set(${PARSE_CONFIG_FILE_STR_INOUT} "${configFileStr}" PARENT_SCOPE)
Expand Down

0 comments on commit 700f916

Please sign in to comment.