Update CMakeLists

This commit is contained in:
Rico Tiongson 2020-04-18 15:30:21 +08:00
parent 7d897ac09e
commit f2893e4aaa
5 changed files with 37 additions and 29 deletions

15
.gitignore vendored
View File

@ -2,8 +2,19 @@
.idea .idea
.vscode .vscode
# Build # CMake
build/ CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
*.cmake
# Library # Library
.lib .lib

View File

@ -1,17 +1,11 @@
# HEADER: versions # Run with: cmake . && make && make install
cmake_minimum_required(VERSION 3.10.2) cmake_minimum_required(VERSION 3.10.2)
project(comfortable-swipe) project(comfortable-swipe)
set(CMAKE_PROJECT_NAME "Comfortable Swipe")
set(CMAKE_PROJECT_DESCRIPTION "Comfortable 3/4-finger swipe gestures")
# link external C++ libraries here # creat project properties
find_library(XDO_LIB libxdo.a)
# CMAKE variables
set(CMAKE_INSTALL_PREFIX "/home/rico/Git/comfortable-swipe-ubuntu/dist")
set(CMAKE_PROJECT_NAME "comfortable-swipe")
set(CMAKE_PROJECT_DESCRIPTION "3/4-finger comfortableswipe gestures")
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
# set flags to use C++ 11 # set flags to use C++ 11
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
@ -19,38 +13,36 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS_DISTRIBUTION "-O2") set(CMAKE_CXX_FLAGS_DISTRIBUTION "-O2")
# set main directories # set main directories
set(comfortable_swipe_bin "${CMAKE_CURRENT_BINARY_DIR}/bin") set(comfortable_swipe_bin "${CMAKE_INSTALL_PREFIX}/bin")
set(comfortable_swipe_lib "${CMAKE_CURRENT_BINARY_DIR}/lib") set(comfortable_swipe_lib "${CMAKE_INSTALL_PREFIX}/lib")
set(comfortable_swipe_share "${CMAKE_CURRENT_BINARY_DIR}/share") set(comfortable_swipe_share "${CMAKE_INSTALL_PREFIX}/share")
set(comfortable_swipe_include "${CMAKE_CURRENT_BINARY_DIR}/include") set(comfortable_swipe_include "${CMAKE_INSTALL_PREFIX}/include")
# set version from VERSION file # set version from VERSION file
file(STRINGS "VERSION" comfortable_swipe_version) file(STRINGS "VERSION" comfortable_swipe_version)
# set project variables # set project variables
set(comfortable_swipe_exe_source "${CMAKE_CURRENT_SOURCE_DIR}/comfortable-swipe.cpp")
set(comfortable_swipe_exe_path "${comfortable_swipe_bin}/comfortable-swipe") set(comfortable_swipe_exe_path "${comfortable_swipe_bin}/comfortable-swipe")
set(comfortable_swipe_conf_path "/usr/local/share/comfortable-swipe/comfortable-swipe.conf") set(comfortable_swipe_conf_path "/usr/local/share/comfortable-swipe/comfortable-swipe.conf")
# C++ definitions # C++ definitions
add_definitions( add_definitions(
-DCMAKE_BUILD 1
-DCOMFORTABLE_SWIPE_VERSION="${comfortable_swipe_version}" -DCOMFORTABLE_SWIPE_VERSION="${comfortable_swipe_version}"
-DCOMFORTABLE_SWIPE_PROGRAM="${comfortable_swipe_exe_path}" -DCOMFORTABLE_SWIPE_PROGRAM="${comfortable_swipe_exe_path}"
-DCOMFORTABLE_SWIPE_CONFIG="${comfortable_swipe_conf_path}" -DCOMFORTABLE_SWIPE_CONFIG="${comfortable_swipe_conf_path}"
) )
# add our own comfortable-swipe library # add our build-time only static library
add_library(comfortable-swipe.a STATIC "${CMAKE_CURRENT_SOURCE_DIR}/src/comfortable_swipe.cpp") add_library(comfortable-swipe.lib STATIC "src/comfortable_swipe.cpp")
target_include_directories(comfortable-swipe.a PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src") target_include_directories(comfortable-swipe.lib PUBLIC "src")
set_target_properties(comfortable-swipe.a PROPERTIES OUTPUT_NAME "comfortable-swipe")
# register comfortable-swipe command line program # register comfortable-swipe command line program
add_executable("comfortable-swipe" "${comfortable_swipe_exe_source}") add_executable("comfortable-swipe" "comfortable-swipe.cpp")
# add libraries to target # link libraries here
target_link_libraries(comfortable-swipe.a "${XDO_LIB}") find_library(XDO libxdo.so)
target_link_libraries(comfortable-swipe comfortable-swipe.a) target_link_libraries(comfortable-swipe.lib "${XDO}")
target_link_libraries(comfortable-swipe comfortable-swipe.lib)
# perform installation # perform installation
install(TARGETS comfortable-swipe DESTINATION bin) install(TARGETS comfortable-swipe DESTINATION bin)

BIN
comfortable-swipe Executable file

Binary file not shown.

View File

@ -16,10 +16,15 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "src/comfortable_swipe.cpp"
#include <ios> // std::ios #include <ios> // std::ios
#include <iostream> // std::cin, std::cout, std::cerr #include <iostream> // std::cin, std::cout, std::cerr
#include <string> // std::string #include <string> // std::string
#include "src/comfortable_swipe.h" // comfortable_swipe
// make sure implementation is also imported
#ifndef __COMFORTABLE_SWIPE__
#include "src/comfortable_swipe.cpp"
#endif
/* Command-line function. */ /* Command-line function. */

View File

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "comfortable_swipe.h" #include "comfortable_swipe.h"
#include "start.cpp"
#include "gesture/keyboard_swipe_gesture.cpp" #include "gesture/keyboard_swipe_gesture.cpp"
#include "gesture/mouse_hold_gesture.cpp" #include "gesture/mouse_hold_gesture.cpp"
@ -39,7 +40,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "service/start.cpp" #include "service/start.cpp"
#include "service/status.cpp" #include "service/status.cpp"
#include "service/stop.cpp" #include "service/stop.cpp"
#include "start.cpp"
#include "util/autostart_filename.cpp" #include "util/autostart_filename.cpp"
#include "util/conf_filename.cpp" #include "util/conf_filename.cpp"
#include "util/read_config_file.cpp" #include "util/read_config_file.cpp"