0% found this document useful (0 votes)
53 views16 pages

Antimicro Gamepad to Keyboard Mapper

Uploaded by

owowk2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views16 pages

Antimicro Gamepad to Keyboard Mapper

Uploaded by

owowk2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

## antimicro Gamepad to KB+M event mapper

## Copyright (C) 2015 Travis Nickles <[Link]@[Link]>


##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <[Link]

cmake_minimum_required(VERSION 3.0)
project(antimicro)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")

if(WIN32)
# Cause cmake to fail if Qt location is not specified.
if(NOT CMAKE_PREFIX_PATH)
message(FATAL_ERROR "Please set CMAKE_PREFIX_PATH to the Qt installation
directory. Exiting.")
endif(NOT CMAKE_PREFIX_PATH)

# CMP0020: Automatically link Qt executables to qtmain target on Windows.


cmake_policy(SET CMP0020 NEW)
endif(WIN32)

# The version number.


set(ANTIMICRO_MAJOR_VERSION 2)
set(ANTIMICRO_MINOR_VERSION 24)
set(ANTIMICRO_PATCH_VERSION 0)

option(USE_SDL_2 "Use SDL 2 libraries rather than SDL 1." ON)

if(UNIX)
option(WITH_X11 "Compile with support for X11." ON)
option(WITH_UINPUT "Compile with support for uinput. uinput will be usable to
simulate events." OFF)
option(WITH_XTEST "Compile with support for XTest. XTest will be usable to
simulate events." ON)
option(APPDATA "Build project with AppData file support." OFF)
endif(UNIX)

option(UPDATE_TRANSLATIONS "Call lupdate to update translation files from source."


OFF)
option(TRANS_KEEP_OBSOLETE "Do not specify -no-obsolete when calling lupdate." OFF)

if(WIN32)
option(PORTABLE_PACKAGE "Create portable Windows package" OFF)
#option(TARGET_ARCH "Choose which version of some libraries to use. (x86,
x86_64)" "x86")
option(WITH_VMULTI "Compile with support for vmulti." OFF)
option(PERFORM_SIGNING "Sign final executable." OFF)
if(PORTABLE_PACKAGE)
message("Portable package mode build")

add_definitions(-DWIN_PORTABLE_PACKAGE)

# Only way to force install target to be dependent on createprofiledir.


add_custom_target(createprofiledir)
add_custom_command(TARGET createprofiledir PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
"${CMAKE_BINARY_DIR}/profiles"
)
install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} createprofiledir
WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\")")
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/profiles" DESTINATION $
{CMAKE_INSTALL_PREFIX})
endif(PORTABLE_PACKAGE)

# Find target architecture based on the compiler.


if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(TARGET_ARCH "x86_64")
else()
set(TARGET_ARCH "x86")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)

#if(TARGET_ARCH)
# set(ARCH_OPTIONS "x86" "x86_64")
# list(FIND ARCH_OPTIONS ${TARGET_ARCH} ARCH_INDEX)
# if(ARCH_INDEX EQUAL -1)
# message(FATAL_ERROR "No valid architecture choice used. Exiting.")
# endif(ARCH_INDEX EQUAL -1)
#endif(TARGET_ARCH)

if(WITH_VMULTI)
add_definitions(-DWITH_VMULTI)
endif(WITH_VMULTI)
endif(WIN32)

# Use pkg-config to find SDL library.


if(UNIX)
find_package(PkgConfig REQUIRED)
#include(FindPkgConfig)

if(USE_SDL_2)
pkg_check_modules(SDL2 REQUIRED sdl2)
elseif(NOT USE_SDL_2)
pkg_check_modules(SDL REQUIRED sdl)
endif(USE_SDL_2)

if(WITH_X11)
find_package(X11 REQUIRED)
endif(WITH_X11)

if(WITH_XTEST AND NOT WITH_X11)


set(WITH_XTEST OFF)
message("Cannot use XTest without X11. Disabling XTest support.")
endif(WITH_XTEST AND NOT WITH_X11)

if(WITH_XTEST)
message("XTest support allowed for simulating events.")
endif(WITH_XTEST)

