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

Add support for FindTPL<tplName>Dependencies.cmake and doc updates (#63, #299, #494) #495

Merged
merged 8 commits into from
Jul 15, 2022
16 changes: 15 additions & 1 deletion test/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ tribits_add_advanced_test( TribitsWriteClientExportFiles_UnitTests
)


tribits_add_advanced_test( TribitsPackageDependencies_UnitTests
OVERALL_WORKING_DIRECTORY TEST_NAME
TEST_0 CMND ${CMAKE_COMMAND}
ARGS
-DPROJECT_NAME=${PROJECT_NAME}
-D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-DCURRENT_TEST_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}
-P "${CMAKE_CURRENT_SOURCE_DIR}/TribitsPackageDependencies_UnitTests.cmake"
PASS_REGULAR_EXPRESSION_ALL
"Final UnitTests Result: num_run = 13"
"Final UnitTests Result: PASSED"
)


tribits_add_advanced_test( TribitsExternalPackageWriteConfigFile_UnitTests
OVERALL_WORKING_DIRECTORY TEST_NAME
TEST_0 CMND ${CMAKE_COMMAND}
Expand All @@ -145,7 +159,7 @@ tribits_add_advanced_test( TribitsExternalPackageWriteConfigFile_UnitTests
-DCURRENT_TEST_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}
-P "${CMAKE_CURRENT_SOURCE_DIR}/TribitsExternalPackageWriteConfigFile_UnitTests.cmake"
PASS_REGULAR_EXPRESSION_ALL
"Final UnitTests Result: num_run = 85"
"Final UnitTests Result: num_run = 74"
"Final UnitTests Result: PASSED"
)

Expand Down
67 changes: 1 addition & 66 deletions test/core/TribitsExternalPackageWriteConfigFile_UnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -191,69 +191,6 @@ function(unittest_tribits_external_package_get_libname_from_full_lib_path_apple)
endfunction()


#
# Test for tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis()
#


function(unittest_tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis)

message("\n***")
message("*** Testing tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis")
message("***\n")

set(MESSAGE_WRAPPER_UNIT_TEST_MODE TRUE)

message("\nTesting default visibility\n")
global_set(MESSAGE_WRAPPER_INPUT "")
tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis(
SomePackage upstreamTplDepNameOut upstreamTplDepVisOut)
unittest_compare_const( upstreamTplDepNameOut
"SomePackage" )
unittest_compare_const( upstreamTplDepVisOut
"PRIVATE" )
unittest_compare_const(MESSAGE_WRAPPER_INPUT "")

message("\nTesting PUBLIC\n")
global_set(MESSAGE_WRAPPER_INPUT "")
tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis(
SomePackage:PUBLIC upstreamTplDepNameOut upstreamTplDepVisOut)
unittest_compare_const( upstreamTplDepNameOut
SomePackage )
unittest_compare_const( upstreamTplDepVisOut
"PUBLIC" )
unittest_compare_const(MESSAGE_WRAPPER_INPUT "")

message("\nTesting PRIVATE\n")
global_set(MESSAGE_WRAPPER_INPUT "")
tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis(
SomePackage:PRIVATE upstreamTplDepNameOut upstreamTplDepVisOut)
unittest_compare_const( upstreamTplDepNameOut
SomePackage )
unittest_compare_const( upstreamTplDepVisOut
"PRIVATE" )
unittest_compare_const(MESSAGE_WRAPPER_INPUT "")

message("\nTesting invalid visibility\n")
global_set(MESSAGE_WRAPPER_INPUT "")
tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis(
SomePackage:SPELLEDWRONG upstreamTplDepNameOut upstreamTplDepVisOut)
unittest_compare_const(MESSAGE_WRAPPER_INPUT
"FATAL_ERROR;ERROR: 'SomePackage:SPELLEDWRONG' has invalid visibility 'SPELLEDWRONG'.; Only 'PUBLIC' or 'PRIVATE' allowed!")

message("\nTesting more than two elements splitting on ':'\n")
global_set(MESSAGE_WRAPPER_INPUT "")
tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis(
SomePackage:BadExtraEntry:PRIVATE upstreamTplDepNameOut upstreamTplDepVisOut)
unittest_compare_const(MESSAGE_WRAPPER_INPUT
"FATAL_ERROR;ERROR: 'SomePackage:BadExtraEntry:PRIVATE' has 2 ':' but only 1 is allowed!")

