Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added cmake and replaced libhid with libhidapi #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
### JetBrains template
.idea/

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### CMake template
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps

52 changes: 52 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.15)
project(dcled VERSION 3.0)


# Config
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_CXX_STANDARD 14)


# Dependencies
include(GNUInstallDirs)

find_package(LibHIDAPI REQUIRED)
include_directories(${LIBHIDAPI_INCLUDE_DIR})


# OS Specific Dependencies
if(APPLE)
find_library(CF CoreFoundation)
find_library(IOK IOKit AppKit)
endif()


# Check if lib m is required
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS(m sin "" HAVE_LIB_M)


# Add definitions
add_definitions(-DDCLEDVERSION="${PROJECT_VERSION}")
add_definitions(-DFONTDIR="${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}")


# Applications
add_executable(dcled
dcled.c)
target_link_libraries(dcled ${LIBHIDAPI_LIBRARY})
if(APPLE)
target_link_libraries(dcled "-framework AppKit")
target_link_libraries(dcled ${CF} ${IOK})
endif()

if (HAVE_LIB_M)
target_link_libraries(dcled m)
endif()


# Installation information
install(TARGETS dcled
CONFIGURATIONS Release
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/fonts/ DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
38 changes: 38 additions & 0 deletions cmake/FindLibHIDAPI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# FindLibHIDAPI.cmake
# Once done this will define
#
# LIBHIDAPI_FOUND - System has libserialport
# LIBHIDAPI_INCLUDE_DIR - The libserialport include directory
# LIBHIDAPI_LIBRARY - The libraries needed to use libserialport
# LIBHIDAPI_DEFINITIONS - Compiler switches required for using libserialport

find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_HIDAPI QUIET hidapi-libusb)
endif()

# FreeBSD
FIND_PATH(LIBHIDAPI_INCLUDE_DIR NAMES hidapi.h
HINTS
${PC_HIDAPI_INCLUDE_DIRS}
/usr
/usr/local
/opt
PATH_SUFFIXES hidapi
)

find_library(LIBHIDAPI_LIBRARY NAMES hidapi-libusb hidapi
HINTS
${PC_HIDAPI_LIBRARY_DIRS}
/usr
/usr/local
/opt)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibHIDAPI DEFAULT_MSG LIBHIDAPI_LIBRARY LIBHIDAPI_INCLUDE_DIR)

mark_as_advanced(LIBHIDAPI_INCLUDE_DIR LIBHIDAPI_LIBRARY)

if (LIBHIDAPI_FOUND)
message(STATUS "found HIDAPI")
endif ()
Loading