2014-04-13 03:52:32 +00:00
|
|
|
###| CMAKE teensy-loader-cli |###
|
|
|
|
#
|
|
|
|
# Jacob Alexander 2014
|
|
|
|
# Written to replace the pjrc's kludey Makefiles
|
|
|
|
# (that require hand edits for different platforms)
|
|
|
|
#
|
|
|
|
# Released into the Public Domain
|
|
|
|
#
|
|
|
|
###
|
|
|
|
|
|
|
|
#| Windows / Cygwin Compatibility options
|
|
|
|
set( CMAKE_LEGACY_CYGWIN_WIN32 0 )
|
|
|
|
set( CMAKE_USE_RELATIVE_PATHS 1 )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# Project Description
|
|
|
|
#
|
|
|
|
|
|
|
|
#| Project
|
|
|
|
project( teensy-loader-cli )
|
|
|
|
|
|
|
|
#| Target Name (output name)
|
|
|
|
set( TARGET teensy-loader-cli )
|
|
|
|
|
|
|
|
#| General Settings
|
|
|
|
cmake_minimum_required( VERSION 2.8 )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# Source Defines
|
|
|
|
#
|
|
|
|
|
|
|
|
#| Sources
|
|
|
|
set( SRCS
|
|
|
|
teensy_loader_cli.c
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# Platform Setup
|
|
|
|
#
|
|
|
|
list( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR} ) # Use local find scripts
|
|
|
|
|
2014-04-18 20:16:47 +00:00
|
|
|
#| Linux/Windows - libusb
|
|
|
|
if( CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "CYGWIN" )
|
2014-04-13 03:52:32 +00:00
|
|
|
# Find libusb (not 1.0)
|
2014-04-18 07:18:02 +00:00
|
|
|
find_package( LibUSB-1.0 REQUIRED )
|
2014-04-13 03:52:32 +00:00
|
|
|
|
|
|
|
# Defines
|
|
|
|
set( DEFINES -s -DUSE_LIBUSB )
|
|
|
|
|
|
|
|
# Include directories
|
|
|
|
set( INCLUDE_DIRS ${LIBUSB_INCLUDE_DIRS} )
|
|
|
|
|
|
|
|
# Libraries
|
|
|
|
set( LIBS ${LIBUSB_LIBRARIES} )
|
|
|
|
|
|
|
|
#| Mac OS X
|
2014-04-18 02:20:56 +00:00
|
|
|
elseif( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
|
2014-04-13 03:52:32 +00:00
|
|
|
message( AUTHOR_WARNING "Not Tested...")
|
|
|
|
|
|
|
|
# Defines - XXX What is SDK?
|
|
|
|
set( DEFINES -DUSE_APPLE_IOKIT -isysroot ${SDK} -Wl,-syslibroot,${SDK} -framework IOKit -framework CoreFoundation )
|
|
|
|
|
|
|
|
#| BSD - NetBSD and OpenBSD
|
2014-04-18 02:20:56 +00:00
|
|
|
elseif( CMAKE_SYSTEM_NAME MATCHES "BSD" )
|
2014-04-13 03:52:32 +00:00
|
|
|
message( AUTHOR_WARNING "Not Tested...")
|
|
|
|
|
|
|
|
# Defines
|
|
|
|
set( DEFINES -s -DUSE_UHID )
|
2014-04-18 02:20:56 +00:00
|
|
|
#| Unregonized OS
|
|
|
|
else()
|
|
|
|
message( FATAL_ERROR "${CMAKE_SYSTEM_NAME}: OS Not Recognized..." )
|
2014-04-13 03:52:32 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# Defines
|
|
|
|
#
|
|
|
|
|
|
|
|
#| Default CFLAGS
|
2014-04-18 07:18:02 +00:00
|
|
|
set( CFLAGS -O2 -Wall -std=gnu99 )
|
2014-04-13 03:52:32 +00:00
|
|
|
|
|
|
|
add_definitions( ${CFLAGS} ${DEFINES} )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# Includes
|
|
|
|
#
|
|
|
|
|
|
|
|
#| Linux
|
|
|
|
include_directories( ${INCLUDE_DIRS} )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# Build Targets
|
|
|
|
#
|
|
|
|
|
|
|
|
#| Create the executable
|
|
|
|
add_executable( ${TARGET} ${SRCS} )
|
|
|
|
|
|
|
|
#| Link executable
|
|
|
|
target_link_libraries( ${TARGET} ${LIBS} )
|
|
|
|
|