ported build system to cmake

This commit is contained in:
Mathias Panzenböck
2014-02-15 03:54:28 +01:00
parent 6fa91c4529
commit 5ca0712af2
8 changed files with 130 additions and 128 deletions

5
.gitignore vendored
View File

@ -1,5 +1,2 @@
.*
*.o
src/moc_*.cpp
src/qjoypad
src/Makefile
build

48
CMakeLists.txt Normal file
View File

@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 2.8.8)
project(qjoypad)
find_package(Qt4 REQUIRED)
set(DEVICE_DIR "/dev/input" CACHE PATH "Set the path where QJoyPad will look for your joystick devices. If your devices are /dev/js0, /dev/js1, etc., this should be just \"/dev\". By default, this is /dev/input.")
set(PLAIN_KEYS OFF CACHE BOOL "Force QJoyPad to use standard XWindows keynames without filtering them for appearance. This will make displays less attractive and readable, but will save processor power and ensure that you see the right names for keys you press.")
message("-- Using device directory: ${DEVICE_DIR}")
add_definitions(-DDEVDIR="${DEVICE_DIR}")
if(PLAIN_KEYS)
message("-- Using regular XWindows key names.")
add_definitions(-DPLAIN_KEYS)
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-deprecated-declarations")
if(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif()
endif()
if(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug"))
add_definitions(-D_DEBUG)
endif()
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
add_definitions(-DICON24="${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/24x24/apps/qjoypad.png")
add_definitions(-DICON64="${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/64x64/apps/qjoypad.png")
add_subdirectory(icons)
add_subdirectory(src)
install(PROGRAMS qjoypad.desktop DESTINATION "share/applications")
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")

View File

@ -0,0 +1,21 @@
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif()
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach (file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if (EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
endif ()
else ()
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
endif ()
endforeach()

2
icons/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
install(FILES gamepad4-24x24.png DESTINATION "share/icons/hicolor/24x24/apps" RENAME qjoypad.png)
install(FILES gamepad3-64x64.png DESTINATION "share/icons/hicolor/64x64/apps" RENAME qjoypad.png)

11
qjoypad.desktop Executable file
View File

@ -0,0 +1,11 @@
[Desktop Entry]
Name=QJoyPad
GenericName=Joypad to Keyboard/Mouse Mapper
GenericName[de]=Joypad zu Tastatur/Maus Mapper
Exec=qjoypad
Icon=qjoypad
Type=Application
Terminal=false
Categories=Qt;Games;
Comment=Maps joypad button and stick events to keyboard and mouse events.
Comment[de]=Bildet Joypad Knopf und Stick Ereignisse auf Tastatur und Maus Ereignisse ab.

47
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,47 @@
set(qjoypad_SOURCES
axis.cpp
axis_edit.cpp
axisw.cpp
button.cpp
button_edit.cpp
buttonw.cpp
event.cpp
flash.cpp
getkey.cpp
icon.cpp
joypad.cpp
joypadw.cpp
joyslider.cpp
keycode.cpp
layout.cpp
layout_edit.cpp
main.cpp
quickset.cpp)
set(qjoypad_HEADERS
axis_edit.h
axis.h
axisw.h
button_edit.h
button.h
buttonw.h
constant.h
device.h
error.h
event.h
flash.h
getkey.h
icon.h
joypad.h
joypadw.h
joyslider.h
keycode.h
layout_edit.h
layout.h
quickset.h)
QT4_WRAP_CPP(qjoypad_HEADERS_MOC ${qjoypad_HEADERS})
add_executable(qjoypad ${qjoypad_SOURCES} ${qjoypad_HEADERS_MOC})
target_link_libraries(qjoypad ${QT_LIBRARIES} Xtst X11)
install(TARGETS qjoypad RUNTIME DESTINATION "bin")

View File

@ -1,123 +0,0 @@
#!/bin/bash
if( ! pkg-config --exists xtst ); then
echo "Error: you will need libxtst to compile this program";
exit 1;
fi;
if( ! pkg-config --atleast-version=4.2 QtCore ); then
echo "Error: you need at least Qt version 4.2 to use this program";
exit 1;
fi;
if( ! ( qmake --version | grep -qi 'Qt version 4' ) ); then
echo "WARNING: Falling back on qmake-qt4; this may or may not work";
echo "WARNING: if it fails please see the compilation instructions on
qjoypad.sourceforge.net";
QMAKE_EXEC="qmake-qt4";
else
QMAKE_EXEC="qmake";
fi;
devdir="/dev/input"
prefix="/usr/local"
installdir="";
plain_keys=""
debug_option="";
build_mode="release";
for arg in $*
do
case $arg in
--help) echo "
Usage: ./config [--devdir=\"dir\"] [--prefix=\"prefix\"] [--help]
Options:
--devdir=DIR Set the path where QJoyPad will look for your joystick
devices to be DIR. If your devices are /dev/js0, /dev/js1,
etc., this should be just \"/dev\". By default, this is
/dev/input.
--prefix=DIR Set the path where QJoyPad and its components will be
installed. By default, this is /usr/local.
--plain_keys Force QJoyPad to use standard XWindows keynames without
filtering them for appearance. This will make displays
less attractive and readable, but will save processor power
and ensure that you see the right names for keys you press.
--install-dir=DIR Sets an optional installation path that will be prepended
to prefix during installation.
--debug Causes Qjoypad to spit out debugging messages (debug messages
will be compiled in; to get rid of the messages you'll have
to recompile).
--qmake4bin=EXEC Overrides the qmake executable used by this script.
EXEC may be relative to PATH or an absolute pathname.
--help Show this message.
"; exit 0;;
--devdir=*) devdir=${arg##*=}
if [[ ! -d $devdir ]]
then
echo "Invalid device directory given: $devdir"
exit 1
fi ;;
--prefix=*) prefix=${arg##*=}
if [[ ! -d $prefix ]]
then
echo "Invalid prefix directory given: $prefix"
exit 1
fi;;
--install-dir=*) installdir=${arg##*=}
if [[ ! -d $installdir ]]
then
echo "invalid destination directory given: $installdir";
exit 1
fi;;
--plain_keys) plain_keys="PLAIN_KEYS";;
--debug)
debug_option+="_DEBUG";
build_mode="debug";;
--qmake4bin=*) QMAKE_EXEC=${arg##*=};;
*) echo "Unrecognized argument: \"$arg\". Try ./config --help for help."
esac
done
if ( ! $QMAKE_EXEC -makefile DEVDIR=$devdir PREFIX=$prefix \
"DEFINES += $plain_keys $debug_option" \
INSTALL_PREFIX=${installdir}/${prefix}/ \
"CONFIG += $build_mode" \
qjoypad.pro ); then
echo "Config failed. If you overrode the qmake exec, make sure it
is valid! Otherwise, email virtuoussin13@users.sourceforge.net for help";
exit 1;
fi
echo "
Configuring QJoyPad installation...
------------------------------------------------------------
Device directory: $devdir
-- Devices will be looked for in:
$devdir/js0
$devdir/js1
etc.
Prefix directory: $prefix
-- Files to be installed in:
$prefix/bin
$prefix/doc
$prefix/share/pixmaps"
if [[ -n $plain_keys ]]; then
echo "
-- Using regular XWindows key names.";
fi
echo "
---------------------------------------------------------
If these settings are okay, go ahead and run 'make' and
then 'make install'.
To make changes, run ./config --help for details.
"

1
src/configure vendored
View File

@ -1 +0,0 @@
config