# Reset global state
global_set(MESSAGE_WRAPPER_INPUT "")

endfunction()


#
# Tests for tribits_external_package_process_libraries_list_incl()
#
Expand Down Expand Up @@ -1277,8 +1214,6 @@ unittest_tribits_external_package_get_libname_from_full_lib_path_linux()
unittest_tribits_external_package_get_libname_from_full_lib_path_win32()
unittest_tribits_external_package_get_libname_from_full_lib_path_apple()

unittest_tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis()

unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_1()
unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_2()
unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_3()
Expand All @@ -1303,4 +1238,4 @@ unittest_tribits_external_package_write_config_file_str_incl_dirs_1_bad_lib_args
unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib_opts_2_2_deps_3()

# Pass in the number of expected tests that must pass!
unittest_final_result(85)
unittest_final_result(74)
187 changes: 187 additions & 0 deletions test/core/TribitsPackageDependencies_UnitTests.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# @HEADER
# ************************************************************************
#
# TriBITS: Tribal Build, Integrate, and Test System
# Copyright 2013 Sandia Corporation
#
# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
# the U.S. Government retains certain rights in this software.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Corporation nor the names of the
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ************************************************************************
# @HEADER

# Echo input arguments
message("PROJECT_NAME = '${PROJECT_NAME}'")
message("${PROJECT_NAME}_TRIBITS_DIR = '${${PROJECT_NAME}_TRIBITS_DIR}'")
message("CURRENT_TEST_DIRECTORY = '${CURRENT_TEST_DIRECTORY}'")

set( CMAKE_MODULE_PATH
"${${PROJECT_NAME}_TRIBITS_DIR}/core/utils"
"${${PROJECT_NAME}_TRIBITS_DIR}/core/package_arch"
)

include(TribitsPackageDependencies)

include(UnitTestHelpers)
include(GlobalNullSet)


#####################################################################
#
# Unit tests for code in TribitsPackageDependencies.cmake
#
#####################################################################


#
# Tests for tribits_external_package_get_dep_name_and_vis()
#


function(unittest_tribits_external_package_get_dep_name_and_vis)

message("\n***")
message("*** Testing tribits_external_package_get_dep_name_and_vis()")
message("***\n")

set(MESSAGE_WRAPPER_UNIT_TEST_MODE TRUE)

message("\nTesting default visibility\n")
global_set(MESSAGE_WRAPPER_INPUT "")
tribits_external_package_get_dep_name_and_vis(
SomePackage upstreamTplDepNameOut upstreamTplDepVisOut)
unittest_compare_const( upstreamTplDepNameOut
"SomePackage" )
unittest_compare_const( upstreamTplDepVisOut
"PRIVATE" )
unittest_compare_const(MESSAGE_WRAPPER_INPUT "")

message("\nTesting PUBLIC\n")
global_set(MESSAGE_WRAPPER_INPUT "")
tribits_external_package_get_dep_name_and_vis(
SomePackage:PUBLIC upstreamTplDepNameOut upstreamTplDepVisOut)
unittest_compare_const( upstreamTplDepNameOut
SomePackage )
unittest_compare_const( upstreamTplDepVisOut
"PUBLIC" )
unittest_compare_const(MESSAGE_WRAPPER_INPUT "")

message("\nTesting PRIVATE\n")
global_set(MESSAGE_WRAPPER_INPUT "")
tribits_external_package_get_dep_name_and_vis(
SomePackage:PRIVATE upstreamTplDepNameOut upstreamTplDepVisOut)
unittest_compare_const( upstreamTplDepNameOut
SomePackage )
unittest_compare_const( upstreamTplDepVisOut
"PRIVATE" )
unittest_compare_const(MESSAGE_WRAPPER_INPUT "")

message("\nTesting invalid visibility\n")
global_set(MESSAGE_WRAPPER_INPUT "")
tribits_external_package_get_dep_name_and_vis(
SomePackage:SPELLEDWRONG upstreamTplDepNameOut upstreamTplDepVisOut)
unittest_compare_const(MESSAGE_WRAPPER_INPUT
"FATAL_ERROR;ERROR: 'SomePackage:SPELLEDWRONG' has invalid visibility 'SPELLEDWRONG'.; Only 'PUBLIC' or 'PRIVATE' allowed!")

