-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cmake files to some of the modules
- Loading branch information
Showing
10 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project("qFlipper" C CXX) | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") | ||
|
||
include(FindCCache) | ||
include(VersionInfo) | ||
include(CompileOptions) | ||
include(GNUInstallDirs) | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE "Debug") | ||
endif() | ||
|
||
if(CMAKE_INSTALL_PREFIX) | ||
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/dist") | ||
message(STATUS "Install Prefix defaulted to: ${CMAKE_INSTALL_PREFIX}") | ||
else() | ||
message(STATUS "Install Prefix set to: ${CMAKE_INSTALL_PREFIX}") | ||
endif() | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
set(CMAKE_AUTOMOC ON) | ||
|
||
find_package(Qt6 COMPONENTS Core Core5Compat Network SerialPort REQUIRED CONFIG) | ||
|
||
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") | ||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET "libusb-1.0") | ||
pkg_check_modules(zlib REQUIRED IMPORTED_TARGET "zlib") | ||
endif() | ||
|
||
add_subdirectory("dfu") | ||
add_subdirectory("backend") | ||
add_subdirectory("plugins") | ||
add_subdirectory("cli") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
qt_add_library(backend STATIC) | ||
|
||
file(GLOB BACKEND_SOURCES | ||
"*.cpp" | ||
"flipperzero/*.cpp" | ||
"flipperzero/*/*.cpp" | ||
) | ||
|
||
target_sources(backend | ||
PRIVATE | ||
${BACKEND_SOURCES} | ||
) | ||
|
||
target_include_directories(backend | ||
PUBLIC | ||
"." | ||
) | ||
|
||
target_compile_definitions(backend | ||
PUBLIC | ||
"-DAPP_NAME=\"${CMAKE_PROJECT_NAME}\"" | ||
"-DAPP_VERSION=\"${GIT_TAG}\"" | ||
"-DAPP_COMMIT=\"%{GIT_COMMIT}\"" | ||
"-DAPP_TIMESTAMP=\"${GIT_TIMESTAMP}\"" | ||
) | ||
|
||
target_link_libraries(backend | ||
PUBLIC | ||
Qt::Network | ||
Qt::SerialPort | ||
PkgConfig::zlib | ||
|
||
PRIVATE | ||
dfu | ||
protobufinterface | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
set(CLI_TARGET "${CMAKE_PROJECT_NAME}_cli") | ||
|
||
qt_add_executable(${CLI_TARGET}) | ||
|
||
file(GLOB CLI_SOURCES | ||
"*.cpp" | ||
) | ||
|
||
target_sources(${CLI_TARGET} | ||
PRIVATE | ||
${CLI_SOURCES} | ||
) | ||
|
||
target_link_libraries(${CLI_TARGET} | ||
PRIVATE | ||
backend | ||
dfu | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if(MSVC) | ||
add_compile_options(/W4 /WX) | ||
else() | ||
add_compile_options(-Wall -Wextra) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
find_program(CCACHE_FOUND ccache) | ||
|
||
if(CCACHE_FOUND) | ||
message(STATUS "Found CCache: ${CCACHE_FOUND}") | ||
set_property(GLOBAL PROPERTY CXX_COMPILER_LAUNCHER ${CCACHE_FOUND}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
execute_process(COMMAND "git" | ||
"describe" | ||
"--tags" | ||
"--abbrev=0" | ||
WORKING_DIRECTORY | ||
"${CMAKE_SOURCE_DIR}" | ||
OUTPUT_VARIABLE | ||
GIT_TAG | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_QUIET | ||
) | ||
|
||
if(GIT_TAG STREQUAL "") | ||
set(GIT_TAG "unknown") | ||
endif() | ||
|
||
execute_process(COMMAND "git" | ||
"rev-parse" | ||
"--short=8" | ||
"HEAD" | ||
WORKING_DIRECTORY | ||
"${CMAKE_SOURCE_DIR}" | ||
OUTPUT_VARIABLE | ||
GIT_COMMIT | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_QUIET | ||
) | ||
|
||
if(GIT_COMMIT STREQUAL "") | ||
set(GIT_COMMIT "unknown") | ||
endif() | ||
|
||
execute_process(COMMAND "git" | ||
"log" | ||
"-1" | ||
"--pretty=format:%ct" | ||
WORKING_DIRECTORY | ||
"${CMAKE_SOURCE_DIR}" | ||
OUTPUT_VARIABLE | ||
GIT_TIMESTAMP | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_QUIET | ||
) | ||
|
||
if(GIT_TIMESTAMP STREQUAL "") | ||
set(GIT_TIMESTAMP "unknown") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
qt_add_library(dfu STATIC) | ||
|
||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows") | ||
set(USB_BACKEND "win32") | ||
set(USB_BACKEND_LIBS setupapi) | ||
else() | ||
set(USB_BACKEND "libusb") | ||
set(USB_BACKEND_LIBS PkgConfig::libusb) | ||
endif() | ||
|
||
file(GLOB DFU_SOURCES | ||
"*.cpp" | ||
"device/*.cpp" | ||
"device/*/*.cpp" | ||
"${USB_BACKEND}/*.cpp" | ||
) | ||
|
||
target_sources(dfu | ||
PRIVATE | ||
${DFU_SOURCES} | ||
) | ||
|
||
target_include_directories(dfu | ||
PUBLIC | ||
"." | ||
"./${USB_BACKEND}" | ||
) | ||
|
||
target_compile_definitions(dfu | ||
PUBLIC | ||
"-DUSB_BACKEND_$<UPPER_CASE:${USB_BACKEND}>" | ||
) | ||
|
||
target_link_libraries(dfu | ||
PUBLIC | ||
Qt6::Core | ||
Qt6::Core5Compat | ||
${USB_BACKEND_LIBS} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_subdirectory("protobufinterface") | ||
add_subdirectory("flipperproto0") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_library(protobufinterface INTERFACE) | ||
target_include_directories(protobufinterface INTERFACE .) |