enable_language(C) add_library(foo SHARED foo.c) set_property(TARGET foo PROPERTY ENABLE_EXPORTS TRUE) set_property (TARGET foo PROPERTY VERSION 2.5.0) set_property (TARGET foo PROPERTY SOVERSION 2.0.0) add_executable(main main.c) target_link_libraries(main PRIVATE foo) install(TARGETS foo DESTINATION "${CMAKE_BINARY_DIR}/INSTALL" COMPONENT default) install(TARGETS foo ARCHIVE DESTINATION "${CMAKE_BINARY_DIR}/INSTALL2/dev1" NAMELINK_SKIP COMPONENT default) install(TARGETS foo ARCHIVE DESTINATION "${CMAKE_BINARY_DIR}/INSTALL2/dev2" NAMELINK_ONLY COMPONENT default) install(TARGETS foo ARCHIVE DESTINATION "${CMAKE_BINARY_DIR}/INSTALL3" COMPONENT lib3 NAMELINK_COMPONENT dev3) install(TARGETS foo ARCHIVE DESTINATION "${CMAKE_BINARY_DIR}/INSTALL4" COMPONENT lib4 NAMELINK_COMPONENT dev4) set (GENERATE_CONTENT "if (\"${CMAKE_TAPI}\") set (APPLE_TEXT_STUBS_SUPPORTED TRUE) endif()\n\n") string (APPEND GENERATE_CONTENT [[ cmake_policy (SET CMP0011 NEW) cmake_policy (SET CMP0057 NEW) macro (CHECK_FILE test_msg path) if (NOT EXISTS "${path}") string (APPEND RunCMake_TEST_FAILED "${test_msg}: \"${path}\" not found\n") endif() endmacro() macro (CHECK_SYMLINK test_msg path) if (NOT IS_SYMLINK "${path}") string (APPEND RunCMake_TEST_FAILED "${test_msg}: \"${path}\" is not a symbolic link\n") elseif (NOT EXISTS "${path}") string (APPEND RunCMake_TEST_FAILED "${test_msg}: \"${path}\" not a valid symlink\n") endif() endmacro() macro (CHECK_NOFILE test_msg path) if (EXISTS "${path}") string (APPEND RunCMake_TEST_FAILED "${test_msg}: \"${path}\" was found\n") endif() endmacro() macro (CHECK_INSTALLED test_msg dir file) file(GLOB installed_files LIST_DIRECTORIES FALSE RELATIVE "${dir}" "${dir}/*") if (NOT "${file}" IN_LIST installed_files) string (APPEND RunCMake_TEST_FAILED "${test_msg}: \"${dir}/${file}\" not found\n") endif() endmacro() check_file("DYLIB file" "$") check_symlink("Linkable DYLIB file" "$") check_symlink("SONAME DYLIB file" "$") check_file("executable file" "$") check_file("Installed DYLIB file" "${RunCMake_TEST_BINARY_DIR}/INSTALL/$") check_symlink("Installed Linkable DYLIB file" "${RunCMake_TEST_BINARY_DIR}/INSTALL/$") check_symlink("Installed SONAME DYLIB file" "${RunCMake_TEST_BINARY_DIR}/INSTALL/$") if (APPLE_TEXT_STUBS_SUPPORTED) check_file("TBD file" "$") check_symlink("Linkable TBD file" "$") check_symlink("SONAME TBD file" "$") check_file("Installed TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL/$") check_symlink("Installed Linkable TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL/$") check_symlink("Installed SONAME TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL/$") check_file("Installed TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL2/dev1/$") check_symlink("Installed SONAME TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL2/dev1/$") check_nofile("Installed Linkable TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL2/dev1/$") check_installed("Installed Linkable TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL2/dev2" "$") check_nofile("Installed TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL2/dev2/$") check_nofile("Installed SONAME TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL2/dev2/$") check_file("Installed TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL3/$") check_symlink("Installed SONAME TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL3/$") check_nofile("Installed Linkable TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL3/$") check_file("Installed TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL4/$") check_symlink("Installed SONAME TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL4/$") check_symlink("Installed Linkable TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL4/$") endif() ]]) file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/LibraryWithVersions-$-generated.cmake" CONTENT "${GENERATE_CONTENT}")