On 31. Aug, 2009, at 7:08, King, Steven R wrote:
Can't you put all executables and shared libraries in one
directory, so they
are all local to each other?
In the top level CMakeLists.txt file just add
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
The executables you specify in ADD_TEST() will have a working
directory that
is ${CMAKE_CURRENT_BINARY_DIR}
Thanks Clint and Tyler and others for your patient help. The
consolidated binary directory didn't work.
I now put all my binaries and libraries in ${CMAKE_BINARY_DIR}/bin
as Clint suggested. This caused ctest to fail for lack of knowing
where the test binary went. I made this adjustment:
add_test (
test_my_module
${CMAKE_BINARY_DIR}/bin/test_my_module
)
This will only work on Unix like systems. Doesn't CTest figure out
that the program name is a target? I.e. doesn't this work (provided
you did add_executable(test_my_module ...)):
add_test(test_my_module test_my_module)
which allowed ctest to find the executable. However, the executable
still can't find the dll, since ctest runs the test from $
{CMAKE_CURRENT_BINARY_DIR} which is apparently not equal to $
{CMAKE_RUNTIME_OUTPUT_DIRECTORY}. As we've just belabored, putting
the dll in ${CMAKE_CURRENT_BINARY_DIR} is neither easy nor well
advised.
Well, how about passing the ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} as an
argument to your test program, and then in the test program construct
the full path to the plugin library? Or as an alternative, configure a
source file defining the path to the CMAKE_RUNTIME_OUTPUT_DIRECTORY as
a variable:
CMakeLists.txt:
------>8-------
# construct the file name of the loadable module (could also use the
deprecated LOCATION property)
set(MODULE_PATH "CMAKE_RUNTIME_OUTPUT_DIRECTORY/$
{CMAKE_SHARED_MODULE_PREFIX}my_module${CMAKE_SHARED_MODULE_SUFFIX}")
file(TO_NATIVE "${MODULE_PATH}" MODULE_PATH)
# configure the test source
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_my_module.c.in $
{CMAKE_CURRENT_BINARY_DIR}/test_my_module.c @ONLY)
# create the test executable
add_executable(test_my_module ${CMAKE_CURRENT_BINARY_DIR}/
test_my_module.c)
# add a test named test_my_module, running test_my_module
add_test(test_my_module test_my_module)
------<8-------
test_my_module.c.in:
------>8------
/* TODO make this work cross-platform */
#include <dlfcn.h>
#define MODULE_PATH "@MODULE_PATH@"
int main() {
void* my_module = dlopen(MODULE_PATH, RTLD_NOW | RTLD_LOCAL);
/* whatever you want to do */
return 0;
}
------<8-------
OK, now I'm actually getting worried. Any other ideas, please?
I hope you get the idea from above...
Again my goal is to simply bring a dll and it's test program
together so they run happily ever after.
Thanks,
-steve
HTH
Michael
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake