Skip to content
Snippets Groups Projects
Commit 28b29af6 authored by Craig Scott's avatar Craig Scott
Browse files

Runs and installs on Windows

parent 27287f51
Branches master
No related tags found
No related merge requests found
......@@ -9,9 +9,11 @@ if(APPLE)
# the directory layout relative to the application binary.
set(CMAKE_INSTALL_RPATH @executable_path/../Frameworks)
# This makes deployment easier
set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qml)
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
file(RELATIVE_PATH relDir
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
......@@ -19,11 +21,13 @@ else()
set(CMAKE_INSTALL_RPATH $ORIGIN $ORIGIN/${relDir})
endif()
# This makes deployment easier on some platforms
set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qml)
find_package(Qt6 REQUIRED COMPONENTS Core Quick)
set(CMAKE_AUTOMOC ON)
add_subdirectory(Shapes/EllipseShape)
qt_add_executable(application MACOSX_BUNDLE WIN32 main.cpp)
......@@ -96,14 +100,39 @@ if(APPLE)
install(TARGETS application DESTINATION .)
install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/deployapp.cmake)
elseif(WIN32)
# NOTE: Due to limitations of windeployqt, we can't use CMake's standard
# install layout. In particular, it doesn't provide an option for
# specifying where to put the QML modules. Deviating from the default
# layout windeployqt wants to use therefore results in a broken app.
# Can't use standard bin destination
install(TARGETS application ellipseShape DESTINATION .)
# Install the app target and let windeployqt do the rest
find_program(DEPLOYQT_EXECUTABLE windeployqt)
#set(DEPLOY_APP bin/application.exe) # Would prefer this, but can't
set(DEPLOY_APP application.exe)
set(DEPLOY_OPTIONS
#--dir . # We would like to use these, but can't
#--libdir bin #
#--plugindir plugins #
--force
--qmldir=${QT_QML_OUTPUT_DIRECTORY}
--qmlimport=${QT_QML_OUTPUT_DIRECTORY}
# --verbose=2
)
list(JOIN DEPLOY_OPTIONS " " DEPLOY_OPTIONS) # convert to space-separated string
configure_file(deployapp.cmake.in deployapp.cmake @ONLY)
install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/deployapp.cmake)
else()
if(NOT WIN32)
# NOTE: We don't try to install Qt's own libraries or plugins, we are
# assuming they will be provided by the OS.
# assuming they will be provided by the OS. Since there is no deploy
# tool, we are responsible for installing everything.
set_target_properties(ellipseShapeplugin PROPERTIES
INSTALL_RPATH $ORIGIN/../../../${CMAKE_INSTALL_LIBDIR}
)
endif()
install(TARGETS application ellipseShape)
install(TARGETS ellipseShapeplugin
DESTINATION qml/Shapes/EllipseShape
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment