Updated formatting of documentation plus a little reorganization.
[cmake.git] / Tests / Plugin / CMakeLists.txt
blobb0942c042019aa26325f9a34ec8804bde97da058
1 cmake_minimum_required (VERSION 2.6)
2 PROJECT(Plugin)
4 # Test per-target output directory properties.
5 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/bin)
6 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/plugin)
7 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/static)
9 # We need the dynamic loader support from KWSys to load the plugin in
10 # the executable.
11 SET(KWSYS_NAMESPACE kwsys)
12 SET(KWSYS_HEADER_ROOT ${Plugin_BINARY_DIR}/include)
13 SET(KWSYS_USE_DynamicLoader 1)
14 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)
20 # We need to include headers from the source tree and configured
21 # headers in the build tree.
22 INCLUDE_DIRECTORIES(
23   ${Plugin_BINARY_DIR}/include
24   ${Plugin_SOURCE_DIR}/include
25   )
27 # Create an executable that exports an API for use by plugins.
28 ADD_EXECUTABLE(example_exe src/example_exe.cxx)
29 SET_TARGET_PROPERTIES(example_exe PROPERTIES
30   ENABLE_EXPORTS 1
31   OUTPUT_NAME example
32   # Test placing exe import library in unique directory.
33   ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/exe
34   )
35 TARGET_LINK_LIBRARIES(example_exe kwsys)
37 # Create a plugin that uses the API provided by the executable.
38 # This module "links" to the executable to use the symbols.
39 ADD_LIBRARY(example_mod_1 MODULE src/example_mod_1.c)
40 TARGET_LINK_LIBRARIES(example_mod_1 example_exe)
42 # TODO:
43 #  - create a plugin that links to a static lib
44 #  - create a plugin that links to a shared lib