summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: e4f315cc142d7f664b7c876df7cf138d9881355e (plain)
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
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(lthor C)

SET(LIBTHOR_SRCS
	libthor/thor_acm.c
	libthor/thor.c
	libthor/thor_raw_file.c
	libthor/thor_tar.c
	libthor/thor_transport.c
	libthor/thor_usb.c
	libthor/thor_net.c
)

SET(SRCS
	lthor.c
)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/libthor)

SET(VENDOR "samsung")
SET(PACKAGE ${PROJECT_NAME})
SET(PKGNAME "${PACKAGE}")
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(BINDIR "${PREFIX}/bin")

SET(PACKAGE_VERSION "2.0")


IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
	SET(CMAKE_BUILD_TYPE "Release")
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")


INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED 
	libarchive
	libusb-1.0>=1.0.17
)

FOREACH(flag ${pkgs_CFLAGS})
	SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_C_FLAGS_RELEASE "-O2")


ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
ADD_DEFINITIONS("-DPACKAGE_VERSION=\"${PACKAGE_VERSION}\"")
ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")

#SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
IF(APPLE)
	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
	INCLUDE_DIRECTORIES("/usr/include/machine")
ELSE()
	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
ENDIF()

ADD_LIBRARY(libthor ${LIBTHOR_SRCS})

ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})

TARGET_LINK_LIBRARIES(${PROJECT_NAME} libthor rt ${pkgs_LDFLAGS})


INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
INSTALL(FILES 99-lthor.rules
        DESTINATION "/etc/udev/rules.d"
        COMPONENT "udev")