if(WITH_UINPUT)
message("uinput support allowed for simulating events.")
endif(WITH_UINPUT)

if(NOT WITH_XTEST AND NOT WITH_UINPUT)


message(FATAL_ERROR "No system is defined for simulating events.")
endif(NOT WITH_XTEST AND NOT WITH_UINPUT)
endif(UNIX)

set(antimicro_SOURCES src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/joybuttontypes/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/joybuttontypes/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/joybuttontypes/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/keyboard/[Link]
src/keyboard/[Link]
src/keyboard/[Link]
src/[Link]
src/[Link]
src/[Link]
src/joybuttontypes/[Link]
src/joybuttontypes/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/mousedialog/[Link]
src/mousedialog/[Link]
src/mousedialog/[Link]
src/mousedialog/[Link]
src/[Link]
src/mousedialog/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/gamecontroller/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/eventhandlers/[Link]
src/[Link]
src/uihelpers/[Link]
src/uihelpers/[Link]
src/uihelpers/[Link]
src/uihelpers/[Link]
src/uihelpers/[Link]
src/uihelpers/[Link]
src/uihelpers/[Link]
src/uihelpers/[Link]
src/uihelpers/[Link]
src/mousedialog/uihelpers/[Link]
src/mousedialog/uihelpers/[Link]
src/mousedialog/uihelpers/[Link]
src/mousedialog/uihelpers/[Link]
)

set(antimicro_HEADERS src/mainwindow.h
src/joybuttonwidget.h
src/joystick.h
src/joybutton.h
src/joybuttontypes/joygradientbutton.h
src/inputdaemon.h
src/joyaxis.h
src/joyaxiswidget.h
src/joydpad.h
src/joybuttontypes/joydpadbutton.h
src/axiseditdialog.h
src/xmlconfigreader.h
src/xmlconfigwriter.h
src/joytabwidget.h
src/axisvaluebox.h
src/advancebuttondialog.h
src/simplekeygrabberbutton.h
src/joybuttonslot.h
src/joybuttontypes/joyaxisbutton.h
src/aboutdialog.h
src/setjoystick.h
src/sdleventreader.h
src/setaxisthrottledialog.h
src/keyboard/virtualkeypushbutton.h
src/keyboard/virtualkeyboardmousewidget.h
src/keyboard/virtualmousepushbutton.h
src/buttoneditdialog.h
src/commandlineutility.h
src/joycontrolstick.h
src/joybuttontypes/joycontrolstickbutton.h
src/joybuttontypes/joycontrolstickmodifierbutton.h
src/joycontrolstickeditdialog.h
src/joycontrolstickpushbutton.h
src/joycontrolstickbuttonpushbutton.h
src/joycontrolstickstatusbox.h
src/advancestickassignmentdialog.h
src/dpadpushbutton.h
src/dpadeditdialog.h
src/vdpad.h
src/joydpadbuttonwidget.h
src/quicksetdialog.h
src/mousehelper.h
src/mousesettingsdialog.h
src/mousedialog/mousecontrolsticksettingsdialog.h
src/mousedialog/mouseaxissettingsdialog.h
src/mousedialog/mousebuttonsettingsdialog.h
src/mousedialog/mousedpadsettingsdialog.h
src/joytabwidgetcontainer.h
src/mousedialog/springmoderegionpreview.h
src/joystickstatuswindow.h
src/joybuttonstatusbox.h
src/qtkeymapperbase.h
src/flashbuttonwidget.h
src/xmlconfigmigration.h
src/qkeydisplaydialog.h
src/antkeymapper.h
src/inputdevice.h
src/mainsettingsdialog.h
src/gamecontroller/gamecontrollertriggerbutton.h
src/setnamesdialog.h
src/autoprofileinfo.h
src/addeditautoprofiledialog.h
src/editalldefaultautoprofiledialog.h
src/localantimicroserver.h
src/extraprofilesettingsdialog.h
src/antimicrosettings.h
src/joybuttoncontextmenu.h
src/joycontrolstickcontextmenu.h
src/dpadcontextmenu.h
src/joyaxiscontextmenu.h
src/stickpushbuttongroup.h
src/dpadpushbuttongroup.h
src/joybuttonmousehelper.h
src/logger.h
src/inputdevicebitarraystatus.h
src/applaunchhelper.h
src/slotitemlistwidget.h
src/eventhandlers/baseeventhandler.h
src/eventhandlerfactory.h
src/uihelpers/advancebuttondialoghelper.h
src/uihelpers/buttoneditdialoghelper.h
src/uihelpers/joytabwidgethelper.h
src/uihelpers/joyaxiscontextmenuhelper.h
src/uihelpers/joycontrolstickcontextmenuhelper.h
src/uihelpers/dpadcontextmenuhelper.h
src/uihelpers/dpadeditdialoghelper.h
src/uihelpers/joycontrolstickeditdialoghelper.h
src/uihelpers/gamecontrollermappingdialoghelper.h
src/mousedialog/uihelpers/mouseaxissettingsdialoghelper.h
src/mousedialog/uihelpers/mousebuttonsettingsdialoghelper.h
src/mousedialog/uihelpers/mousecontrolsticksettingsdialoghelper.h
src/mousedialog/uihelpers/mousedpadsettingsdialoghelper.h
)

