CMakeLists.txt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. cmake_minimum_required (VERSION 2.6)
  2. PROJECT(Plugin)
  3. # Test per-target output directory properties.
  4. SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/bin)
  5. SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/plugin)
  6. SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/static)
  7. # We need the dynamic loader support from KWSys to load the plugin in
  8. # the executable.
  9. SET(KWSYS_NAMESPACE kwsys)
  10. SET(KWSYS_HEADER_ROOT ${Plugin_BINARY_DIR}/include)
  11. SET(KWSYS_USE_DynamicLoader 1)
  12. ADD_SUBDIRECTORY(${Plugin_SOURCE_DIR}/../../Source/kwsys src/kwsys)
  13. # Configure the location of plugins.
  14. CONFIGURE_FILE(${Plugin_SOURCE_DIR}/src/example_exe.h.in
  15. ${Plugin_BINARY_DIR}/include/example_exe.h @ONLY)
  16. # We need to include headers from the source tree and configured
  17. # headers in the build tree.
  18. INCLUDE_DIRECTORIES(
  19. ${Plugin_BINARY_DIR}/include
  20. ${Plugin_SOURCE_DIR}/include
  21. )
  22. # Create an executable that exports an API for use by plugins.
  23. ADD_EXECUTABLE(example_exe src/example_exe.cxx)
  24. SET_TARGET_PROPERTIES(example_exe PROPERTIES
  25. ENABLE_EXPORTS 1
  26. OUTPUT_NAME example
  27. # Test placing exe import library in unique directory.
  28. ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/exe
  29. )
  30. TARGET_LINK_LIBRARIES(example_exe kwsys)
  31. # Create a plugin that uses the API provided by the executable.
  32. # This module "links" to the executable to use the symbols.
  33. ADD_LIBRARY(example_mod_1 MODULE src/example_mod_1.c)
  34. TARGET_LINK_LIBRARIES(example_mod_1 example_exe)
  35. # TODO:
  36. # - create a plugin that links to a static lib
  37. # - create a plugin that links to a shared lib