Fixed sdps crash for some size flash.bin
[mfgtools.git] / libuuu / CMakeLists.txt
blobcccb7f594dc18254e6be000c974cee38b6950bd3
1 cmake_minimum_required(VERSION 3.4)
3 set(CMAKE_CXX_STANDARD 14)
4 set(CMAKE_CXX_STANDARD_REQUIRED ON)
5 set(CMAKE_SKIP_RPATH ON)
7 find_package(BZip2 REQUIRED)
8 find_package(PkgConfig REQUIRED)
9 pkg_check_modules(LIBUSB REQUIRED libusb-1.0>=1.0.16)
10 pkg_check_modules(LIBZSTD REQUIRED libzstd)
11 find_package(Threads)
13 if (STATIC)
14 set(OPENSSL_USE_STATIC_LIBS TRUE)
15 endif()
17 find_package(OpenSSL)
19 if(OPENSSL_FOUND)
20 set(UUUSSL "-DUUUSSL")
21 set(UUUOPENSLL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR})
22 endif()
24 include_directories(${LIBUSB_INCLUDE_DIRS} ${LIBZSTD_INCLUDE_DIRS} ${UUUOPENSLL_INCLUDE_DIR} include)
27 if (FORCE_OLD)
28 set(FORCE_OLDLIBUSB "-DFORCE_OLDLIBUSB")
29 endif()
31 set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wstrict-aliasing -Wextra ${UUUSSL} ${FORCE_OLDLIBUSB}")
32 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 ${UUUSSL} ${FORCE_OLDLIBUSB}")
34 set(SOURCES
35         error.cpp
36         buffer.cpp
37         cmd.cpp
38         config.cpp
39         notify.cpp
40         sdps.cpp
41         trans.cpp
42         usbhotplug.cpp
43         version.cpp
44         sdp.cpp
45         gitversion.h
46         fastboot.cpp
47         zip.cpp
48         fat.cpp
49         tar.cpp
50         rominfo.cpp
51         http.cpp
52         hidreport.cpp
53         sparse.cpp
56 set(generated_files_dir "${CMAKE_BINARY_DIR}/libuuu/gen")
57 set(gitversion_h "${generated_files_dir}/gitversion.h")
59 add_custom_command(
60         OUTPUT gitversion.h
61         PRE_BUILD
62         COMMAND mkdir -p ${generated_files_dir}
63         COMMAND sh -c 'cd ${CMAKE_CURRENT_SOURCE_DIR} && rm -f ${gitversion_h} && ./gen_ver.sh "${gitversion_h}.tmp" && mv -f "${gitversion_h}.tmp" "${gitversion_h}"'
66 include_directories(${generated_files_dir})
68 #add_library( uuc SHARED ${SOURCES} ))
69 add_library( uuc_s STATIC ${SOURCES} )