summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/AppleTextStubs/Simple.cmake
blob: 9f6318c5613ed9d377a14f18ec0c607269ee6ad3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
enable_language(C)

add_library(foo SHARED foo.c)
set_property(TARGET foo PROPERTY ENABLE_EXPORTS TRUE)

add_executable(main main.c)
target_link_libraries(main PRIVATE foo)


install(TARGETS foo DESTINATION "${CMAKE_BINARY_DIR}/INSTALL")

install(TARGETS foo LIBRARY DESTINATION "${CMAKE_BINARY_DIR}/INSTALL2/lib"
                    ARCHIVE DESTINATION "${CMAKE_BINARY_DIR}/INSTALL2/dev")


set (GENERATE_CONTENT "if (\"${CMAKE_TAPI}\")
  set (APPLE_TEXT_STUBS_SUPPORTED TRUE)
endif()\n\n")

string (APPEND GENERATE_CONTENT [[
macro (CHECK_FILE test_msg path)
  if (NOT EXISTS "${path}")
    string (APPEND RunCMake_TEST_FAILED "${test_msg}: \"${path}\" not found\n")
  endif()
endmacro()

check_file("DYLIB file" "$<TARGET_FILE:foo>")
check_file("executable file" "$<TARGET_FILE:main>")

check_file("Installed DYLIB file" "${RunCMake_TEST_BINARY_DIR}/INSTALL2/lib/$<TARGET_FILE_NAME:foo>")

if (APPLE_TEXT_STUBS_SUPPORTED)
  check_file("TBD file" "$<TARGET_IMPORT_FILE:foo>")

  check_file("Installed TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL/$<TARGET_IMPORT_FILE_NAME:foo>")
  check_file("Installed TBD file" "${RunCMake_TEST_BINARY_DIR}/INSTALL2/dev/$<TARGET_IMPORT_FILE_NAME:foo>")
endif()
]])

file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Simple-$<CONFIG>-generated.cmake"
  CONTENT "${GENERATE_CONTENT}")