Skip to content

Commit b7fac88

Browse files
committed
[cmake][win] Fix issue #9354
Don't use the Debug, Release, ... subdirs for gtest supersedes #18315 and fixes #9354
1 parent 7a9298c commit b7fac88

File tree

4 files changed

+28
-46
lines changed

4 files changed

+28
-46
lines changed

cmake/modules/RootMacros.cmake

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,7 @@ function(ROOT_ADD_GTEST test_suite)
18481848
set(test_exports "/EXPORT:_Init_thread_abort /EXPORT:_Init_thread_epoch \
18491849
/EXPORT:_Init_thread_footer /EXPORT:_Init_thread_header /EXPORT:_tls_index")
18501850
set_property(TARGET ${test_suite} APPEND_STRING PROPERTY LINK_FLAGS ${test_exports})
1851+
ROOT_SET_OUTPUT_DIRECTORIES(${test_suite})
18511852
endif()
18521853

18531854
if(ARG_WILLFAIL)
@@ -2537,6 +2538,7 @@ macro(ROOTTEST_GENERATE_DICTIONARY dictname)
25372538
25382539
set_target_properties(${targetname_libgen} PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
25392540
set_target_properties(${targetname_libgen} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
2541+
ROOT_SET_OUTPUT_DIRECTORIES(${targetname_libgen})
25402542
25412543
target_link_libraries(${targetname_libgen} ${ROOT_LIBRARIES})
25422544
@@ -2578,16 +2580,6 @@ macro(ROOTTEST_GENERATE_DICTIONARY dictname)
25782580
FIXTURES_REQUIRED ${ARG_FIXTURES_REQUIRED})
25792581
endif()
25802582
2581-
if(MSVC AND NOT CMAKE_GENERATOR MATCHES Ninja)
2582-
add_custom_command(TARGET ${targetname_libgen} POST_BUILD
2583-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${dictname}_rdict.pcm
2584-
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${dictname}_rdict.pcm
2585-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${dictname}.dll
2586-
${CMAKE_CURRENT_BINARY_DIR}/${dictname}.dll
2587-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${dictname}.lib
2588-
${CMAKE_CURRENT_BINARY_DIR}/${dictname}.lib)
2589-
endif()
2590-
25912583
endmacro(ROOTTEST_GENERATE_DICTIONARY)
25922584
25932585
#-------------------------------------------------------------------------------
@@ -2639,6 +2631,7 @@ macro(ROOTTEST_GENERATE_REFLEX_DICTIONARY dictionary)
26392631
set_target_properties(${targetname_libgen} PROPERTIES ${ROOT_LIBRARY_PROPERTIES} )
26402632
set_property(TARGET ${targetname_libgen} PROPERTY BUILD_WITH_INSTALL_RPATH OFF) # will never be installed anyway
26412633
set_target_properties(${targetname_libgen} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
2634+
ROOT_SET_OUTPUT_DIRECTORIES(${targetname_libgen})
26422635
26432636
if(ARG_LIBNAME)
26442637
set_target_properties(${targetname_libgen} PROPERTIES PREFIX "")
@@ -2695,18 +2688,6 @@ macro(ROOTTEST_GENERATE_REFLEX_DICTIONARY dictionary)
26952688
FIXTURES_REQUIRED ${ARG_FIXTURES_REQUIRED})
26962689
endif()
26972690
2698-
if(MSVC AND NOT CMAKE_GENERATOR MATCHES Ninja)
2699-
if(ARG_LIBNAME)
2700-
add_custom_command(TARGET ${targetname_libgen} POST_BUILD
2701-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${ARG_LIBNAME}.dll
2702-
${CMAKE_CURRENT_BINARY_DIR}/${ARG_LIBNAME}.dll)
2703-
else()
2704-
add_custom_command(TARGET ${targetname_libgen} POST_BUILD
2705-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/lib${dictionary}_dictrflx.dll
2706-
${CMAKE_CURRENT_BINARY_DIR}/lib${dictionary}_dictrflx.dll)
2707-
endif()
2708-
endif()
2709-
27102691
endmacro(ROOTTEST_GENERATE_REFLEX_DICTIONARY)
27112692
27122693
#-------------------------------------------------------------------------------
@@ -3491,26 +3472,38 @@ function(find_python_module module)
34913472
set(PY_${module_upper}_FOUND ${PY_${module_upper}_FOUND} PARENT_SCOPE)
34923473
endfunction()
34933474

3475+
#---------------------------------------------------------------------------------------------------
3476+
# function ROOT_SET_OUTPUT_DIRECTORIES( <name> )
3477+
#
3478+
# this function simply sets the output directories from the standard outupt directory
3479+
# (CMAKE_CURRENT_BINARY_DIR/$<CONFIG>) to its parent directory (CMAKE_CURRENT_BINARY_DIR) on Windows
3480+
#
3481+
#---------------------------------------------------------------------------------------------------
3482+
function(ROOT_SET_OUTPUT_DIRECTORIES library)
3483+
if(MSVC AND NOT CMAKE_GENERATOR MATCHES Ninja)
3484+
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
3485+
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
3486+
set_target_properties(${library} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR})
3487+
set_target_properties(${library} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR})
3488+
set_target_properties(${library} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR})
3489+
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
3490+
endif()
3491+
endfunction()
3492+
34943493
#---------------------------------------------------------------------------------------------------
34953494
# function ROOTTEST_LINKER_LIBRARY( <name> source1 source2 ...[TYPE STATIC|SHARED] [DLLEXPORT]
34963495
# [NOINSTALL] LIBRARIES library1 library2 ...
34973496
# DEPENDENCIES dep1 dep2
34983497
# BUILTINS dep1 dep2)
34993498
#
3500-
# this function simply calls the ROOT function ROOT_LINKER_LIBRARY, and add a POST_BUILD custom
3501-
# command to copy the .dll and .lib from the standard config directory (Debug/Release) to its
3502-
# parent directory (CMAKE_CURRENT_BINARY_DIR) on Windows
3499+
# this function simply calls the ROOT function ROOT_LINKER_LIBRARY, and sets the output directories
3500+
# from the standard output directory (CMAKE_CURRENT_BINARY_DIR/$<CONFIG>) to its parent directory
3501+
# (CMAKE_CURRENT_BINARY_DIR) on Windows
35033502
#
35043503
#---------------------------------------------------------------------------------------------------
35053504
function(ROOTTEST_LINKER_LIBRARY library)
35063505
ROOT_LINKER_LIBRARY(${ARGV})
3507-
if(MSVC AND NOT CMAKE_GENERATOR MATCHES Ninja)
3508-
add_custom_command(TARGET ${library} POST_BUILD
3509-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/lib${library}.dll
3510-
${CMAKE_CURRENT_BINARY_DIR}/lib${library}.dll
3511-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/lib${library}.lib
3512-
${CMAKE_CURRENT_BINARY_DIR}/lib${library}.lib)
3513-
endif()
3506+
ROOT_SET_OUTPUT_DIRECTORIES(${library})
35143507
endfunction()
35153508

