Werner Smekal wrote:
Hi Scott,
There is actually a possibility to tell Visual C++ directly where the
DLL is located (by changing the PATH variable for one configuration
inside VS), but I don't remember right now how and I'm just on the
wrong OS right now to have a look.

Obviously I want to avoid having the developer manually editing the
project that cmake has produced, so if such a feature exists, I'd
like to track down how to make cmake spit it out for me.

Just for the records: Start Visual C++ and right click on the Project,
then choose Properties. Go to Configuration Properties->Debugging. In
the Textbox "Environment" enter something like:

PATH=%PATH%;$(SolutionDir)\dll

Thanks again Werner. While that solution would most certainly work, what I've been working really hard on is to ensure that a developer needs little more than the compiler and subversion installed on his/her machine to do our build.

Thanks to David Cole's help, here is what I have working now and it *should* be pretty portable. I'm going to try to work it into a re-usable function or macro, which I'll post on the list when I'm done if anyone is interested:

#
# In order to run tests we will need to set the approriate environment
# variable so that the test program can locate its dependent DLL's. First
# we want to know what directory our dependent DLL was installed into:
#
get_target_property(utildir util LOCATION_Debug)
get_filename_component(utildir "${utildir}" PATH)
file(TO_NATIVE_PATH "${utildir}" native_utildir)

#
# Next, for our directory full of platform-dependent 3rd party DLL's
#
file(TO_NATIVE_PATH "${THIRDPARTY_DIR}/lib" native_3rdparty_lib)
file(TO_NATIVE_PATH "${THIRDRDPARTY_DIR}/bin" native_3rdparty_bin)

#
# Determine which environment variable controls the locating of
# DLL's and set that variable.
#
if (WIN32)
  set (LD_VARNAME "PATH")
set (LD_PATH "${native_utildir};${native_3rdparty_lib};${native_3rdparty_bin};$ENV{PATH}

  #
  # IMPORTANT NOTE: The set_tests_properties(), below, internally
  # stores its name/value pairs with a semicolon delimiter.
  # because of this we must protect the semicolons in the path
  #
  string(REPLACE ";" "\\;" LD_PATH "${LD_PATH}")
else ()
  set (LD_VARNAME "LD_LIBRARY_PATH")
set (LD_PATH "${native_utildir}:${native_3rdparty_lib}:$ENV{LD_LIBRARY_PATH}")
endif ()

add_test (SomeTest SomeTest)
set_tests_properties(SomeTest PROPERTIES ENVIRONMENT "${LD_VARNAME}=${LD_PATH}")


Thanks again,
-scott
_______________________________________________
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

Reply via email to