set(antimicro_FORMS src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
)

set(antimicro_RESOURCES src/[Link])

# Files that require SDL 2 support.


if(USE_SDL_2)
LIST(APPEND antimicro_SOURCES src/gamecontroller/[Link]
src/gamecontroller/[Link]
src/gamecontroller/[Link]
src/gamecontroller/[Link]
src/[Link]
src/[Link]
)
LIST(APPEND antimicro_HEADERS src/gamecontroller/gamecontroller.h
src/gamecontroller/gamecontrollerdpad.h
src/gamecontroller/gamecontrollerset.h
src/gamecontroller/gamecontrollertrigger.h
src/gamecontrollermappingdialog.h
src/gamecontrollerexample.h
)
endif(USE_SDL_2)

# Platform dependent files.


if(UNIX)
if(WITH_X11)
LIST(APPEND antimicro_SOURCES src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
)
LIST(APPEND antimicro_HEADERS src/x11extras.h
src/qtx11keymapper.h
src/unixcapturewindowutility.h
src/autoprofilewatcher.h
src/capturedwindowinfodialog.h
)

if(WITH_XTEST)
LIST(APPEND antimicro_SOURCES src/eventhandlers/[Link])
LIST(APPEND antimicro_HEADERS src/eventhandlers/xtesteventhandler.h)
endif(WITH_XTEST)
endif(WITH_X11)

if(WITH_UINPUT)
LIST(APPEND antimicro_SOURCES src/[Link]
src/[Link]
src/eventhandlers/[Link]
)
LIST(APPEND antimicro_HEADERS src/qtuinputkeymapper.h
src/uinputhelper.h
src/eventhandlers/uinputeventhandler.h
)
endif(WITH_UINPUT)

elseif(WIN32)
LIST(APPEND antimicro_SOURCES src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/[Link]
src/eventhandlers/[Link]
src/[Link]
)
LIST(APPEND antimicro_HEADERS src/winextras.h
src/qtwinkeymapper.h
src/winappprofiletimerdialog.h
src/autoprofilewatcher.h
src/capturedwindowinfodialog.h
src/eventhandlers/winsendinputeventhandler.h
src/joykeyrepeathelper.h
)
LIST(APPEND antimicro_FORMS src/[Link])
# Add Windows specific resource file used for application icons.
LIST(APPEND antimicro_RESOURCES src/resources_windows.qrc)

if(WITH_VMULTI)
list(APPEND antimicro_SOURCES src/[Link]
src/eventhandlers/[Link]
# vmulti/client/client.c
)
list(APPEND antimicro_HEADERS src/qtvmultikeymapper.h
src/eventhandlers/winvmultieventhandler.h
)
endif(WITH_VMULTI)
endif(UNIX)

set(USE_QT5 OFF)
set(USE_QT4 OFF)

