mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-05 13:50:10 -05:00
1a846c8849
Add several test cases to verify that install(PACKAGE_INFO) is working as expected. These cover validating the output for several scenarios, improper use of the command, effects of command arguments, and a handful of improper uses. Tests that should still be added include one covering DESTINATION (both the default and user-specified) and the CPS location and link_location attributes. These have been skipped for now because the former requires actually installing a test project, and the latter involves validating attributes whose values are platform-dependent. (In particular, I don't think link_location will appear on not-Windows.) Additionally, there is no coverage of (other) common install-command arguments such as PERMISSIONS, COMPONENT, etc.; however, because the logic implementing these is shared, the tests covering them for other sub-commands is probably sufficient. Note that, because the files are generated in a location that includes a hash of the install destination, and because the default destination is platform dependent, the tests need to specify a fixed DESTINATION so that the location of generated files (which we need to inspect and validate) is predictable.
25 lines
1.1 KiB
CMake
25 lines
1.1 KiB
CMake
include(${CMAKE_CURRENT_LIST_DIR}/Assertions.cmake)
|
|
|
|
set(out_dir "${RunCMake_BINARY_DIR}/InterfaceProperties-build/CMakeFiles/Export/510c5684a4a8a792eadfb55bc9744983")
|
|
|
|
file(READ "${out_dir}/foo.cps" content)
|
|
expect_value("${content}" "foo" "name")
|
|
|
|
string(JSON component GET "${content}" "components" "foo")
|
|
|
|
expect_value("${component}" "interface" "type")
|
|
expect_array("${component}" 1 "includes")
|
|
expect_value("${component}" "@prefix@/include/foo" "includes" 0)
|
|
expect_array("${component}" 1 "compile_features")
|
|
expect_value("${component}" "c++23" "compile_features" 0)
|
|
expect_array("${component}" 1 "compile_flags")
|
|
expect_value("${component}" "-ffast-math" "compile_flags" 0)
|
|
expect_null("${component}" "compile_definitions" "*" "FOO")
|
|
expect_value("${component}" "BAR" "compile_definitions" "*" "BAR")
|
|
expect_array("${component}" 1 "link_directories")
|
|
expect_value("${component}" "/opt/foo/lib" "link_directories" 0)
|
|
expect_array("${component}" 1 "link_flags")
|
|
expect_value("${component}" "--needed" "link_flags" 0)
|
|
expect_array("${component}" 1 "link_libraries")
|
|
expect_value("${component}" "/usr/lib/libm.so" "link_libraries" 0)
|