mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-17 14:47:30 -05:00
* Added quotes in equality checks so lists can be compared * Function to parse argument of CPMAddPackage in case a single one was provided * Error on URL type in CPMAddPackage single-arg * Fixed format * Support single argument syntax of CPMAddPackage * Documenting and showcasing the new shorthand syntax of CPMAddPackage * Auto EXCLUDE_FROM_ALL for the shorthand syntax * Fixed accidental paste of TOLOWER * Document why some test cases are commented out Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com> * Update README.md Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com> * Removed GitHub as the default package shorthand provider Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
74 lines
1.9 KiB
CMake
74 lines
1.9 KiB
CMake
function(ASSERT_EQUAL)
|
|
if(NOT ARGC EQUAL 2)
|
|
message(FATAL_ERROR "assertion failed: invalid argument count: ${ARGC}")
|
|
endif()
|
|
|
|
if(NOT "${ARGV0}" STREQUAL "${ARGV1}")
|
|
message(FATAL_ERROR "assertion failed: '${ARGV0}' != '${ARGV1}'")
|
|
else()
|
|
message(STATUS "test passed: '${ARGV0}' == '${ARGV1}'")
|
|
endif()
|
|
endfunction()
|
|
|
|
function(ASSERT_NOT_EQUAL)
|
|
if(NOT ARGC EQUAL 2)
|
|
message(FATAL_ERROR "assertion failed: invalid argument count: ${ARGC}")
|
|
endif()
|
|
|
|
if("${ARGV0}" STREQUAL "${ARGV1}")
|
|
message(FATAL_ERROR "assertion failed: '${ARGV0}' == '${ARGV1}'")
|
|
else()
|
|
message(STATUS "test passed: '${ARGV0}' != '${ARGV1}'")
|
|
endif()
|
|
endfunction()
|
|
|
|
function(ASSERT_EMPTY)
|
|
if(NOT ARGC EQUAL 0)
|
|
message(FATAL_ERROR "assertion failed: input ${ARGC} not empty: '${ARGV}'")
|
|
endif()
|
|
endfunction()
|
|
|
|
function(ASSERT_DEFINED KEY)
|
|
if(DEFINED ${KEY})
|
|
message(STATUS "test passed: '${KEY}' is defined")
|
|
else()
|
|
message(FATAL_ERROR "assertion failed: '${KEY}' is not defiend")
|
|
endif()
|
|
endfunction()
|
|
|
|
function(ASSERT_NOT_DEFINED KEY)
|
|
if(DEFINED ${KEY})
|
|
message(FATAL_ERROR "assertion failed: '${KEY}' is defiend")
|
|
else()
|
|
message(STATUS "test passed: '${KEY}' is not defined")
|
|
endif()
|
|
endfunction()
|
|
|
|
function(ASSERT_TRUTHY KEY)
|
|
if(${${KEY}})
|
|
message(STATUS "test passed: '${KEY}' is set truthy")
|
|
else()
|
|
message(FATAL_ERROR "assertion failed: value of '${KEY}' is not true (${${KEY}})")
|
|
endif()
|
|
endfunction()
|
|
|
|
function(ASSERTION_FAILED)
|
|
message(FATAL_ERROR "assertion failed: ${ARGN}")
|
|
endfunction()
|
|
|
|
function(ASSERT_EXISTS file)
|
|
if(EXISTS ${file})
|
|
message(STATUS "test passed: '${file}' exists")
|
|
else()
|
|
message(FATAL_ERROR "assertion failed: file ${file} does not exist")
|
|
endif()
|
|
endfunction()
|
|
|
|
function(ASSERT_NOT_EXISTS file)
|
|
if(NOT EXISTS ${file})
|
|
message(STATUS "test passed: '${file}' does not exist")
|
|
else()
|
|
message(FATAL_ERROR "assertion failed: file ${file} exists")
|
|
endif()
|
|
endfunction()
|