From c1a6e4dcc666c548c182bc6cf8617815b330d977 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 17 Apr 2007 13:52:50 -0400 Subject: ENH: Configure location of plugin files so that the executable can run with any current working directory. --- Tests/Plugin/CMakeLists.txt | 7 +++++++ Tests/Plugin/src/example_exe.cxx | 4 +++- Tests/Plugin/src/example_exe.h.in | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 Tests/Plugin/src/example_exe.h.in diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt index 41fd05f..a0d1add 100644 --- a/Tests/Plugin/CMakeLists.txt +++ b/Tests/Plugin/CMakeLists.txt @@ -11,6 +11,13 @@ SET(KWSYS_NAMESPACE kwsys) SET(KWSYS_HEADER_ROOT ${Plugin_BINARY_DIR}/include) SET(KWSYS_USE_DynamicLoader 1) ADD_SUBDIRECTORY(${Plugin_SOURCE_DIR}/../../Source/kwsys src/kwsys) + +# Configure the location of plugins. +CONFIGURE_FILE(${Plugin_SOURCE_DIR}/src/example_exe.h.in + ${Plugin_BINARY_DIR}/include/example_exe.h @ONLY) + +# We need to include headers from the source tree and configured +# headers in the build tree. INCLUDE_DIRECTORIES( ${Plugin_BINARY_DIR}/include ${Plugin_SOURCE_DIR}/include diff --git a/Tests/Plugin/src/example_exe.cxx b/Tests/Plugin/src/example_exe.cxx index 59f1e0b..96566d5 100644 --- a/Tests/Plugin/src/example_exe.cxx +++ b/Tests/Plugin/src/example_exe.cxx @@ -1,5 +1,7 @@ #include +#include + #include #include #include @@ -21,7 +23,7 @@ extern "C" int example_exe_function() int main() { - kwsys_stl::string libName = "lib/plugin" CONFIG_DIR "/"; + kwsys_stl::string libName = EXAMPLE_EXE_PLUGIN_DIR CONFIG_DIR "/"; libName += kwsys::DynamicLoader::LibPrefix(); libName += "example_mod_1"; libName += kwsys::DynamicLoader::LibExtension(); diff --git a/Tests/Plugin/src/example_exe.h.in b/Tests/Plugin/src/example_exe.h.in new file mode 100644 index 0000000..62f0d9f --- /dev/null +++ b/Tests/Plugin/src/example_exe.h.in @@ -0,0 +1,6 @@ +#ifndef example_exe_h +#define example_exe_h + +#define EXAMPLE_EXE_PLUGIN_DIR "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@" + +#endif -- cgit v0.12