CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Import targets from the exported build tree.
  2. include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake)
  3. # Import targets from the exported install tree.
  4. include(${CMAKE_INSTALL_PREFIX}/lib/exp/exp.cmake)
  5. # Try referencing an executable imported from the install tree.
  6. add_custom_command(
  7. OUTPUT ${Import_BINARY_DIR}/exp_generated.c
  8. COMMAND exp_testExe1 ${Import_BINARY_DIR}/exp_generated.c
  9. DEPENDS exp_testExe1
  10. )
  11. add_custom_command(
  12. OUTPUT ${Import_BINARY_DIR}/exp_generated3.c
  13. COMMAND exp_testExe3 ${Import_BINARY_DIR}/exp_generated3.c
  14. DEPENDS exp_testExe3
  15. )
  16. add_executable(imp_testExe1
  17. imp_testExe1.c
  18. ${Import_BINARY_DIR}/exp_generated.c
  19. ${Import_BINARY_DIR}/exp_generated3.c
  20. )
  21. # Try linking to a library imported from the install tree.
  22. target_link_libraries(imp_testExe1
  23. exp_testLib2
  24. exp_testLib3
  25. exp_testLib4
  26. exp_testLib5
  27. )
  28. # Try building a plugin to an executable imported from the install tree.
  29. add_library(imp_mod1 MODULE imp_mod1.c)
  30. target_link_libraries(imp_mod1 exp_testExe2)
  31. # Try referencing an executable imported from the build tree.
  32. add_custom_command(
  33. OUTPUT ${Import_BINARY_DIR}/bld_generated.c
  34. COMMAND bld_testExe1 ${Import_BINARY_DIR}/bld_generated.c
  35. DEPENDS bld_testExe1
  36. )
  37. add_custom_command(
  38. OUTPUT ${Import_BINARY_DIR}/bld_generated3.c
  39. COMMAND bld_testExe3 ${Import_BINARY_DIR}/bld_generated3.c
  40. DEPENDS bld_testExe3
  41. )
  42. add_executable(imp_testExe1b
  43. imp_testExe1.c
  44. ${Import_BINARY_DIR}/bld_generated.c
  45. ${Import_BINARY_DIR}/bld_generated3.c
  46. )
  47. # Try linking to a library imported from the build tree.
  48. target_link_libraries(imp_testExe1b
  49. bld_testLib2
  50. bld_testLib3
  51. bld_testLib4
  52. bld_testLib5
  53. )
  54. # Try building a plugin to an executable imported from the build tree.
  55. add_library(imp_mod1b MODULE imp_mod1.c)
  56. target_link_libraries(imp_mod1b bld_testExe2)
  57. # Export/CMakeLists.txt pretends the RelWithDebInfo (as well as Debug)
  58. # configuration should link to debug libs.
  59. foreach(c DEBUG RELWITHDEBINFO)
  60. set_property(TARGET imp_testExe1 PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG)
  61. set_property(TARGET imp_testExe1b PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG)
  62. endforeach(c)
  63. # Create a library to be linked by another directory in this project
  64. # to test transitive linking to otherwise invisible imported targets.
  65. add_library(imp_lib1 STATIC imp_lib1.c)
  66. target_link_libraries(imp_lib1 exp_testLib2)
  67. add_library(imp_lib1b STATIC imp_lib1.c)
  68. target_link_libraries(imp_lib1b bld_testLib2)