diff --git a/CMakeLists.txt b/CMakeLists.txt index 83785cb..116ee1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,6 @@ set(CMAKE_AUTOMOC ON) #available params: # - NO_BUILD_TESTS=1 # - NO_BUILD_EXAMPLES=1 -# - WINPTY_ROOT_DIR= - if you set this parameter, winpty doesn't be auto-downloaded like dependency # - WINPTY_LIBS= - redefine path to winpty lib for libkage and ignore included find mechanic IF("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") set(PTYQT_DEBUG TRUE) @@ -52,7 +51,7 @@ if (MSVC) endif() #dependencies -if (MSVC AND "${WINPTY_LIBS}" STREQUAL "STATIC") +if (MSVC) add_subdirectory(thirdparty) endif() diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 5e30665..dfe5e08 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -75,7 +75,6 @@ target_link_libraries(ptyqt Qt5::Core ${ADDITIONAL_LIBS}) if (MSVC) target_link_libraries( ptyqt Qt5::Network ${WINPTY_LIBS}) - add_dependencies(ptyqt winpty) endif() install(TARGETS ptyqt DESTINATION ${PTYQT_INSTALL_LIB_DIR}) diff --git a/examples/xtermjs/CMakeLists.txt b/examples/xtermjs/CMakeLists.txt index 6899fb7..a9f3ee5 100644 --- a/examples/xtermjs/CMakeLists.txt +++ b/examples/xtermjs/CMakeLists.txt @@ -8,7 +8,6 @@ add_dependencies(xtermjs_sample ptyqt) target_link_libraries(xtermjs_sample ptyqt Qt5::Core ${Qt5WebSockets_LIBRARIES}) if (MSVC) - add_dependencies(xtermjs_sample winpty) target_link_libraries(xtermjs_sample Qt5::Network ${WINPTY_LIBS}) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 80433a2..91ff0d4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,7 +9,6 @@ add_dependencies(ptyqt_tests ptyqt) add_test(ptyqt_tests ptyqt_tests) if (MSVC) - add_dependencies(ptyqt_tests winpty) if ("${PTYQT_DEBUG}") set(WINPTY_DEBUG_SERVER_PATH ${WINPTY_ROOT_DIR}/${TARGET_ARCH}/bin/winpty-debugserver.exe) add_definitions(-DWINPTY_DEBUG_SRV_PATH="${WINPTY_DEBUG_SERVER_PATH}") diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 19a2d5f..3d5b340 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -2,7 +2,7 @@ if (MSVC) include(ExternalProject) - if("${WINPTY_ROOT_DIR}" STREQUAL "") + if("${WINPTY_LIBS}" STREQUAL "") set(WINPTY_URL https://github.com/rprichard/winpty/releases/download/0.4.3/winpty-0.4.3-msvc2015.zip) @@ -27,24 +27,26 @@ if (MSVC) message("Use user-defined WinPty") endif() - set(WINPTY_SUB_ARCH ${TARGET_ARCH}) - if ("${WINPTY_SUB_ARCH}" STREQUAL "x86") - set(WINPTY_SUB_ARCH ia32) + if("${WINPTY_LIBS}" STREQUAL "") + set(WINPTY_SUB_ARCH ${TARGET_ARCH}) + if ("${WINPTY_SUB_ARCH}" STREQUAL "x86") + set(WINPTY_SUB_ARCH ia32) + endif() + + #message("WINPTY_SUB_ARCH " ${WINPTY_SUB_ARCH}) + #message("TARGET_ARCH " ${TARGET_ARCH}) + + #can be linked only to DLL, because WinPty built and distributed only for MSVC/Shared/x64 + if("${BUILD_TYPE}" STREQUAL "STATIC") + set(WINPTY_LIBS ${WINPTY_ROOT_DIR}/${WINPTY_SUB_ARCH}/lib/winpty.lib PARENT_SCOPE) + else() + set(WINPTY_LIBS ${WINPTY_ROOT_DIR}/${WINPTY_SUB_ARCH}/bin/winpty.dll PARENT_SCOPE) + endif() + + #winpty.dll and winpty-agent.exe must be near your project executable + set(WINPTY_DIST_FILES ${WINPTY_ROOT_DIR}/${WINPTY_SUB_ARCH}/bin/winpty.dll + ${WINPTY_ROOT_DIR}/${WINPTY_SUB_ARCH}/bin/winpty-agent.exe + PARENT_SCOPE) + #message("WINPTY_DIST_FILES" ${WINPTY_DIST_FILES}) endif() - - #message("WINPTY_SUB_ARCH " ${WINPTY_SUB_ARCH}) - #message("TARGET_ARCH " ${TARGET_ARCH}) - - #can be linked only to DLL, because WinPty built and distributed only for MSVC/Shared/x64 - if("${BUILD_TYPE}" STREQUAL "STATIC") - set(WINPTY_LIBS ${WINPTY_ROOT_DIR}/${WINPTY_SUB_ARCH}/lib/winpty.lib PARENT_SCOPE) - else() - set(WINPTY_LIBS ${WINPTY_ROOT_DIR}/${WINPTY_SUB_ARCH}/bin/winpty.dll PARENT_SCOPE) - endif() - - #winpty.dll and winpty-agent.exe must be near your project executable - set(WINPTY_DIST_FILES ${WINPTY_ROOT_DIR}/${WINPTY_SUB_ARCH}/bin/winpty.dll - ${WINPTY_ROOT_DIR}/${WINPTY_SUB_ARCH}/bin/winpty-agent.exe - PARENT_SCOPE) - #message("WINPTY_DIST_FILES" ${WINPTY_DIST_FILES}) endif()