set(CMAKE_AUTOMOC ON)
if(UNIX)
# Check if Qt 4 or 5 was specified using an environment variable
# or by specifying -DQT_QMAKE_EXECUTABLE.
# Otherwise, check for Qt libraries.
if("$ENV{QT_SELECT}" EQUAL 5)
set(USE_QT5 ON)
elseif(QT_QMAKE_EXECUTABLE MATCHES ".*/qmake-qt5")
set(USE_QT5 ON)
elseif ("$ENV{QT_SELECT}" EQUAL 4)
set(USE_QT4 ON)
elseif(QT_QMAKE_EXECUTABLE MATCHES ".*/qmake-qt4")
set(USE_QT4 ON)
else()
find_package(Qt5Core QUIET)
if(Qt5Core_FOUND)
set(USE_QT5 ON)
else()
find_package(Qt4 QUIET)
if(QT_FOUND)
set(USE_QT4 ON)
else()
message(FATAL_ERROR "No Qt libraries could be found.")
endif(QT_FOUND)
endif(Qt5Core_FOUND)
endif("$ENV{QT_SELECT}" EQUAL 5)
elseif(WIN32)
# Use Qt5 on Windows.
set(USE_QT5 ON)
endif(UNIX)

if(USE_QT5)
message("Compiling with Qt5 support")
elseif(USE_QT4)
message("Compiling with Qt4 support")
if(NOT WITH_X11)
message(FATAL_ERROR "Cannot build application using Qt4 without X11
support.")
endif(NOT WITH_X11)
else()
message(FATAL_ERROR "No Qt version was specified.")
endif(USE_QT5)

if(USE_SDL_2)
add_definitions(-DUSE_SDL_2)
endif(USE_SDL_2)

if (WIN32)
if(PERFORM_SIGNING)
add_definitions(-DPERFORM_SIGNING)
endif(PERFORM_SIGNING)
endif (WIN32)

if(UNIX)
if(WITH_X11)
add_definitions(-DWITH_X11)
endif(WITH_X11)

if(WITH_XTEST)
add_definitions(-DWITH_XTEST)
endif(WITH_XTEST)

if(WITH_UINPUT)
add_definitions(-DWITH_UINPUT)
endif(WITH_UINPUT)
endif(UNIX)

if (UNIX)
if (USE_QT5)
# Find includes in corresponding build directories
#set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.

find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5LinguistTools REQUIRED)

QT5_WRAP_UI(antimicro_FORMS_HEADERS ${antimicro_FORMS})
QT5_ADD_RESOURCES(antimicro_RESOURCES_RCC ${antimicro_RESOURCES})
add_subdirectory("share/antimicro/translations")

include_directories(${Qt5Widgets_INCLUDE_DIRS})
add_definitions(${Qt5Widgets_DEFINITIONS})
include_directories(${Qt5Core_INCLUDE_DIRS})
add_definitions(${Qt5Core_DEFINITIONS})
include_directories(${Qt5Gui_INCLUDE_DIRS})
add_definitions(${Qt5Gui_DEFINITIONS})
include_directories(${Qt5Network_INCLUDE_DIRS})
add_definitions(${Qt5Network_DEFINITIONS})

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Add compiler flags for building executables (-fPIE)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $
{Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

LIST(APPEND LIBS ${Qt5Widgets_LIBRARIES}


${Qt5Core_LIBRARIES}
${Qt5Gui_LIBRARIES}
${Qt5Network_LIBRARIES}
)
else()
find_package(Qt4 REQUIRED)
set(QT_USE_QTNETWORK TRUE)

QT4_WRAP_UI(antimicro_FORMS_HEADERS ${antimicro_FORMS})
QT4_ADD_RESOURCES(antimicro_RESOURCES_RCC ${antimicro_RESOURCES})

add_subdirectory("share/antimicro/translations")

include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
list(APPEND LIBS ${QT_LIBRARIES})
endif(USE_QT5)

elseif(WIN32)
# Find includes in corresponding build directories
#set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.

find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5LinguistTools REQUIRED)

QT5_WRAP_UI(antimicro_FORMS_HEADERS ${antimicro_FORMS})
QT5_ADD_RESOURCES(antimicro_RESOURCES_RCC ${antimicro_RESOURCES})
add_subdirectory("share/antimicro/translations")

