diff --git a/hw04/CMakeLists.txt b/hw04/CMakeLists.txt index 4c6060f..1ac9cb9 100644 --- a/hw04/CMakeLists.txt +++ b/hw04/CMakeLists.txt @@ -13,6 +13,12 @@ find_package(OpenGL REQUIRED) include_directories( ${OPENGL_INCLUDE_DIRS} ) + +# Set path to our custom CMAKE scripts +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") +# Include Qt deployment helper function +include(windeployqt) + add_executable(OpenGL_Example main.cpp mainwindow.cpp @@ -28,6 +34,7 @@ find_package(Qt${QT_VERSION} COMPONENTS ${REQUIRED_LIBS} REQUIRED) target_link_libraries(${PROJECT_NAME} ${REQUIRED_LIBS_QUALIFIED}) target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} Qt5::Widgets) if (WIN32) set(DEBUG_SUFFIX) if (CMAKE_BUILD_TYPE MATCHES "Debug") @@ -56,3 +63,7 @@ "$") endforeach (QT_LIB) endif () + +if(CMAKE_BUILD_TYPE STREQUAL "Release") + windeployqt(${PROJECT_NAME}) +endif() diff --git a/hw04/CMakeLists.txt b/hw04/CMakeLists.txt index 4c6060f..1ac9cb9 100644 --- a/hw04/CMakeLists.txt +++ b/hw04/CMakeLists.txt @@ -13,6 +13,12 @@ find_package(OpenGL REQUIRED) include_directories( ${OPENGL_INCLUDE_DIRS} ) + +# Set path to our custom CMAKE scripts +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") +# Include Qt deployment helper function +include(windeployqt) + add_executable(OpenGL_Example main.cpp mainwindow.cpp @@ -28,6 +34,7 @@ find_package(Qt${QT_VERSION} COMPONENTS ${REQUIRED_LIBS} REQUIRED) target_link_libraries(${PROJECT_NAME} ${REQUIRED_LIBS_QUALIFIED}) target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} Qt5::Widgets) if (WIN32) set(DEBUG_SUFFIX) if (CMAKE_BUILD_TYPE MATCHES "Debug") @@ -56,3 +63,7 @@ "$") endforeach (QT_LIB) endif () + +if(CMAKE_BUILD_TYPE STREQUAL "Release") + windeployqt(${PROJECT_NAME}) +endif() diff --git a/hw04/cmake/windeployqt.cmake b/hw04/cmake/windeployqt.cmake new file mode 100644 index 0000000..4789d56 --- /dev/null +++ b/hw04/cmake/windeployqt.cmake @@ -0,0 +1,50 @@ +find_package(Qt5Core REQUIRED) + +# get absolute path to qmake, then use it to find windeployqt executable + +get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION) +get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) + +function(windeployqt target) + + # POST_BUILD step + # - after build, we have a bin/lib for analyzing qt dependencies + # - we run windeployqt on target and deploy Qt libs + + add_custom_command(TARGET ${target} POST_BUILD + COMMAND "${_qt_bin_dir}/windeployqt.exe" + --verbose 1 + --release + --no-svg + --no-angle +# --no-opengl + --no-opengl-sw +# --no-compiler-runtime + --compiler-runtime + --no-system-d3d-compiler + --dir ./dist + \"$\" + COMMENT "Deploying Qt libraries using windeployqt for compilation target '${target}' ..." + ) + + add_custom_command(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${target}.exe ./dist/${target}.exe) + +# add_custom_command(TARGET ${target} POST_BUILD +# COMMAND "${_qt_bin_dir}/windeployqt.exe" +# --verbose 1 +# --debug +# --no-svg +# --no-angle +# # --no-opengl +# --no-opengl-sw +# # --no-compiler-runtime +# --compiler-runtime +# --no-system-d3d-compiler +# --dir ./dist +# \"$\" +# COMMENT "Deploying Qt libraries using windeployqt for compilation target Debug '${target}' ..." +# ) + +endfunction() \ No newline at end of file