Skip to content

Commit 1940fa5

Browse files
committed
unify output dirs
1 parent 2505337 commit 1940fa5

File tree

2 files changed

+73
-10
lines changed

2 files changed

+73
-10
lines changed

CMakeLists.txt

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,34 @@ if(USE_CONAN)
220220
endif()
221221
target_compile_definitions(influx-c-rest PRIVATE BUILDING_INFLUX_C_REST)
222222

223+
# Put DLL in bin directory (matching test executable location) so tests can find it
224+
# This ensures test-influx-c-rest and test-influxdb-cpp-auth can find influx-c-rest.dll
225+
# On Windows/MSVC (multi-config): bin/Release or bin/Debug via $<CONFIG>
226+
# On Unix (single-config): bin/Release or bin/Debug via CMAKE_BUILD_TYPE
227+
if(CMAKE_CONFIGURATION_TYPES)
228+
# Multi-config generator (Visual Studio, Xcode) - use generator expression directly
229+
set_target_properties(influx-c-rest
230+
PROPERTIES
231+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>"
232+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>"
233+
)
234+
else()
235+
# Single-config generator (Unix Makefiles, Ninja) - use CMAKE_BUILD_TYPE if set
236+
if(CMAKE_BUILD_TYPE)
237+
set_target_properties(influx-c-rest
238+
PROPERTIES
239+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}"
240+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}"
241+
)
242+
else()
243+
set_target_properties(influx-c-rest
244+
PROPERTIES
245+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
246+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
247+
)
248+
endif()
249+
endif()
250+
223251
# Demo application
224252
if(BUILD_DEMO)
225253
add_executable(demo
@@ -323,17 +351,50 @@ add_test(NAME test-influxdb-cpp-rest COMMAND ${CMAKE_BINARY_DIR}/bin/test-influx
323351
add_test(NAME test-influx-c-rest COMMAND ${CMAKE_BINARY_DIR}/bin/test-influx-c-rest)
324352
add_test(NAME test-influxdb-cpp-auth COMMAND ${CMAKE_BINARY_DIR}/bin/test-influxdb-cpp-auth)
325353

326-
# Set output directories for executables
327-
set_target_properties(test-influxdb-cpp-rest test-influx-c-rest test-influxdb-cpp-auth
328-
PROPERTIES
329-
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
330-
)
331-
332-
if(BUILD_DEMO)
333-
set_target_properties(demo
354+
# Set output directories for executables - match influx-c-rest DLL location
355+
if(CMAKE_CONFIGURATION_TYPES)
356+
# Multi-config generator (Visual Studio, Xcode)
357+
set_target_properties(test-influxdb-cpp-rest test-influx-c-rest test-influxdb-cpp-auth
334358
PROPERTIES
335-
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
359+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>"
336360
)
361+
else()
362+
# Single-config generator
363+
if(CMAKE_BUILD_TYPE)
364+
set_target_properties(test-influxdb-cpp-rest test-influx-c-rest test-influxdb-cpp-auth
365+
PROPERTIES
366+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}"
367+
)
368+
else()
369+
set_target_properties(test-influxdb-cpp-rest test-influx-c-rest test-influxdb-cpp-auth
370+
PROPERTIES
371+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
372+
)
373+
endif()
374+
endif()
375+
376+
if(BUILD_DEMO)
377+
# Demo output directory - match test executables location
378+
if(CMAKE_CONFIGURATION_TYPES)
379+
# Multi-config generator (Visual Studio, Xcode)
380+
set_target_properties(demo
381+
PROPERTIES
382+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>"
383+
)
384+
else()
385+
# Single-config generator
386+
if(CMAKE_BUILD_TYPE)
387+
set_target_properties(demo
388+
PROPERTIES
389+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}"
390+
)
391+
else()
392+
set_target_properties(demo
393+
PROPERTIES
394+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
395+
)
396+
endif()
397+
endif()
337398
endif()
338399

339400
# Installation

scripts/test.bat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ set BIN_DIR_ALT=%BUILD_DIR%\bin
1313
echo Running tests...
1414
echo Searching in: %BIN_DIR% and %BIN_DIR_ALT%
1515

16-
set PATH=%BIN_DIR%;%BIN_DIR_ALT%;%BUILD_DIR%;%PATH%
16+
REM Add build directories to PATH so DLLs can be found
17+
REM influx-c-rest.dll is needed by test-influx-c-rest and test-influxdb-cpp-auth
18+
set PATH=%BIN_DIR%;%BIN_DIR_ALT%;%BUILD_DIR%;%BUILD_DIR%\Release;%BUILD_DIR%\bin\Release;%PATH%
1719

1820
REM Test executables
1921
set TEST_FILES=test-influxdb-cpp-rest test-influx-c-rest test-influxdb-cpp-auth

0 commit comments

Comments
 (0)