include_directories(${Qt5Widgets_INCLUDE_DIRS})
add_definitions(${Qt5Widgets_DEFINITIONS})
include_directories(${Qt5Core_INCLUDE_DIRS})
add_definitions(${Qt5Core_DEFINITIONS})
include_directories(${Qt5Gui_INCLUDE_DIRS})
add_definitions(${Qt5Gui_DEFINITIONS})
include_directories(${Qt5Network_INCLUDE_DIRS})
add_definitions(${Qt5Network_DEFINITIONS})

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Add compiler flags for building executables (-fPIE)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $
{Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

LIST(APPEND LIBS ${Qt5Widgets_LIBRARIES}


${Qt5Core_LIBRARIES}
${Qt5Gui_LIBRARIES}
${Qt5Network_LIBRARIES}
)
endif(UNIX)

if(UNIX)
if(WITH_X11)
LIST(APPEND LIBS ${X11_X11_LIB})
LIST(APPEND LIBS ${X11_Xi_LIB})
endif(WITH_X11)
if(WITH_XTEST)
LIST(APPEND LIBS ${X11_XTest_LIB})
endif(WITH_XTEST)

if(USE_SDL_2)
list(APPEND LIBS ${SDL2_LIBRARIES})
else()
list(APPEND LIBS ${SDL_LIBRARIES})
endif(USE_SDL_2)
elseif (WIN32)
if(USE_SDL_2)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
message("SDL2 include dir: ${SDL2_INCLUDE_DIRS}")
list(APPEND LIBS ${SDL2_LIBRARIES})

add_definitions(-DUNICODE -D_UNICODE)
endif(USE_SDL_2)

list(APPEND LIBS "psapi")

if(WITH_VMULTI)
include_directories("${PROJECT_SOURCE_DIR}/vmulti/inc")
list(APPEND LIBS "hid" "setupapi")
endif(WITH_VMULTI)
endif (UNIX)

include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("${PROJECT_SOURCE_DIR}/src")

if(UNIX)
# Store executable in a bin subdir. Needed here so translations can be loaded.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
endif(UNIX)

if(USE_QT5)
if(UNIX)
add_executable(antimicro ${antimicro_SOURCES}
${antimicro_FORMS_HEADERS}
${antimicro_RESOURCES_RCC}
)
elseif(WIN32)
# The WIN32 is required to specify a GUI application.
add_executable(antimicro WIN32 ${antimicro_SOURCES}
${antimicro_FORMS_HEADERS}
${antimicro_RESOURCES_RCC}
src/[Link]
)
endif(UNIX)

else()
add_executable(antimicro ${antimicro_SOURCES}
${antimicro_HEADERS_MOC}
${antimicro_FORMS_HEADERS}
${antimicro_RESOURCES_RCC}
)

endif(USE_QT5)
# Add link libraries.
#message(${LIBS})
target_link_libraries(antimicro ${LIBS})

# Specify out directory for final executable.


if(UNIX)
install(TARGETS antimicro RUNTIME DESTINATION "bin")
elseif(WIN32)
install(TARGETS antimicro RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
endif(UNIX)

if(UNIX)
install(FILES src/images/[Link] DESTINATION "share/pixmaps")
install(FILES other/[Link] DESTINATION "share/applications")
install(FILES other/[Link] DESTINATION "share/mime/packages")
endif(UNIX)

# Add man page for *nix platforms.


if(UNIX)
add_subdirectory(other)

# Only way to force install target to be dependent on manpage.


install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} manpage
WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\")")

if(APPDATA)
# Only way to force install target to be dependent on appdata.
install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} appdata
WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\")")
endif(APPDATA)
endif(UNIX)

# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.[Link]"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

# Only way to force install target to be dependent on updateqm.


install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} updateqm
WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\")")

# Use this to use some variables created here in the actual project.
# Modify the [Link] file using the appropriate variables.
configure_file(
"${PROJECT_SOURCE_DIR}/src/[Link]"
"${PROJECT_BINARY_DIR}/config.h"
)

