CMakeLists.txt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 ansi C support.
  7. IF(CMAKE_ANSI_CFLAGS)
  8. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
  9. ENDIF(CMAKE_ANSI_CFLAGS)
  10. # We need the dynamic loader support from KWSys to load the plugin in
  11. # the executable.
  12. SET(KWSYS_NAMESPACE kwsys)
  13. SET(KWSYS_HEADER_ROOT ${Plugin_BINARY_DIR}/include)
  14. SET(KWSYS_USE_DynamicLoader 1)
  15. ADD_SUBDIRECTORY(${Plugin_SOURCE_DIR}/../../Source/kwsys src/kwsys)
  16. # Configure the location of plugins.
  17. CONFIGURE_FILE(${Plugin_SOURCE_DIR}/src/example_exe.h.in
  18. ${Plugin_BINARY_DIR}/include/example_exe.h @ONLY)
  19. # We need to include headers from the source tree and configured
  20. # headers in the build tree.
  21. INCLUDE_DIRECTORIES(
  22. ${Plugin_BINARY_DIR}/include
  23. ${Plugin_SOURCE_DIR}/include
  24. )
  25. # Create an executable that exports an API for use by plugins.
  26. ADD_EXECUTABLE(example_exe src/example_exe.cxx)
  27. SET_TARGET_PROPERTIES(example_exe PROPERTIES
  28. ENABLE_EXPORTS 1
  29. OUTPUT_NAME example
  30. )
  31. TARGET_LINK_LIBRARIES(example_exe kwsys)
  32. # Create a plugin that uses the API provided by the executable.
  33. # This module "links" to the executable to use the symbols.
  34. ADD_LIBRARY(example_mod_1 MODULE src/example_mod_1.c)
  35. TARGET_LINK_LIBRARIES(example_mod_1 example_exe)
  36. # TODO:
  37. # - create a plugin that links to a static lib
  38. # - create a plugin that links to a shared lib