]> git.donarmstrong.com Git - kiibohd-controller.git/blob - LoadFile/CMakeLists.txt
More Windows compatibility build fixes
[kiibohd-controller.git] / LoadFile / CMakeLists.txt
1 ###| CMAKE teensy-loader-cli |###
2 #
3 # Jacob Alexander 2014
4 # Written to replace the pjrc's kludey Makefiles
5 #  (that require hand edits for different platforms)
6 #
7 # Released into the Public Domain
8 #
9 ###
10
11 #| Windows / Cygwin Compatibility options
12 set( CMAKE_LEGACY_CYGWIN_WIN32 0 )
13 set( CMAKE_USE_RELATIVE_PATHS  1 )
14
15
16
17 ###
18 # Project Description
19 #
20
21 #| Project
22 project( teensy-loader-cli )
23
24 #| Target Name (output name)
25 set( TARGET teensy-loader-cli )
26
27 #| General Settings
28 cmake_minimum_required( VERSION 2.8 )
29
30
31
32 ###
33 # Source Defines
34 #
35
36 #| Sources
37 set( SRCS
38         teensy_loader_cli.c
39 )
40
41
42
43 ###
44 # Platform Setup
45 #
46 list( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR} ) # Use local find scripts
47
48 #| Linux - libusb
49 if( CMAKE_SYSTEM_NAME MATCHES "Linux" )
50         # Find libusb (not 1.0)
51         find_package( LibUSB REQUIRED )
52
53         # Defines
54         set( DEFINES -s -DUSE_LIBUSB )
55
56         # Include directories
57         set( INCLUDE_DIRS ${LIBUSB_INCLUDE_DIRS} )
58
59         # Libraries
60         set( LIBS ${LIBUSB_LIBRARIES} )
61
62 #| Windows
63 elseif( CMAKE_SYSTEM_NAME MATCHES "CYGWIN" )
64         message( AUTHOR_WARNING "Not Tested...")
65
66         # Defines
67         set( DEFINES -s -DUSE_WIN32 )
68
69         # Libraries
70         set( LIBS hid setupapi )
71
72 #| Mac OS X
73 elseif( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
74         message( AUTHOR_WARNING "Not Tested...")
75
76         # Defines - XXX What is SDK?
77         set( DEFINES -DUSE_APPLE_IOKIT -isysroot ${SDK} -Wl,-syslibroot,${SDK} -framework IOKit -framework CoreFoundation )
78
79 #| BSD - NetBSD and OpenBSD
80 elseif( CMAKE_SYSTEM_NAME MATCHES "BSD" )
81         message( AUTHOR_WARNING "Not Tested...")
82
83         # Defines
84         set( DEFINES -s -DUSE_UHID )
85 #| Unregonized OS
86 else()
87         message( FATAL_ERROR "${CMAKE_SYSTEM_NAME}: OS Not Recognized..." )
88 endif()
89
90
91
92 ###
93 # Defines
94 #
95
96 #| Default CFLAGS
97 set( CFLAGS -O2 -Wall )
98
99 add_definitions( ${CFLAGS} ${DEFINES} )
100
101
102
103 ###
104 # Includes
105 #
106
107 #| Linux
108 include_directories( ${INCLUDE_DIRS} )
109
110
111
112 ###
113 # Build Targets
114 #
115
116 #| Create the executable
117 add_executable( ${TARGET} ${SRCS} )
118
119 #| Link executable
120 target_link_libraries( ${TARGET} ${LIBS} )
121