35163509
#---------------------------------------------------------------------------------------------------

roottest/root/tree/cloning/CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@
22
# FIXME: it will be nice to move roottest-treeformula-event to CMake and add it as dependency
33
# To fix runtime_cxxmodules, we need to use already build artefacts.
44

5-
if(MSVC)
6-
if(CMAKE_GENERATOR MATCHES Ninja)
7-
set(test_bin_dir "${ROOTSYS}/test")
8-
else()
9-
set(test_bin_dir "${ROOTSYS}/test/$<CONFIG>")
10-
endif()
11-
else()
12-
set(test_bin_dir "${CMAKE_BINARY_DIR}/test")
13-
endif()
5+
set(test_bin_dir "${CMAKE_BINARY_DIR}/test")
146

157
ROOTTEST_ADD_TEST(hsimple-create
168
MACRO ${CMAKE_SOURCE_DIR}/tutorials/hsimple.C

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ if(MSVC AND NOT CMAKE_GENERATOR MATCHES Ninja)
3636
endif()
3737
endif()
3838
ROOT_EXECUTABLE(eventexe MainEvent.cxx LIBRARIES Event RIO Tree TreePlayer Hist Net)
39+
ROOT_SET_OUTPUT_DIRECTORIES(eventexe)
3940
ROOT_ADD_TEST(test-event COMMAND eventexe)
4041

4142
#---guitest------------------------------------------------------------------------------------

tree/tree/test/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ ROOT_GENERATE_DICTIONARY(ElementStructDict ElementStruct.h LINKDEF ElementStruct
99
ROOT_ADD_GTEST(testTOffsetGeneration TOffsetGeneration.cxx ElementStruct.cxx ElementStructDict.cxx
1010
LIBRARIES RIO Tree MathCore
1111
)
12-
if(MSVC AND NOT CMAKE_GENERATOR MATCHES Ninja)
13-
add_custom_command(TARGET testTOffsetGeneration POST_BUILD
14-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/libElementStructDict_rdict.pcm
15-
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/libElementStructDict_rdict.pcm)
16-
endif()
1712
target_include_directories(testTOffsetGeneration PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
1813
ROOT_STANDARD_LIBRARY_PACKAGE(SillyStruct NO_INSTALL_HEADERS HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/SillyStruct.h SOURCES SillyStruct.cxx LINKDEF SillyStructLinkDef.h DEPENDENCIES RIO)
14+
ROOT_SET_OUTPUT_DIRECTORIES(SillyStruct)
1915
ROOT_ADD_GTEST(testBulkApi BulkApi.cxx LIBRARIES RIO Tree TreePlayer)
2016
#FIXME: tests are having timeout on 32bit CERN VM (in docker container everything is fine),
2117
# to be reverted after investigation.

0 commit comments

Comments
 (0)