Skip to content

Commit a4fb5db

Browse files
authored
Put ".exe" and ".dll" together to make test usable in build dir. (#1166)
1 parent d517d59 commit a4fb5db

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

Diff for: CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ option(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF)
8585
# Adhere to GNU filesystem layout conventions
8686
include(GNUInstallDirs)
8787

88+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Archive output dir.")
89+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Library output dir.")
90+
set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" CACHE PATH "PDB (MSVC debug symbol)output dir.")
91+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Executable/dll output dir.")
92+
8893
set(JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL")
8994

9095
configure_file("${PROJECT_SOURCE_DIR}/version.in"

Diff for: src/test_lib_json/CMakeLists.txt

+8-19
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,17 @@ target_link_libraries(jsoncpp_test jsoncpp_lib)
2121
# another way to solve issue #90
2222
#set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store)
2323

24+
## Create tests for dashboard submission, allows easy review of CI results https://my.cdash.org/index.php?project=jsoncpp
25+
add_test(NAME jsoncpp_test
26+
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:jsoncpp_test>
27+
)
28+
set_target_properties(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test)
29+
2430
# Run unit tests in post-build
2531
# (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?)
2632
if(JSONCPP_WITH_POST_BUILD_UNITTEST)
27-
if(BUILD_SHARED_LIBS)
28-
# First, copy the shared lib, for Microsoft.
29-
# Then, run the test executable.
30-
add_custom_command(TARGET jsoncpp_test
31-
POST_BUILD
32-
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:jsoncpp_lib> $<TARGET_FILE_DIR:jsoncpp_test>
33-
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:jsoncpp_test>
34-
)
35-
else()
36-
# Just run the test executable.
37-
add_custom_command(TARGET jsoncpp_test
38-
POST_BUILD
39-
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:jsoncpp_test>
40-
)
41-
endif()
42-
## Create tests for dashboard submission, allows easy review of CI results https://my.cdash.org/index.php?project=jsoncpp
43-
add_test(NAME jsoncpp_test
33+
add_custom_command(TARGET jsoncpp_test
34+
POST_BUILD
4435
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:jsoncpp_test>
4536
)
4637
endif()
47-
48-
set_target_properties(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test)

0 commit comments

Comments
 (0)