-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
executable file
·122 lines (97 loc) · 4.23 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
118
119
120
121
122
#
# Minimum version of cmake required
#
cmake_minimum_required(VERSION 3.5.0)
## Set default module path if not already set
if(NOT DEFINED CMAKE_MODULE_PATH)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
endif()
## Include common cmake modules
include(utils)
set(LCDLIB "lcdlib")
set(LCDLIB_COMPONENT "lib${LCDLIB}")
set(LCDLIB_TARGET "${LCDLIB}32")
set(SRC_DIR "src/lcdlib")
set(INC_DIR "include/lcdlib")
# The following default version values should be updated as appropriate for
# ABI breaks (update MAJOR and MINOR), and ABI/API additions (update MINOR).
# Until ABI stabilizes VERSION_MAJOR will be 0. This should be over-ridden
# by git tags (through "git describe") when they are present.
set(LCDLIB_LIB_VERSION_MAJOR 0)
set(LCDLIB_LIB_VERSION_MINOR 1)
################# Determine the library version #########################
## Setup the package version based on git tags.
set(LIB_SO_VERSION_STR
"${LCDLIB_LIB_VERSION_MAJOR}.${LCDLIB_LIB_VERSION_MINOR}.0")
get_version(${LIB_SO_VERSION_STR} "lcdlib")
# VERSION_* variables should be set by get_version
set(LIB_SO_VERSION_STR ${VERSION_STRING})
set(${LCDLIB}_VERSION_MAJOR "${VERSION_MAJOR}")
set(${LCDLIB}_VERSION_MINOR "${VERSION_MINOR}")
set(${LCDLIB}_VERSION_PATCH "${VERSION_PATCH}")
set(${LCDLIB}_VERSION_BUILD "${VERSION_BUILD}")
# Debian package specific variables
# Set a default value for the package version
set(VERSION_STRING "1.0.0")
get_version(${VERSION_STRING} "e")
# VERSION_* variables should be set by get_version
set(BUILD_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
project(${LCDLIB_TARGET})
# Create a configure file to get version info from within library
#configure_file(
# "${PROJECT_SOURCE_DIR}/${SRC_DIR}/${LCDLIB_TARGET}Config.in"
# "${PROJECT_SOURCE_DIR}/${INC_DIR}/${LCDLIB_TARGET}Config.h")
if (NOT DEFINED CPACK_PACKAGE_VENDOR)
set(CPACK_PACKAGE_VENDOR "AMD")
endif()
if (NOT DEFINED CPACK_PACKAGE_CONTACT)
set(CPACK_PACKAGE_CONTACT "Advanced Micro Devices Inc.")
endif()
if (NOT DEFINED CPACK_PACKAGE_DESCRIPTION_SUMMARY)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"GENOA™ LCD display Interface library")
endif()
set(CPACK_PACKAGE_FILE_NAME "lcdlib_lib32-${BUILD_VERSION_STRING}")
## Verbose output.
set(CMAKE_VERBOSE_MAKEFILE on)
## Compiler flags
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti -m64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -std=c++11 ")
# Use this instead of above for 32 bit
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
if ("${CMAKE_BUILD_TYPE}" STREQUAL Release)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -O0 -DDEBUG")
endif ()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
set(LCDLIB_SRC_LIST ${LCDLIB_SRC_LIST} "${SRC_DIR}/lcdlib_common.c")
#set(LCD_TOOL "lcdlib_tool")
#add_executable(${LCD_TOOL} "example/lcdlib_tool.c")
#target_link_libraries(${LCD_TOOL} ${LCDLIB_TARGET})
add_library(${LCDLIB_TARGET} SHARED ${LCDLIB_SRC_LIST} ${LCD_INC_LIST})
target_link_libraries(${LCDLIB_TARGET} pthread rt m i2c)
## Set the VERSION and SOVERSION values
set_property(TARGET ${LCDLIB_TARGET}
PROPERTY VERSION "${LIB_SO_VERSION_STR}")
set_property(TARGET ${LCDLIB_TARGET}
PROPERTY SOVERSION "${LCDLIB_LIB_VERSION_MAJOR}")
## If the library is a release, strip the target library
if ("${CMAKE_BUILD_TYPE}" STREQUAL Release)
add_custom_command(
TARGET ${LCDLIB_TARGET}
POST_BUILD COMMAND ${CMAKE_STRIP} lib${LCDLIB_TARGET}.so)
endif ()
## Define default variable and variables for the optional build target
## lcdlib_lib-dev
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
CACHE STRING "Location of LCDLIB source code.")
set(CMAKE_INSTALL_PREFIX "/opt/lcdlib"
CACHE STRING "Default installation directory.")
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/lcdlib"
CACHE STRING "Default packaging prefix.")
## Add the install directives for the runtime library.
install(TARGETS ${LCDLIB_TARGET}
LIBRARY DESTINATION ${LCDLIB}/lib COMPONENT ${LCDLIB_COMPONENT})
install(FILES ${SOURCE_DIR}/include/lcdlib/common.h
DESTINATION lcdlib/include/lcdlib)