diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e60d8128c0417e157de8c4dfbd27184b21f1cea..b729fa0e3aa2be2cf76e6528b0a77e46d432a884 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,11 @@ include(GNUInstallDirs) string(COMPARE EQUAL "${CMAKE_PROJECT_NAME}" "${PROJECT_NAME}" IS_TOP_LEVEL) +if (IS_TOP_LEVEL) + include(CTest) + set(CMAKE_CTEST_ARGUMENTS "--verbose") +endif () + # LoadStaticSharedTargets is a CMake script, which we never want to debug # If using a multi config generator if (GENERATOR_IS_MULTI_CONFIG) @@ -48,6 +53,10 @@ endif () add_subdirectory(src) +if (IS_TOP_LEVEL AND BUILD_TESTING) + add_subdirectory(tests) +endif () + option(LoadStaticSharedTargets_INCLUDE_PACKAGING "Include packaging rules for LoadStaticSharedTargets" "${IS_TOP_LEVEL}") if (LoadStaticSharedTargets_INCLUDE_PACKAGING) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..dee4f65c8b868347c424cb54cd2725af10bd4166 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,85 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +set( + TEST_CASES + "common-failures_test-case-01" + "common-failures_test-case-02" + "include-requested-by-common-flag_test-case-01" + "include-requested-by-common-flag_test-case-04" + "include-requested-by-common-flag_test-case-07" + "include-requested-by-common-flag_test-case-10" + "include-requested-by-component_test-case-01" + "include-requested-by-component_test-case-02" + "include-requested-by-component_test-case-03" + "include-requested-by-component_test-case-04" + "include-requested-by-component_test-case-05" + "include-requested-by-component_test-case-06" + "include-requested-by-component_test-case-07" + "include-requested-by-component_test-case-08" + "include-requested-by-package-flag_test-case-01" + "include-requested-by-package-flag_test-case-02" + "include-requested-by-package-flag_test-case-03" + "include-requested-by-package-flag_test-case-04" + "include-requested-by-package-flag_test-case-05" + "include-requested-by-package-flag_test-case-06" + "include-requested-by-package-flag_test-case-07" + "include-requested-by-package-flag_test-case-08" +) + +set( + TEST_CASES_WITH_WARNING + "include-requested-by-common-flag_test-case-02" + "include-requested-by-common-flag_test-case-03" + "include-requested-by-common-flag_test-case-05" + "include-requested-by-common-flag_test-case-06" + "include-requested-by-common-flag_test-case-08" + "include-requested-by-common-flag_test-case-09" + "include-requested-by-common-flag_test-case-11" + "include-requested-by-common-flag_test-case-12" +) + +foreach (TEST_CASE IN LISTS TEST_CASES TEST_CASES_WITH_WARNING) + add_test( + NAME "${TEST_CASE}" + COMMAND "${CMAKE_COMMAND}" -D CMAKE_MINIMUM_REQUIRED_VERSION=${CMAKE_MINIMUM_REQUIRED_VERSION} -D "TEST_CASE=${TEST_CASE}" -P "./helpers/test_case_wrapper.cmake" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + ) +endforeach () + +foreach (TEST_CASE IN LISTS TEST_CASES_WITH_WARNING) + add_test( + NAME "${TEST_CASE}_check-warning" + COMMAND "${CMAKE_COMMAND}" -D CMAKE_MINIMUM_REQUIRED_VERSION=${CMAKE_MINIMUM_REQUIRED_VERSION} -D "TEST_CASE=${TEST_CASE}" -P "./helpers/test_case_wrapper.cmake" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + ) + + set_tests_properties( + "${TEST_CASE}_check-warning" + PROPERTIES + PASS_REGULAR_EXPRESSION + "Requested `.+` targets for package .+ were not found\\.;Trying alternative `.+` targets\\." + ) +endforeach () diff --git a/tests/common-failures_test-case-01.cmake b/tests/common-failures_test-case-01.cmake new file mode 100644 index 0000000000000000000000000000000000000000..57e5f6452195978eab53ae6d13bba7997d622381 --- /dev/null +++ b/tests/common-failures_test-case-01.cmake @@ -0,0 +1,50 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) + + +TEST_CASE("Fail, if unknown find component is being used: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS "unknown") + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} does not recognize component `unknown`." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) +REQUIRE_UNDEFINED(TEST_TARGET_1) +REQUIRE_UNDEFINED(TEST_TARGET_2) diff --git a/tests/common-failures_test-case-02.cmake b/tests/common-failures_test-case-02.cmake new file mode 100644 index 0000000000000000000000000000000000000000..b94ba343a96529f075567600335dcf3455b1e021 --- /dev/null +++ b/tests/common-failures_test-case-02.cmake @@ -0,0 +1,50 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) + + +TEST_CASE("Fail, if both `shared` and `static` find components are being used together: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS "shared" "static") + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `static` and `shared` components are mutually exclusive." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) +REQUIRE_UNDEFINED(TEST_TARGET_1) +REQUIRE_UNDEFINED(TEST_TARGET_2) diff --git a/tests/helpers/assertions.cmake b/tests/helpers/assertions.cmake new file mode 100644 index 0000000000000000000000000000000000000000..42fdb29dd7e41252ddce40b0b9482de8b8be6128 --- /dev/null +++ b/tests/helpers/assertions.cmake @@ -0,0 +1,116 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +macro(TEST_CASE DESCRIPTION) + message(NOTICE "${DESCRIPTION}") +endmacro() + +macro(REQUIRE_FALSY VAR_NAME) + if (NOT DEFINED ${VAR_NAME}) + message(FATAL_ERROR "${VAR_NAME} is NOT DEFINED!") + elseif (${VAR_NAME}) + message(FATAL_ERROR "${VAR_NAME} is TRUTHY!") + else () + message(STATUS "${VAR_NAME} is DEFINED and FALSY.") + endif () +endmacro() + +macro(CHECK_FALSY VAR_NAME) + if (NOT DEFINED ${VAR_NAME}) + message(SEND_ERROR "${VAR_NAME} is NOT DEFINED!") + elseif (${VAR_NAME}) + message(SEND_ERROR "${VAR_NAME} is TRUTHY!") + else () + message(STATUS "${VAR_NAME} is DEFINED and FALSY.") + endif () +endmacro() + +macro(REQUIRE_TRUTHY VAR_NAME) + if (NOT DEFINED ${VAR_NAME}) + message(FATAL_ERROR "${VAR_NAME} is NOT DEFINED!") + elseif (NOT ${VAR_NAME}) + message(FATAL_ERROR "${VAR_NAME} is FALSY!") + else () + message(STATUS "${VAR_NAME} is DEFINED and TRUTHY.") + endif () +endmacro() + +macro(CHECK_TRUTHY VAR_NAME) + if (NOT DEFINED ${VAR_NAME}) + message(SEND_ERROR "${VAR_NAME} is NOT DEFINED!") + elseif (NOT ${VAR_NAME}) + message(SEND_ERROR "${VAR_NAME} is FALSY!") + else () + message(STATUS "${VAR_NAME} is DEFINED and TRUTHY.") + endif () +endmacro() + +macro(REQUIRE_UNDEFINED VAR_NAME) + if (DEFINED ${VAR_NAME}) + message(FATAL_ERROR "${VAR_NAME} is DEFINED!") + else () + message(STATUS "${VAR_NAME} is NOT DEFINED.") + endif () +endmacro() + +macro(CHECK_UNDEFINED VAR_NAME) + if (DEFINED ${VAR_NAME}) + message(SEND_ERROR "${VAR_NAME} is DEFINED!") + else () + message(STATUS "${VAR_NAME} is NOT DEFINED.") + endif () +endmacro() + +macro(REQUIRE_DEFINED VAR_NAME) + if (NOT DEFINED ${VAR_NAME}) + message(FATAL_ERROR "${VAR_NAME} is NOT DEFINED!") + else () + message(STATUS "${VAR_NAME} is DEFINED.") + endif () +endmacro() + +macro(CHECK_DEFINED VAR_NAME) + if (NOT DEFINED ${VAR_NAME}) + message(SEND_ERROR "${VAR_NAME} is NOT DEFINED!") + else () + message(STATUS "${VAR_NAME} is DEFINED.") + endif () +endmacro() + +macro(REQUIRE_STREQUAL VAR_NAME VALUE) + if (NOT ${VAR_NAME} STREQUAL "${VALUE}") + message(FATAL_ERROR "${VAR_NAME} with value `${${VAR_NAME}}` is NOT STREQUAL to `${VALUE}`!") + else () + message(STATUS "${VAR_NAME} is STREQUAL to `${VALUE}`.") + endif () +endmacro() + +macro(CHECK_STREQUAL VAR_NAME VALUE) + if (NOT ${VAR_NAME} STREQUAL "${VALUE}") + message(SEND_ERROR "${VAR_NAME} with value `${${VAR_NAME}}` is NOT STREQUAL to `${VALUE}`!") + else () + message(STATUS "${VAR_NAME} is STREQUAL to `${VALUE}`.") + endif () +endmacro() diff --git a/tests/helpers/test_case_wrapper.cmake b/tests/helpers/test_case_wrapper.cmake new file mode 100644 index 0000000000000000000000000000000000000000..744a3e0f56c2d3f6b600eb1409342ff0a9db3531 --- /dev/null +++ b/tests/helpers/test_case_wrapper.cmake @@ -0,0 +1,34 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +cmake_policy(VERSION ${CMAKE_MINIMUM_REQUIRED_VERSION}) + +include("./helpers/assertions.cmake") +include("../src/cmake/LoadStaticSharedTargets.cmake") + +# find_package() mock +set(CMAKE_FIND_PACKAGE_NAME "test") + +include("./${TEST_CASE}.cmake") diff --git a/tests/helpers/testee_macro_wrapper.cmake b/tests/helpers/testee_macro_wrapper.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6b699ad3a22f61cca3b5a8bcb299a60c5ef530a8 --- /dev/null +++ b/tests/helpers/testee_macro_wrapper.cmake @@ -0,0 +1,32 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +# This wrapper is necessary to capture return() commands in the macro +load_static_shared_targets( + STATIC_TARGETS + ${STATIC_TEST_TARGET_FILES} + SHARED_TARGETS + ${SHARED_TEST_TARGET_FILES} +) diff --git a/tests/include-requested-by-common-flag_test-case-01.cmake b/tests/include-requested-by-common-flag_test-case-01.cmake new file mode 100644 index 0000000000000000000000000000000000000000..4041d69a3cd8cd5a8eb387fcb865139cfcbd744b --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-01.cmake @@ -0,0 +1,41 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one shared target by common flag (`BUILD_SHARED_LIBS`): ") + +set(BUILD_SHARED_LIBS TRUE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/success-target1.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) diff --git a/tests/include-requested-by-common-flag_test-case-02.cmake b/tests/include-requested-by-common-flag_test-case-02.cmake new file mode 100644 index 0000000000000000000000000000000000000000..fc2921051ec321cf39d26d6b40e29f74672704b2 --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-02.cmake @@ -0,0 +1,41 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one shared target by common flag, but it doesn't exist. Include static target instead: ") + +set(BUILD_SHARED_LIBS TRUE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/success-target1.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/i-do-not-exist" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) diff --git a/tests/include-requested-by-common-flag_test-case-03.cmake b/tests/include-requested-by-common-flag_test-case-03.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3313f0f5a006d88c4c437ec903a6ff00ae0e5a04 --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-03.cmake @@ -0,0 +1,45 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one shared target by common flag, but neither the shared nor the static target exist: ") + +set(BUILD_SHARED_LIBS TRUE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/i-do-not-exist" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/i-do-not-exist" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `STATIC` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) diff --git a/tests/include-requested-by-common-flag_test-case-04.cmake b/tests/include-requested-by-common-flag_test-case-04.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e6d5de0ef2b8b007dbaf9982f38f51f506913f9c --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-04.cmake @@ -0,0 +1,44 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple shared targets by common flag (`BUILD_SHARED_LIBS`): ") + +set(BUILD_SHARED_LIBS TRUE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/success-target1.cmake" + "./mocks/success-target2.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) +REQUIRE_TRUTHY(TEST_TARGET_2) diff --git a/tests/include-requested-by-common-flag_test-case-05.cmake b/tests/include-requested-by-common-flag_test-case-05.cmake new file mode 100644 index 0000000000000000000000000000000000000000..51bb9c221edae1c0048dd406fb40dc60aecd21a6 --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-05.cmake @@ -0,0 +1,44 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple shared targets by common flag, but one doesn't exist. Include static targets instead: ") + +set(BUILD_SHARED_LIBS TRUE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/success-target1.cmake" + "./mocks/success-target2.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/i-do-not-exist" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) +REQUIRE_TRUTHY(TEST_TARGET_2) diff --git a/tests/include-requested-by-common-flag_test-case-06.cmake b/tests/include-requested-by-common-flag_test-case-06.cmake new file mode 100644 index 0000000000000000000000000000000000000000..9b9517b8bed29a9b2b90f256456f569a94e70f20 --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-06.cmake @@ -0,0 +1,47 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple shared targets by common flag, but neither the shared nor the static targets exist: ") + +set(BUILD_SHARED_LIBS TRUE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/i-do-not-exist" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/i-do-not-exist" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `STATIC` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) diff --git a/tests/include-requested-by-common-flag_test-case-07.cmake b/tests/include-requested-by-common-flag_test-case-07.cmake new file mode 100644 index 0000000000000000000000000000000000000000..fe237c352ae60b73bd30ff8c609b031c58858cf1 --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-07.cmake @@ -0,0 +1,41 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one static target by common flag (`BUILD_SHARED_LIBS`): ") + +set(BUILD_SHARED_LIBS FALSE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/success-target1.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) diff --git a/tests/include-requested-by-common-flag_test-case-08.cmake b/tests/include-requested-by-common-flag_test-case-08.cmake new file mode 100644 index 0000000000000000000000000000000000000000..480db26291819f155a37491b9afff8f464eaba96 --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-08.cmake @@ -0,0 +1,41 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one static target by common flag, but it doesn't exist. Include shared target instead: ") + +set(BUILD_SHARED_LIBS FALSE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/i-do-not-exist" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/success-target1.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) diff --git a/tests/include-requested-by-common-flag_test-case-09.cmake b/tests/include-requested-by-common-flag_test-case-09.cmake new file mode 100644 index 0000000000000000000000000000000000000000..286ce232dfb9aef997d7426700fcda6d09fea15a --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-09.cmake @@ -0,0 +1,45 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one static target by common flag, but neither the static nor the shared target exist: ") + +set(BUILD_SHARED_LIBS FALSE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/i-do-not-exist" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/i-do-not-exist" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `SHARED` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) diff --git a/tests/include-requested-by-common-flag_test-case-10.cmake b/tests/include-requested-by-common-flag_test-case-10.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3f86dc63bde95830b67530dd800ce6bed2d09821 --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-10.cmake @@ -0,0 +1,44 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple static targets by common flag (`BUILD_SHARED_LIBS`): ") + +set(BUILD_SHARED_LIBS FALSE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/success-target1.cmake" + "./mocks/success-target2.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) +REQUIRE_TRUTHY(TEST_TARGET_2) diff --git a/tests/include-requested-by-common-flag_test-case-11.cmake b/tests/include-requested-by-common-flag_test-case-11.cmake new file mode 100644 index 0000000000000000000000000000000000000000..f9a80827e6d31d2668297b1575ddfbed2288bfa4 --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-11.cmake @@ -0,0 +1,44 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple static targets by common flag, but one doesn't exist. Include shared targets instead: ") + +set(BUILD_SHARED_LIBS FALSE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/i-do-not-exist" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/success-target1.cmake" + "./mocks/success-target2.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) +REQUIRE_TRUTHY(TEST_TARGET_2) diff --git a/tests/include-requested-by-common-flag_test-case-12.cmake b/tests/include-requested-by-common-flag_test-case-12.cmake new file mode 100644 index 0000000000000000000000000000000000000000..219e93dda44e3ead85534ea4abbbd59d34a217cb --- /dev/null +++ b/tests/include-requested-by-common-flag_test-case-12.cmake @@ -0,0 +1,47 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple static targets by common flag, but neither the static nor the shared targets exist: ") + +set(BUILD_SHARED_LIBS FALSE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/i-do-not-exist" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/i-do-not-exist" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `SHARED` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) diff --git a/tests/include-requested-by-component_test-case-01.cmake b/tests/include-requested-by-component_test-case-01.cmake new file mode 100644 index 0000000000000000000000000000000000000000..9116f45ea7a00b97d7b5ccf556b91960125f699f --- /dev/null +++ b/tests/include-requested-by-component_test-case-01.cmake @@ -0,0 +1,41 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one shared target by find component: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS "shared") + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/success-target1.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) diff --git a/tests/include-requested-by-component_test-case-02.cmake b/tests/include-requested-by-component_test-case-02.cmake new file mode 100644 index 0000000000000000000000000000000000000000..2ca2f9ff9586797b26a3b096c61843c80bb6cc8d --- /dev/null +++ b/tests/include-requested-by-component_test-case-02.cmake @@ -0,0 +1,46 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one shared target by find component, but it doesn't exist: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS "shared") + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/i-do-not-exist" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `SHARED` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) +REQUIRE_UNDEFINED(TEST_TARGET_1) diff --git a/tests/include-requested-by-component_test-case-03.cmake b/tests/include-requested-by-component_test-case-03.cmake new file mode 100644 index 0000000000000000000000000000000000000000..98a460a4ad664f7059933da33dea74dc99d92f9e --- /dev/null +++ b/tests/include-requested-by-component_test-case-03.cmake @@ -0,0 +1,44 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple shared targets by find component: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS "shared") + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/success-target1.cmake" + "./mocks/success-target2.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) +REQUIRE_TRUTHY(TEST_TARGET_2) diff --git a/tests/include-requested-by-component_test-case-04.cmake b/tests/include-requested-by-component_test-case-04.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8f53a6e63f84fb7b86f523b7ba63c471b6b8fbbe --- /dev/null +++ b/tests/include-requested-by-component_test-case-04.cmake @@ -0,0 +1,49 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple shared targets by find component, but one doesn't exist: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS "shared") + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/i-do-not-exist" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `SHARED` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) +REQUIRE_UNDEFINED(TEST_TARGET_1) +REQUIRE_UNDEFINED(TEST_TARGET_2) diff --git a/tests/include-requested-by-component_test-case-05.cmake b/tests/include-requested-by-component_test-case-05.cmake new file mode 100644 index 0000000000000000000000000000000000000000..366209b5152f94af84f91687910a2e1334ce6b9a --- /dev/null +++ b/tests/include-requested-by-component_test-case-05.cmake @@ -0,0 +1,41 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one static target by find component: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS "static") + +set( + STATIC_TEST_TARGET_FILES + "./mocks/success-target1.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) diff --git a/tests/include-requested-by-component_test-case-06.cmake b/tests/include-requested-by-component_test-case-06.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3ca2796582730d247fea3ffe0ade3b3a077cb159 --- /dev/null +++ b/tests/include-requested-by-component_test-case-06.cmake @@ -0,0 +1,46 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one static target by find component, but it doesn't exist: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS "static") + +set( + STATIC_TEST_TARGET_FILES + "./mocks/i-do-not-exist" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `STATIC` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) +REQUIRE_UNDEFINED(TEST_TARGET_1) diff --git a/tests/include-requested-by-component_test-case-07.cmake b/tests/include-requested-by-component_test-case-07.cmake new file mode 100644 index 0000000000000000000000000000000000000000..edf29dd1cc43cb81794e17f78d031e3facff6d42 --- /dev/null +++ b/tests/include-requested-by-component_test-case-07.cmake @@ -0,0 +1,44 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple static targets by find component: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS "static") + +set( + STATIC_TEST_TARGET_FILES + "./mocks/success-target1.cmake" + "./mocks/success-target2.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) +REQUIRE_TRUTHY(TEST_TARGET_2) diff --git a/tests/include-requested-by-component_test-case-08.cmake b/tests/include-requested-by-component_test-case-08.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e8e2c085965ec527138e86e5d58016b8a812cd0e --- /dev/null +++ b/tests/include-requested-by-component_test-case-08.cmake @@ -0,0 +1,49 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple static targets by find component, but one doesn't exist: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS "static") + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/i-do-not-exist" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `STATIC` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) +REQUIRE_UNDEFINED(TEST_TARGET_1) +REQUIRE_UNDEFINED(TEST_TARGET_2) diff --git a/tests/include-requested-by-package-flag_test-case-01.cmake b/tests/include-requested-by-package-flag_test-case-01.cmake new file mode 100644 index 0000000000000000000000000000000000000000..ab6a593cfec78cbd66511419a983efe3c3b4bc91 --- /dev/null +++ b/tests/include-requested-by-package-flag_test-case-01.cmake @@ -0,0 +1,41 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one shared target by package specific flag (`${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS`): ") + +set(${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS TRUE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/success-target1.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) diff --git a/tests/include-requested-by-package-flag_test-case-02.cmake b/tests/include-requested-by-package-flag_test-case-02.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3a88c4756d049941bf2962f79fb933ad5f01d2da --- /dev/null +++ b/tests/include-requested-by-package-flag_test-case-02.cmake @@ -0,0 +1,46 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one shared target by package specific flag, but it doesn't exist: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS TRUE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/i-do-not-exist" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `SHARED` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) +REQUIRE_UNDEFINED(TEST_TARGET_1) diff --git a/tests/include-requested-by-package-flag_test-case-03.cmake b/tests/include-requested-by-package-flag_test-case-03.cmake new file mode 100644 index 0000000000000000000000000000000000000000..9a5f21e5fc55510b59b545dcef36cffef398e33d --- /dev/null +++ b/tests/include-requested-by-package-flag_test-case-03.cmake @@ -0,0 +1,44 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple shared targets by package specific flag (`${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS`): ") + +set(${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS TRUE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/success-target1.cmake" + "./mocks/success-target2.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) +REQUIRE_TRUTHY(TEST_TARGET_2) diff --git a/tests/include-requested-by-package-flag_test-case-04.cmake b/tests/include-requested-by-package-flag_test-case-04.cmake new file mode 100644 index 0000000000000000000000000000000000000000..bcdf0aea1b3eb3721edeec57bb0c5d1ec98e7a2a --- /dev/null +++ b/tests/include-requested-by-package-flag_test-case-04.cmake @@ -0,0 +1,49 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple shared targets by package specific flag, but one doesn't exist: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS TRUE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/i-do-not-exist" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `SHARED` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) +REQUIRE_UNDEFINED(TEST_TARGET_1) +REQUIRE_UNDEFINED(TEST_TARGET_2) diff --git a/tests/include-requested-by-package-flag_test-case-05.cmake b/tests/include-requested-by-package-flag_test-case-05.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a090d9287983c95dc9a75051298f9bd738629c38 --- /dev/null +++ b/tests/include-requested-by-package-flag_test-case-05.cmake @@ -0,0 +1,41 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one static target by package specific flag (`${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS`): ") + +set(${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS FALSE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/success-target1.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) diff --git a/tests/include-requested-by-package-flag_test-case-06.cmake b/tests/include-requested-by-package-flag_test-case-06.cmake new file mode 100644 index 0000000000000000000000000000000000000000..4f6edcb00a5db7e19b9643550ff2e4dce93a8415 --- /dev/null +++ b/tests/include-requested-by-package-flag_test-case-06.cmake @@ -0,0 +1,46 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include one static target by package specific flag, but it doesn't exist: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS FALSE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/i-do-not-exist" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `STATIC` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) +REQUIRE_UNDEFINED(TEST_TARGET_1) diff --git a/tests/include-requested-by-package-flag_test-case-07.cmake b/tests/include-requested-by-package-flag_test-case-07.cmake new file mode 100644 index 0000000000000000000000000000000000000000..299fcf6bf511f0dce2883c8ffc5a2caac2d50cf5 --- /dev/null +++ b/tests/include-requested-by-package-flag_test-case-07.cmake @@ -0,0 +1,44 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple static targets by package specific flag (`${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS`): ") + +set(${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS FALSE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/success-target1.cmake" + "./mocks/success-target2.cmake" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +REQUIRE_TRUTHY(TEST_TARGET_1) +REQUIRE_TRUTHY(TEST_TARGET_2) diff --git a/tests/include-requested-by-package-flag_test-case-08.cmake b/tests/include-requested-by-package-flag_test-case-08.cmake new file mode 100644 index 0000000000000000000000000000000000000000..58cd88601e6bb6d31a44d5872cc95a9f26790cfb --- /dev/null +++ b/tests/include-requested-by-package-flag_test-case-08.cmake @@ -0,0 +1,49 @@ +#[[ +MIT License + +CMake build script for LoadStaticSharedTargets module +Copyright (c) 2024 Tim Kaune + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +TEST_CASE("Include multiple static targets by package specific flag, but one doesn't exist: ") + +set(${CMAKE_FIND_PACKAGE_NAME}_SHARED_LIBS FALSE) + +set( + STATIC_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/i-do-not-exist" +) +set( + SHARED_TEST_TARGET_FILES + "./mocks/failure-target1.cmake" + "./mocks/failure-target2.cmake" +) + +include("./helpers/testee_macro_wrapper.cmake") + +CHECK_STREQUAL( + ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "${CMAKE_FIND_PACKAGE_NAME} `STATIC` libraries were requested but not found." +) +REQUIRE_FALSY(${CMAKE_FIND_PACKAGE_NAME}_FOUND) +REQUIRE_UNDEFINED(TEST_TARGET_1) +REQUIRE_UNDEFINED(TEST_TARGET_2) diff --git a/tests/mocks/failure-target1.cmake b/tests/mocks/failure-target1.cmake new file mode 100644 index 0000000000000000000000000000000000000000..28063d699d10a15ea193a8fb84ca31c67d1415bd --- /dev/null +++ b/tests/mocks/failure-target1.cmake @@ -0,0 +1,2 @@ +message(STATUS "Wrong target included.") +set(TEST_TARGET_1 FALSE) diff --git a/tests/mocks/failure-target2.cmake b/tests/mocks/failure-target2.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e8c271e2668a7652b3980248b7679c4124b86576 --- /dev/null +++ b/tests/mocks/failure-target2.cmake @@ -0,0 +1,2 @@ +message(STATUS "Wrong target included.") +set(TEST_TARGET_2 FALSE) diff --git a/tests/mocks/success-target1.cmake b/tests/mocks/success-target1.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8de8ffb0cdefd7adb96286f090dfb835d41fc597 --- /dev/null +++ b/tests/mocks/success-target1.cmake @@ -0,0 +1,2 @@ +message(STATUS "Correct target successfully included.") +set(TEST_TARGET_1 TRUE) diff --git a/tests/mocks/success-target2.cmake b/tests/mocks/success-target2.cmake new file mode 100644 index 0000000000000000000000000000000000000000..dbbe2423a4b51004a75f90a43bec4efa6894ed4a --- /dev/null +++ b/tests/mocks/success-target2.cmake @@ -0,0 +1,2 @@ +message(STATUS "Correct target successfully included.") +set(TEST_TARGET_2 TRUE)