Add submodules checkout
[mfgtools.git] / libuuu / CMakeLists.txt
blob8dcb0f63e9dd28848c8403095d05d47b4b21e035
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 set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wstrict-aliasing -Wextra ${UUUSSL}")
28 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 ${UUUSSL}")
30 set(SOURCES
31         error.cpp
32         buffer.cpp
33         cmd.cpp
34         config.cpp
35         notify.cpp
36         sdps.cpp
37         trans.cpp
38         usbhotplug.cpp
39         version.cpp
40         sdp.cpp
41         gitversion.h
42         fastboot.cpp
43         zip.cpp
44         fat.cpp
45         tar.cpp
46         rominfo.cpp
47         http.cpp
48         hidreport.cpp
49         sparse.cpp
52 set(generated_files_dir "${CMAKE_BINARY_DIR}/libuuu/gen")
53 set(gitversion_h "${generated_files_dir}/gitversion.h")
55 add_custom_command(
56         OUTPUT gitversion.h
57         PRE_BUILD
58         COMMAND mkdir -p ${generated_files_dir}
59         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}"'
62 include_directories(${generated_files_dir})
64 #add_library( uuc SHARED ${SOURCES} ))
65 add_library( uuc_s STATIC ${SOURCES} )