1cmake_minimum_required(VERSION 3.5) 2 3project(cmake_install_test LANGUAGES C) 4 5# Find LZ4 installation in Config mode 6find_package(lz4 CONFIG REQUIRED) 7 8# Verify that the universal target always exists 9if (NOT TARGET LZ4::lz4) 10 message(FATAL_ERROR "LZ4::lz4 target does not exist!") 11endif() 12 13# Verify that the location property is set 14get_property(LZ4_LOCATION TARGET LZ4::lz4_shared PROPERTY LOCATION) 15if (NOT LZ4_LOCATION) 16 message(FATAL_ERROR "Missing LOCATION property for LZ4::lz4_shared!") 17endif() 18 19# Verify that the include directory property is set 20get_property(LZ4_SHARED_INCLUDE_DIRECTORIES TARGET LZ4::lz4_shared PROPERTY INTERFACE_INCLUDE_DIRECTORIES) 21if (NOT LZ4_SHARED_INCLUDE_DIRECTORIES) 22 message(FATAL_ERROR "Missing INTERFACE_INCLUDE_DIRECTORIES property for LZ4::lz4_shared!") 23endif() 24 25# Add a test that builds against the installation 26set(LZ4_TESTS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") 27add_executable(decompress-partial "${LZ4_TESTS_SOURCE_DIR}/decompress-partial.c") 28target_link_libraries(decompress-partial LZ4::lz4_shared) 29