CMakeLists.txt 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. PROJECT(Plugin)
  2. # Test per-target output directory properties.
  3. SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/bin)
  4. SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/plugin)
  5. SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/static)
  6. # We need the dynamic loader support from KWSys to load the plugin in
  7. # the executable.
  8. SET(KWSYS_NAMESPACE kwsys)
  9. SET(KWSYS_HEADER_ROOT ${Plugin_BINARY_DIR}/include)
  10. SET(KWSYS_USE_DynamicLoader 1)
  11. ADD_SUBDIRECTORY(${Plugin_SOURCE_DIR}/../../Source/kwsys src/kwsys)
  12. INCLUDE_DIRECTORIES(
  13. ${Plugin_BINARY_DIR}/include
  14. ${Plugin_SOURCE_DIR}/include
  15. )
  16. # Create an executable that exports an API for use by plugins.
  17. ADD_EXECUTABLE(example_exe src/example_exe.cxx)
  18. SET_TARGET_PROPERTIES(example_exe PROPERTIES
  19. ENABLE_EXPORTS 1
  20. OUTPUT_NAME example
  21. )
  22. TARGET_LINK_LIBRARIES(example_exe kwsys)
  23. # Create a plugin that uses the API provided by the executable.
  24. # This module "links" to the executable to use the symbols.
  25. ADD_LIBRARY(example_mod_1 MODULE src/example_mod_1.c)
  26. TARGET_LINK_LIBRARIES(example_mod_1 example_exe)
  27. # TODO:
  28. # - create a plugin that links to a static lib
  29. # - create a plugin that links to a shared lib