On Mon, 7 Oct 2019 at 09:03, Murray Cumming <murr...@murrayc.com> wrote:
> On Wed, 2019-10-02 at 10:25 +0100, Stuart Dootson wrote: > > On Wed, 2 Oct 2019 at 10:23, Stuart Dootson <stuart.doot...@gmail.com > > > wrote: > > > There's no problem with the tests per-se - the problem is that the > > > sigc dll is not in the same directory as the test executables. The > > > DLL is in <cmake-build-dir>/sigc++/<Debug/Release>, while the EXEs > > > are in <cmake-build-dir>/tests/<Debug/Release>. > > > > > > So, options are: > > > > > > 1. Change the PATH to include the DLL directory before running the > > > tests > > > 2. Copy the DLL to the EXE directory as a post-build action - that > > > can be done with CMake, something like adding this bit of CMake to > > > the function add_sigcpp_test: > > > > > > add_custom_command( > > > TARGET ${test_name} > > > POST_BUILD > > > COMMAND ${CMAKE_COMMAND} -E copy > > > $<TARGET_FILE:sigc-${SIGCXX_API_VERSION}> > > > ${CMAKE_CURRENT_BINARY_DIR} > > > VERBATIM > > > ) > > > > > > 3. Build all targets (DLL & test executables) into the same output > > > directory with something like this bit of CMake: > > > if(MSVC) > > > set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) > > > endif() > > > > > > > > > > I ought to clarify that this should be added to the root > > CMakeList.txt, just after the "project (sigc++)" line. > > > > > Hope that's of some help... > > Thanks. Trying option 3 (putting everything in one bin/ directory) > seems to work, but I find the changes a bit messy: > https://github.com/libsigcplusplus/libsigcplusplus/pull/31 > > Option 1 (changing the PATH) seems to be the simplest and most correct > way to do it, but I haven't found quite the correct CMake incantation: > https://github.com/libsigcplusplus/libsigcplusplus/pull/32 > > If you have a Windows system, maybe you could checkout out that branch > and try it out, please. > > -- > Murray Cumming > murr...@murrayc.com > www.murrayc.com > > > >From some quick Googling, it looks like the best/easiest way to alter the PATH for the test environment is to use "cmake -E env" as an intermediate executor that sets the environment for your test executable, and using CMake generator expressions to retrieve the correct file & directory paths for the targets involved. This yields the following add_test command: add_test (NAME ${test_name} COMMAND ${CMAKE_COMMAND} -E env "PATH=$<TARGET_FILE_DIR:sigc-${SIGCXX_API_VERSION}>;$ENV{PATH}" $<TARGET_FILE:${test_name}>) I've implemented that & tested it (seems to work - the tests all pass) on my Windows machine & pushed the commit to a fork of libsigc++ @ https://github.com/studoot/libsigcplusplus/commit/2a332883d6ee20970d965b0907ca04fc1e2f1289. I also tried making a test deliberately fail & that was detected as well, so it looks like tests are executed correctly. Stuart Dootson
_______________________________________________ libsigc-list mailing list libsigc-list@gnome.org https://mail.gnome.org/mailman/listinfo/libsigc-list