Skip to content
Snippets Groups Projects
Unverified Commit 1c65eb7c authored by Tim Kaune's avatar Tim Kaune
Browse files

Add unit tests

parent 2ab9108b
No related branches found
No related tags found
No related merge requests found
Showing
with 941 additions and 0 deletions
......@@ -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)
......
#[[
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 ()
#[[
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)
#[[
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)
#[[
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()
#[[
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")
#[[
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}
)
#[[
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)
#[[
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)
#[[
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)
#[[
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)
#[[
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)
#[[
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)
#[[
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)
#[[
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)
#[[
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)
#[[
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)
#[[
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)
#[[
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)
#[[
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment