From 98a2805b5c399dba5cbb77b56967c35457218182 Mon Sep 17 00:00:00 2001 From: ethdev zug Date: Mon, 13 Apr 2015 17:35:29 +0100 Subject: [PATCH] fixed copying dlls --- alethzero/CMakeLists.txt | 2 +- cmake/EthExecutableHelper.cmake | 21 +++++++++++++-------- cmake/scripts/copydlls.cmake | 13 +++++++------ eth/CMakeLists.txt | 4 +--- ethrpctest/CMakeLists.txt | 2 +- third/CMakeLists.txt | 2 +- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/alethzero/CMakeLists.txt b/alethzero/CMakeLists.txt index c81c86222..e0cdab589 100644 --- a/alethzero/CMakeLists.txt +++ b/alethzero/CMakeLists.txt @@ -64,5 +64,5 @@ if (NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) endif() # eth_install_executable is defined in cmake/EthExecutableHelper.cmake -eth_install_executable(${EXECUTABLE} DLLS ${MHD_DLL_RELEASE}) +eth_install_executable(${EXECUTABLE} DLLS MHD_DLLS) diff --git a/cmake/EthExecutableHelper.cmake b/cmake/EthExecutableHelper.cmake index a2d2de8b9..be4f7ccd1 100644 --- a/cmake/EthExecutableHelper.cmake +++ b/cmake/EthExecutableHelper.cmake @@ -44,10 +44,18 @@ macro(eth_add_executable EXECUTABLE) endmacro() macro(eth_copy_dlls EXECUTABLE DLLS) - add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMNAND ${CMAKE_COMMAND} - -DLIBS="${DLLS}" - -DCONFIGURATION="$" - -DDESTINATION="${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" + # dlls must be unsubstitud list variable (without ${}) in format + # optimized;path_to_dll.dll;debug;path_to_dlld.dll + list(GET ${DLLS} 1 DLL_RELEASE) + list(GET ${DLLS} 3 DLL_DEBUG) + add_custom_command(TARGET ${EXECUTABLE} + POST_BUILD + COMMAND ${CMAKE_COMMAND} ARGS + -DDLL_RELEASE="${DLL_RELEASE}" + -DDLL_DEBUG="${DLL_DEBUG}" + -DCONF="$" + -DDESTINATION="${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" + -P "${ETH_SCRIPTS_DIR}/copydlls.cmake" ) endmacro() @@ -115,10 +123,7 @@ macro(eth_install_executable EXECUTABLE) #copy additional dlls foreach(dll ${ETH_INSTALL_EXECUTABLE_DLLS}) - add_custom_command(TARGET ${EXECUTABLE} POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${dll} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" - ) + eth_copy_dlls(${EXECUTABLE} ${dll}) endforeach(dll) install( TARGETS ${EXECUTABLE} RUNTIME diff --git a/cmake/scripts/copydlls.cmake b/cmake/scripts/copydlls.cmake index 49c2e1c03..6d86b8e4e 100644 --- a/cmake/scripts/copydlls.cmake +++ b/cmake/scripts/copydlls.cmake @@ -1,16 +1,17 @@ # this module expects # DLLS -# CONFIGURATION +# CONF # DESTINATION # example usage: -# cmake -DLLS=${MHD_LIBRARIES} -DCONFIGURATION=Release -DDESTINATION=dest -P scripts/copydlls.cmake +# cmake -DDLL_DEBUG=xd.dll -DDLL_RELEASE=x.dll -DCONFIGURATION=Release -DDESTINATION=dest -P scripts/copydlls.cmake -# expects DLLS to be in format optimized;path_to_dll.dll;debug;path_to_dll_d.dll -if (${CONFIGURATION} STREQUAL "Release") - list(GET DLLS 1 DLL) +# this script is created cause we do not know configuration in multiconfiguration generators at cmake configure phase ;) + +if ("${CONF}" STREQUAL "Release") + set(DLL ${DLL_RELEASE}) else () # Debug - list(GET DLLS 3 DLL) + set(DLL ${DLL_DEBUG}) endif() execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${DLL}" "${DESTINATION}") diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index 047f81c49..2b354dab2 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -29,9 +29,7 @@ target_link_libraries(${EXECUTABLE} webthree) target_link_libraries(${EXECUTABLE} ethash) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) - eth_copy_dlls(${EXECUTABLE} ${MHD_DLLS}) - #add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${MHD_DLL_RELEASE} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") - + eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) endif() install( TARGETS ${EXECUTABLE} DESTINATION bin ) diff --git a/ethrpctest/CMakeLists.txt b/ethrpctest/CMakeLists.txt index 5d3fef542..e28b08d70 100644 --- a/ethrpctest/CMakeLists.txt +++ b/ethrpctest/CMakeLists.txt @@ -28,7 +28,7 @@ target_link_libraries(${EXECUTABLE} testutils) target_link_libraries(${EXECUTABLE} web3jsonrpc) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) - add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${MHD_DLL_RELEASE} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") + eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) endif() install( TARGETS ${EXECUTABLE} DESTINATION bin ) diff --git a/third/CMakeLists.txt b/third/CMakeLists.txt index 397f2b7a6..a173d10fd 100644 --- a/third/CMakeLists.txt +++ b/third/CMakeLists.txt @@ -52,5 +52,5 @@ target_link_libraries(${EXECUTABLE} web3jsonrpc) target_link_libraries(${EXECUTABLE} jsqrc) # eth_install_executable is defined in cmake/EthExecutableHelper.cmake -eth_install_executable(${EXECUTABLE} DLLS ${MHD_DLL_RELEASE}) +eth_install_executable(${EXECUTABLE} DLLS MHD_DLLS)