message("\nTesting more than two elements splitting on ':'\n")
global_set(MESSAGE_WRAPPER_INPUT "")
tribits_external_package_get_dep_name_and_vis(
SomePackage:BadExtraEntry:PRIVATE upstreamTplDepNameOut upstreamTplDepVisOut)
unittest_compare_const(MESSAGE_WRAPPER_INPUT
"FATAL_ERROR;ERROR: 'SomePackage:BadExtraEntry:PRIVATE' has 2 ':' but only 1 is allowed!")

# Reset global state
global_set(MESSAGE_WRAPPER_INPUT "")

endfunction()


#
# Tests for tribits_external_package_define_dependencies()
#


function(unittest_tribits_external_package_define_dependencies_basic)

message("\n***")
message("*** ${CMAKE_CURRENT_FUNCTION}()")
message("***\n")

tribits_external_package_define_dependencies(someExtPkg
DEPENDENCIES upPkg1 upPkg2:PUBLIC upPkg3:PRIVATE upPkg4)
unittest_compare_const( someExtPkg_LIB_ALL_DEPENDENCIES
"upPkg1;upPkg2:PUBLIC;upPkg3:PRIVATE;upPkg4" )

endfunction()


#
# Tests for tribits_external_package_setup_enabled_dependencies()
#


function(unittest_tribits_external_package_setup_enabled_dependencies)

message("\n***")
message("*** ${CMAKE_CURRENT_FUNCTION}()")
message("***\n")

tribits_external_package_define_dependencies(someExtPkg
DEPENDENCIES upPkg1 upPkg2:PUBLIC upPkg3:PRIVATE upPkg4)
set(TPL_ENABLE_someExtPkg ON)
set(TPL_ENABLE_upPkg1 ON)
set(TPL_ENABLE_upPkg3 ON)
tribits_external_package_setup_enabled_dependencies(someExtPkg)
unittest_compare_const( someExtPkg_LIB_ENABLED_DEPENDENCIES
"upPkg1;upPkg3:PRIVATE" )

endfunction()


#####################################################################
#
# Execute the unit tests
#
#####################################################################

unittest_initialize_vars()

#
# Run the unit tests
#

unittest_tribits_external_package_get_dep_name_and_vis()

unittest_tribits_external_package_define_dependencies_basic()

unittest_tribits_external_package_setup_enabled_dependencies()

# Pass in the number of expected tests that must pass!
unittest_final_result(13)
17 changes: 14 additions & 3 deletions tribits/core/package_arch/TribitsAdjustPackageEnables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ include(TribitsProcessPackagesAndDirsLists)
include(TribitsAddOptionAndDefine)
include(TribitsGeneralMacros)
include(TribitsPrintEnabledPackagesLists)
include(TribitsPackageDependencies)

include(AdvancedOption)
include(AdvancedSet)
Expand Down Expand Up @@ -588,7 +589,9 @@ endmacro()
# packages where only the shell of the parent package is enabled and not
# all of its required subpackages are enabled.
#
macro(tribits_setup_direct_package_dependencies_lists_and_lib_required_enable_vars packageName)
macro(tribits_setup_direct_package_dependencies_lists_and_lib_required_enable_vars
packageName
)

# LIB dependencies

Expand Down Expand Up @@ -1470,10 +1473,18 @@ macro(tribits_adjust_package_enables)
tribits_set_up_enabled_lists_and_se_pkg_idx()

#
# H) Set up flat list of direct package dependencies (even for non-enabled
# packages) and enabled package dependencies for enabled packages
# H) Set up flat list of direct external and inner package dependencies (even
# for non-enabled packages) and enabled package dependencies for enabled
# packages
#

foreach(externalPkgName ${${PROJECT_NAME}_TPLS})
tribits_external_package_setup_enabled_dependencies(${externalPkgName})
# ToDo: Assert that all of the listed dependencies in
# ${externalPkgName}_LIB_ENABLED_DEPENDENCIES exist and are upstream from
# ${externalPkgName}
endforeach()

foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_SE_PACKAGES})
tribits_setup_direct_package_dependencies_lists_and_lib_required_enable_vars(
${TRIBITS_PACKAGE})
Expand Down
Loading