Skip to content

Commit 13e063c

Browse files
committed
copy .dll for unit-test
Fix 2nd problem in issue open-source-parsers#200. * http://stackoverflow.com/questions/10671916/how-to-copy-dll-files-into-the-same-folder-as-the-executable-using-cmake Q: What about the Python tests? A: They are not normally run in Visual Studio. If desired, one can set PATH.
1 parent f57da48 commit 13e063c

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/test_lib_json/CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# vim: et ts=4 sts=4 sw=4 tw=0
12

23
IF(JSONCPP_LIB_BUILD_SHARED)
34
ADD_DEFINITIONS( -DJSON_DLL )
@@ -22,9 +23,19 @@ ENDIF(JSONCPP_LIB_BUILD_SHARED)
2223
# Run unit tests in post-build
2324
# (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?)
2425
IF(JSONCPP_WITH_POST_BUILD_UNITTEST)
25-
ADD_CUSTOM_COMMAND( TARGET jsoncpp_test
26-
POST_BUILD
27-
COMMAND $<TARGET_FILE:jsoncpp_test>)
26+
IF(JSONCPP_LIB_BUILD_SHARED)
27+
# First, copy the shared lib, for Microsoft.
28+
# Then, run the test executable.
29+
ADD_CUSTOM_COMMAND( TARGET jsoncpp_test
30+
POST_BUILD
31+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:jsoncpp_lib> $<TARGET_FILE_DIR:jsoncpp_test>
32+
COMMAND $<TARGET_FILE:jsoncpp_test>)
33+
ELSE(JSONCPP_LIB_BUILD_SHARED)
34+
# Just run the test executable.
35+
ADD_CUSTOM_COMMAND( TARGET jsoncpp_test
36+
POST_BUILD
37+
COMMAND $<TARGET_FILE:jsoncpp_test>)
38+
ENDIF(JSONCPP_LIB_BUILD_SHARED)
2839
ENDIF(JSONCPP_WITH_POST_BUILD_UNITTEST)
2940

3041
SET_TARGET_PROPERTIES(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test)

0 commit comments

Comments
 (0)