1
0
mirror of https://github.com/MatMoul/g810-led.git synced 2025-04-04 15:21:45 +00:00

cmake support and reordering of files

This commit is contained in:
Kamil Strzempowicz 2018-01-31 21:52:07 +01:00
parent 1b480ae4c2
commit cea21604eb
11 changed files with 108 additions and 5 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
bin/*
lib/*
.
*.user
*.swp
build/

64
CMakeLists.txt Normal file
View File

@ -0,0 +1,64 @@
cmake_minimum_required(VERSION 3.1)
project(g810-led)
option(USE_LIBUSB "Use libusb instead of hidapi" OFF)
#
# Generic Compiler Flags
#
set(CMAKE_CXX_STANDARD 11) #17?
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_DEBUG "-g -Wextra -pedantic ${CMAKE_CXX_FLAGS_DEBUG}")
if(USE_LIBUSB)
add_definitions(-Dlibusb)
set(DEP_LIBRARIES "usb-1.0")
else()
add_definitions(-Dhidapi)
set(DEP_LIBRARIES "hidapi-hidraw")
endif()
#
# version
#
set(MAJOR 0)
set(MINOR 2)
set(MICRO 7)
add_definitions(-DVERSION="${MAJOR}.${MINOR}.${MICRO}")
#
# Colored Terminal Output
#
if(UNIX AND (
(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9))
AND CMAKE_GENERATOR STREQUAL "Ninja")
# These compilers generate coloured output, but by default only when their output channel is a
# terminal (TTY/PTY). Ninja however captures all output in a pipe (per-subprocess), disabling
# coloured compiler diagnostics. We forcefully enable it because Ninja, since 1.0.0
# (ninja-build/ninja#198) takes care to strip VT100 CSI control sequences from the output if Ninja
# itself is writing to a pipe instead of a terminal. As a result this should give us the best of
# both worlds: coloured output when we're running in a terminal, plain output for editors, IDEs,
# etc.
set(CMAKE_CXX_FLAGS "-fdiagnostics-color=always ${CMAKE_CXX_FLAGS}" CACHE STRING "" FORCE)
endif()
#
# lib
#
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${INCLUDE_DIR})
add_subdirectory(src)
#
# app
#
add_subdirectory(app)

20
app/CMakeLists.txt Normal file
View File

@ -0,0 +1,20 @@
set(SOURCES
main.cpp
# utils.h
utils.cpp
# help.h
help.cpp
)
if(CMAKE_EXTRA_GENERATOR OR MSVC_IDE)
message(STATUS "Adding header files to project")
file(GLOB_RECURSE HEADERS "${INCLUDE_DIR}/*.h")
if(MSVC_IDE)
source_group("Header Files" FILES ${HEADERS})
endif()
list(APPEND SOURCES ${HEADERS})
endif()
add_executable(g810-led ${SOURCES})
target_link_libraries(g810-led PUBLIC libledkeyboard)

View File

@ -4,9 +4,9 @@
#include <fstream>
#include <map>
#include "helpers/help.h"
#include "helpers/utils.h"
#include "classes/Keyboard.h"
#include "help.h"
#include "utils.h"
#include "Keyboard.h"
int commit(LedKeyboard &kbd) {

View File

@ -3,7 +3,7 @@
#include <iostream>
#include <algorithm>
#include "../classes/Keyboard.h"
#include "Keyboard.h"
namespace utils {

View File

@ -2,7 +2,7 @@
#define UTILS_HELPER
#include <iostream>
#include "../classes/Keyboard.h"
#include "Keyboard.h"
namespace utils {

16
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,16 @@
set(SOURCES
Keyboard.cpp
)
if(CMAKE_EXTRA_GENERATOR OR MSVC_IDE)
message(STATUS "Adding header files to project")
file(GLOB_RECURSE HEADERS "${INCLUDE_DIR}/*.hpp")
if(MSVC_IDE)
source_group("Header Files" FILES ${HEADERS})
endif()
list(APPEND SOURCES ${CUKE_HEADERS})
endif()
add_library(libledkeyboard STATIC ${SOURCES})
target_link_libraries(libledkeyboard PRIVATE ${DEP_LIBRARIES})