chore(cpn): build for Windows with Visual Studio (#6476)
This commit is contained in:
@@ -136,16 +136,6 @@ set(HWDEFS_PHDR "HWDEF_JSON_LIST")
|
||||
set(HWDEFS_QRC "${CMAKE_CURRENT_BINARY_DIR}/hwdefs.qrc")
|
||||
set(HWDEFS_CMD "${COMPANION_SRC_DIRECTORY}/../util/generate_hwdefs_qrc.py")
|
||||
|
||||
# qrc used by Companion and Simulator
|
||||
add_custom_command(OUTPUT ${HWDEFS_QRC}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${HWDEFS_CMD}
|
||||
-d ${HWDEFS_DIR}
|
||||
-t ${HWDEFS_TMPL}
|
||||
-p ${HWDEFS_PHDR}
|
||||
-o ${HWDEFS_QRC}
|
||||
DEPENDS ${HWDEFS_TMPL}
|
||||
)
|
||||
|
||||
############# Common lib ###############
|
||||
|
||||
set(common_SRCS
|
||||
@@ -161,13 +151,23 @@ set(common_MOC_HDRS
|
||||
modeledit/node.h
|
||||
)
|
||||
|
||||
qt_wrap_cpp(common_SRCS ${common_MOC_HDRS})
|
||||
|
||||
# qrc used by Companion and Simulator
|
||||
add_custom_command(OUTPUT ${HWDEFS_QRC}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${HWDEFS_CMD}
|
||||
-d ${HWDEFS_DIR}
|
||||
-t ${HWDEFS_TMPL}
|
||||
-p ${HWDEFS_PHDR}
|
||||
-o ${HWDEFS_QRC}
|
||||
DEPENDS ${HWDEFS_TMPL}
|
||||
)
|
||||
|
||||
set(common_RESOURCES
|
||||
companion.qrc
|
||||
${TRANSLATIONS_QRC}
|
||||
${HWDEFS_QRC}
|
||||
)
|
||||
|
||||
qt_wrap_cpp(common_SRCS ${common_MOC_HDRS})
|
||||
)
|
||||
qt_add_resources(common_RCC ${common_RESOURCES})
|
||||
|
||||
add_library(common ${common_SRCS} ${common_RCC})
|
||||
@@ -410,8 +410,7 @@ elseif(WIN32)
|
||||
|
||||
# install libsim dlls into same directory as apps
|
||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/plugins/
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT Runtime)
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
install(FILES ${LICENSE_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
|
||||
@@ -431,14 +430,12 @@ elseif(WIN32)
|
||||
|
||||
if(EXISTS "${LIBUSB1_LIBRARY_FILE}")
|
||||
install(FILES "${LIBUSB1_LIBRARY_FILE}"
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT Runtime)
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
||||
if(DFU_UTIL_FOUND)
|
||||
install(FILES "${DFU_UTIL_PATH}"
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT Runtime)
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
endif(LIBUSB1_FOUND)
|
||||
|
||||
@@ -455,7 +452,6 @@ elseif(WIN32)
|
||||
if(EXISTS "${OPENSSL_SSL_LIBRARY_DIR}")
|
||||
install(DIRECTORY ${OPENSSL_SSL_LIBRARY_DIR}/
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT Runtime
|
||||
FILES_MATCHING
|
||||
PATTERN "libcrypto-*.dll"
|
||||
PATTERN "libssl-*.dll")
|
||||
@@ -560,6 +556,7 @@ if(WIN32)
|
||||
EXECUTABLE ${companion_executable_path}
|
||||
ADDITIONAL_EXECUTABLES ${simulator_executable_path}
|
||||
NO_TRANSLATIONS
|
||||
NO_COMPILER_RUNTIME
|
||||
GENERATE_QT_CONF
|
||||
VERBOSE
|
||||
)
|
||||
@@ -587,12 +584,9 @@ if(WIN32)
|
||||
|
||||
# The 'install' target prepares all the distro files, make sure it has been executed first.
|
||||
add_custom_target(installer
|
||||
COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target install --config Release
|
||||
COMMAND "${CMAKE_COMMAND}" -P "${qt_deploy_script}"
|
||||
# Hack to overwrite the pthread lib shipped with Qt
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "${MINGW_BIN_DIR}/libwinpthread-1.dll" "${CMAKE_BINARY_DIR}/_install/bin/libwinpthread-1.dll"
|
||||
COMMAND "${NSIS_EXE}" "${NSI_FILE}"
|
||||
DEPENDS "${NSI_FILE}" "${qt_deploy_script}"
|
||||
DEPENDS install "${NSI_FILE}" "${qt_deploy_script}"
|
||||
COMMENT "Building Windows NSIS installer..."
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -97,6 +97,7 @@ void FlashProcess::onStarted()
|
||||
#if !__GNUC__
|
||||
bool killProcessByName(const char *szProcessToKill)
|
||||
{
|
||||
QString processToKill{szProcessToKill};
|
||||
HANDLE hProcessSnap;
|
||||
HANDLE hProcess;
|
||||
PROCESSENTRY32 pe32;
|
||||
@@ -115,7 +116,9 @@ bool killProcessByName(const char *szProcessToKill)
|
||||
}
|
||||
|
||||
do {
|
||||
if (!strcmp(pe32.szExeFile,szProcessToKill)) { // checks if process at current position has the name of to be killed app
|
||||
QString exeFile{pe32.szExeFile};
|
||||
|
||||
if (exeFile == processToKill) { // checks if process at current position has the name of to be killed app
|
||||
hProcess = OpenProcess(PROCESS_TERMINATE,0, pe32.th32ProcessID); // gets handle to process
|
||||
TerminateProcess(hProcess, 0); // Terminate process by handle
|
||||
CloseHandle(hProcess); // close the handle
|
||||
|
||||
Reference in New Issue
Block a user