-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
117 lines (117 loc) · 3.74 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#
# CMAKE SETUP
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
#
# PROJECT INFO
#
PROJECT(libk8055)
SET(VERSION_MAJOR "0")
SET(VERSION_MINOR "5")
SET(VERSION_PATCH "1")
SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
ADD_DEFINITIONS(-DVERSION="${VERSION}")
#
# CONFIG OPTIONS
#
OPTION(WANT_DEBUG "build with debug information" OFF)
IF(WANT_DEBUG)
SET(CMAKE_BUILD_TYPE Debug)
ELSE()
SET(CMAKE_BUILD_TYPE Release)
ENDIF()
SET(CMAKE_C_FLAGS "-pedantic -std=gnu99")
SET(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
SET(CMAKE_C_FLAGS_DEBUG "-g -O2 -DDEBUG")
#
# COLOR MESSAGES
#
string( ASCII 27 _escape)
function(COLOR_MESSAGE TEXT)
if(CMAKE_COLOR_MAKEFILE)
MESSAGE(${TEXT})
else()
string(REGEX REPLACE "${_escape}.[0123456789;]*m" "" __TEXT ${TEXT})
MESSAGE(${__TEXT})
endif()
endfunction()
#
# HEADER LIBRARY FUNCTIONS
#
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists)
if(NOT WIN32)
FIND_PACKAGE(PkgConfig)
endif()
if(PKG_CONFIG_FOUND)
pkg_check_modules(LIBUSB libusb-1.0)
else()
MESSAGE(STATUS "Checking for module 'libusb'")
endif()
find_path(LIBUSB_INCLUDE_DIR
NAMES libusb.h
PATHS /usr/include/libusb-1.0 /usr/local/include/libusb-1.0
)
find_library(LIBUSB_LDFLAGS
NAMES libusb
)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIR)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES)
CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
CHECK_INCLUDE_FILES(stdio.h HAVE_STDIO_H)
CHECK_INCLUDE_FILES(assert.h HAVE_ASSERT_H)
CHECK_INCLUDE_FILES(math.h HAVE_MATH_H)
IF (LIBUSB_FOUND)
ADD_SUBDIRECTORY(libk8055)
ENDIF()
#
FIND_PACKAGE(wxWidgets COMPONENTS core base)
IF(wxWidgets_FOUND)
ADD_SUBDIRECTORY(k8055gui)
ENDIF()
#
FIND_PACKAGE(SWIG)
FIND_PACKAGE(PythonLibs)
FIND_PACKAGE(PythonInterp)
IF(SWIG_FOUND AND PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)
SET(BUILD_PYTHON TRUE)
ADD_SUBDIRECTORY(pyk8055)
ENDIF()
#
# BUILD SUMMARY
#
COLOR_MESSAGE("\n${_escape}[1;36mBuild Summary${_escape}[0m\n--------------------")
COLOR_MESSAGE("* ${_escape}[1;35mInstall dir${_escape}[0m : ${_escape}[1;32m${CMAKE_INSTALL_PREFIX}${_escape}[0m")
IF (LIBUSB_FOUND)
COLOR_MESSAGE("* ${_escape}[1;35mlibusb${_escape}[0m : ${_escape}[1;32mfound${_escape}[0m build libk8055")
ELSE()
COLOR_MESSAGE("* ${_escape}[1;35mlibusb${_escape}[0m : ${_escape}[1;31mmissing${_escape}[0m unable to build libk8055")
MESSAGE( FATAL_ERROR "Abort" )
ENDIF()
IF(wxWidgets_FOUND)
COLOR_MESSAGE("* ${_escape}[1;35mwxwidget${_escape}[0m : ${_escape}[1;32mfound${_escape}[0m build k8055gui")
ELSE()
COLOR_MESSAGE("* ${_escape}[1;35mwxwidget${_escape}[0m : ${_escape}[1;31mmissing${_escape}[0m unable to build k8055gui")
ENDIF()
IF(SWIG_FOUND)
COLOR_MESSAGE("* ${_escape}[1;35mSWIG${_escape}[0m : ${_escape}[1;32mfound${_escape}[0m")
ELSE()
COLOR_MESSAGE("* ${_escape}[1;35mSWIG${_escape}[0m : ${_escape}[1;31mmissing${_escape}[0m")
ENDIF()
IF(PYTHONLIBS_FOUND)
COLOR_MESSAGE("* ${_escape}[1;35mpython libs${_escape}[0m : ${_escape}[1;32mfound${_escape}[0m")
ELSE()
COLOR_MESSAGE("* ${_escape}[1;35mpython libs${_escape}[0m : ${_escape}[1;31mmissing${_escape}[0m")
ENDIF()
IF(PYTHONINTERP_FOUND)
COLOR_MESSAGE("* ${_escape}[1;35mpython interpreter${_escape}[0m : ${_escape}[1;32mfound${_escape}[0m")
ELSE()
COLOR_MESSAGE("* ${_escape}[1;35mpython interpreter${_escape}[0m : ${_escape}[1;31mmissing${_escape}[0m")
ENDIF()
IF(BUILD_PYTHON)
COLOR_MESSAGE("* build pyk8055")
ELSE()
COLOR_MESSAGE("* unable to build pyk8055")
ENDIF()
MESSAGE("")