# Copy current Changelog file to location that the resource file expects.
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Changelog DESTINATION $
{CMAKE_CURRENT_SOURCE_DIR}/src/)

if(WIN32)
#if(TARGET_ARCH STREQUAL "x86_64")
# # Copy [Link] to find installation directory.
# add_custom_target(copy_sdl_dll
# COMMAND ${CMAKE_COMMAND} -E copy "${SDL2_BASE_DIR}/x86_64-w64-
mingw32/bin/[Link]" ${CMAKE_CURRENT_BINARY_DIR}
# )
#else()
# # Copy [Link] to find installation directory.
# add_custom_target(copy_sdl_dll
# COMMAND ${CMAKE_COMMAND} -E copy
"${SDL2_BASE_DIR}/i686-w64-mingw32/bin/[Link]" ${CMAKE_CURRENT_BINARY_DIR}
# )
#endif(TARGET_ARCH STREQUAL "x86_64")

add_custom_target(copy_sdl_dll
COMMAND ${CMAKE_COMMAND} -E copy "${SDL2_DLL_LOCATION_DIR}/[Link]" $
{CMAKE_CURRENT_BINARY_DIR}
)

# Obtain location of Qt5 DLL files and assign them to a list.


# This list will only be used for Release builds.
get_target_property(QTCORE_DLL_LOCATION Qt5::Core LOCATION)
string(REPLACE "/[Link]" "" QTCORE_DLL_LOCATION ${QTCORE_DLL_LOCATION})
set(EXTRA_QT_DLL_FILES
"${QTCORE_DLL_LOCATION}/[Link]"
"${QTCORE_DLL_LOCATION}/[Link]"
"${QTCORE_DLL_LOCATION}/[Link]"
"${QTCORE_DLL_LOCATION}/[Link]"
)

find_library(EXTRA_DLLS_PTHREAD NAMES "[Link]" )


find_library(EXTRA_DLLS_LIBCPP NAMES "libstdc++-[Link]" )

# Don't think find_library will handle versioned DLLS, so we'll try each one
until we find something
foreach( ICU_VER 51 52 53 54 55 56 57 58 59 )
find_library(ICU_DT_DLL NAMES "icudt${ICU_VER}.dll")
find_library(ICU_IN_DLL NAMES "icuin${ICU_VER}.dll")
find_library(ICU_UC_DLL NAMES "icuuc${ICU_VER}.dll")
endforeach( ICU_VER )

list(APPEND EXTRA_DLL_FILES
${EXTRA_QT_DLL_FILES}
${EXTRA_DLLS_PTHREAD}
${EXTRA_DLLS_LIBCPP}
${ICU_DT_DLL}
${ICU_IN_DLL}
${ICU_UC_DLL}
)

# Copy relevant DLL files depending on the chosen architecture.


if(TARGET_ARCH STREQUAL "x86_64")
find_library( GCC_DLL "libgcc_s_seh-[Link]" )

list(APPEND EXTRA_DLL_FILES
${GCC_DLL}
"${SDL2_BASE_DIR}/x86_64-w64-mingw32/bin/[Link]"
)
else()
find_library( GCC_DLL "libgcc_s_dw2-[Link]" )

list(APPEND EXTRA_DLL_FILES
${GCC_DLL}
"${SDL2_BASE_DIR}/i686-w64-mingw32/bin/[Link]"
)
endif(TARGET_ARCH STREQUAL "x86_64")

# Not a DLL file, but needs to travel with [Link]


list(APPEND EXTRA_DLL_FILES "${SDL2_BASE_DIR}/[Link]")

# Target to copy Qt DLL files.


add_custom_target(install_extra_dlls)

# Create destination directory if it does not exist.


add_custom_command(TARGET install_extra_dlls PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_INSTALL_PREFIX}/"
)

foreach(CURRENT_DLL_FILE ${EXTRA_DLL_FILES})
add_custom_command(TARGET install_extra_dlls PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CURRENT_DLL_FILE} "$
{CMAKE_INSTALL_PREFIX}/"
)
endforeach()

# Target to copy [Link] platforms file.


