From: Drew Fisher Date: Tue, 25 Oct 2011 07:14:38 +0000 (-0700) Subject: First pass at a CMakeLists.txt to support building on Windows, OSX, and Linux. X-Git-Url: http://git.zarvox.org/shortlog/%7Bdate%7D?a=commitdiff_plain;h=f34ee8c5ffde5fc916f9be7d677fe359864f8df5;p=libtouchmouse.git First pass at a CMakeLists.txt to support building on Windows, OSX, and Linux. Signed-off-by: Drew Fisher --- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9039226 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,38 @@ +# libtouchmouse + +cmake_minimum_required(VERSION 2.6) + +project(libtouchmouse) + +# Set up output folder +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) + +# Add include path to hidapi.h +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/hidapi/hidapi) + +if(WIN32) + # Win32-specific options go here. + message(STATUS "Detected Win32 system") + list(APPEND SRC hidapi/windows/hid.c) +elseif(APPLE) + # Apple-specific options go here. + message(STATUS "Detected Apple system") + list(APPEND SRC hidapi/mac/hid.c) + set(CMAKE_EXE_LINKER_FLAGS "-framework IOKit -framework CoreFoundation") +else() + # Linux-specific options go here. + message(STATUS "Detected non-windows, non-apple system; assuming some Linux variant") + include_directories(/usr/include/libusb-1.0) + list(APPEND SRC hidapi/linux/hid-libusb.c) +endif() + +# Build + +set(CMAKE_C_FLAGS "-Wall") + +add_executable(touchmouse touchmouse.c ${SRC}) +if(WIN32) + target_link_libraries(touchmouse setupapi) +elseif(NOT APPLE) + target_link_libraries(touchmouse usb-1.0 pthread rt) +endif() diff --git a/Makefile b/Makefile deleted file mode 100644 index 0463752..0000000 --- a/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# TODO: make this work in a cross-platform manner, using HIDAPI's different backends - -CC=gcc -CFLAGS=-I./hidapi/hidapi `pkg-config --cflags libusb-1.0` -LIBS=`pkg-config --libs libusb-1.0 libudev` -lpthread - -touchmouse: touchmouse.o hid-libusb.o - ${CC} -o touchmouse touchmouse.o hid-libusb.o ${LIBS} - -touchmouse.o: touchmouse.c - -#hid.o: hidapi/linux/hid.c -# ${CC} -c ${CFLAGS} -o hid.o hidapi/linux/hid.c - -hid-libusb.o: hidapi/linux/hid-libusb.c - ${CC} -c ${CFLAGS} -o hid-libusb.o hidapi/linux/hid-libusb.c - -clean: - rm -f touchmouse *.o