add_custom_target(install_platforms_dll)
add_custom_command(TARGET install_platforms_dll PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QTCORE_DLL_LOCATION}/../plugins/platforms/[Link]"
"${CMAKE_INSTALL_PREFIX}/platforms/[Link]"
)

# Combine the two targets into a single target that will be used
# while bundling the program.
add_custom_target(install_dlls)
add_dependencies(install_dlls
install_extra_dlls
install_platforms_dll
)

# Copy bundled Qt translation files.


SET(QT_TRANSLATION_PATH "${QTCORE_DLL_LOCATION}/../translations/" )
file(GLOB QT_TRANSLATION_FILES "${QT_TRANSLATION_PATH}qt_[^help]*.qm")
add_custom_target(copy_qt_translations)
foreach(CURRENT_QM_FILE ${QT_TRANSLATION_FILES})
set(CURRENT_QM_FILENAME "")
string(REPLACE ${QT_TRANSLATION_PATH} "" CURRENT_QM_FILENAME $
{CURRENT_QM_FILE})
add_custom_command(TARGET copy_qt_translations PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CURRENT_QM_FILE}"
"${CMAKE_INSTALL_PREFIX}/share/qt/translations/${CURRENT_QM_FILENAME}"
)
endforeach()

# Sign final executable


if(PERFORM_SIGNING)
install(CODE "execute_process(COMMAND \"C:/Program Files (x86)/Windows
Kits/8.1/bin/x64/[Link]\"
sign /v /a /s ROOT /n antimicro
${CMAKE_INSTALL_PREFIX}/[Link])")
endif(PERFORM_SIGNING)

# Set variables needed for MSI building.


set(MSIFOLDER "${PROJECT_SOURCE_DIR}/windows")
set(WIXENV $ENV{WIX})

# Use a different file for each architecture due


# to some DLL differences.
if(TARGET_ARCH STREQUAL "x86_64")
set(WIXWXS "${MSIFOLDER}/antimicro_64.wxs")
else()
set(WIXWXS "${MSIFOLDER}/[Link]")
endif(TARGET_ARCH STREQUAL "x86_64")

set(WIXOBJ "${MSIFOLDER}/[Link]")

# Use version number in output file name.


set(MSIFILENAME "${ANTIMICRO_MAJOR_VERSION}.${ANTIMICRO_MINOR_VERSION}")
if(ANTIMICRO_PATCH_VERSION AND NOT ANTIMICRO_PATCH_VERSION EQUAL 0)
set(MSIFILENAME "${MSIFILENAME}.${ANTIMICRO_PATCH_VERSION}")
endif(ANTIMICRO_PATCH_VERSION AND NOT ANTIMICRO_PATCH_VERSION EQUAL 0)

# Change output file depending on the target architecture.


if(TARGET_ARCH STREQUAL "x86_64")
set(WIXMSI "${MSIFOLDER}/antimicro-${MSIFILENAME}-[Link]")
else()
set(WIXMSI "${MSIFOLDER}/antimicro-${MSIFILENAME}-[Link]")
endif(TARGET_ARCH STREQUAL "x86_64")

if(NOT WIXENV)
# Display message when WIX is not set up. No extra target will be added.
message("MSI package building not possible: WIX environment variable not
defined.")
else()
# Target to build .msi installer file.
add_custom_target(buildmsi)

# Change arch value passed to [Link]


set(WIXARCH "")
if(TARGET_ARCH STREQUAL "x86_64")
set(WIXARCH "x64")
else()
set(WIXARCH "x86")
endif(TARGET_ARCH STREQUAL "x86_64")

add_custom_command(TARGET buildmsi PRE_BUILD


COMMAND "${WIXENV}\\bin\\[Link]" ${WIXWXS} -out ${WIXOBJ} -sw1113 -
arch ${WIXARCH} &&
"${WIXENV}\\bin\\[Link]" ${WIXOBJ} -out ${WIXMSI} -sw1076 -spdb
)
set(WIXFILES ${WIXOBJ} ${WIXMSI})
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "$
{WIXFILES}")
endif(NOT WIXENV)
# Copy extra files to include in the final archive.
install(FILES [Link] Changelog [Link] [Link]
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif(WIN32)

You might also like