-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from Wolkabout/rework/cmake-project-structure
Refactored everything to be structured more correctly
- Loading branch information
Showing
224 changed files
with
1,120 additions
and
1,118 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 |
---|---|---|
|
@@ -51,4 +51,4 @@ jobs: | |
uses: jidicula/[email protected] | ||
with: | ||
clang-format-version: 10 | ||
exclude-regex: "core/utilities/nlohmann/json.hpp" | ||
exclude-regex: "core/utility/nlohmann/json.hpp" |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,32 @@ | ||
# Include the util dependencies | ||
include(cmake/dependencies.cmake) | ||
|
||
# Create the library | ||
add_library(${AWS_LOG_UPLOADER_TARGET_NAME}) | ||
add_library(${NAMESPACE}::${AWS_LOG_UPLOADER_TARGET_NAME} ALIAS ${AWS_LOG_UPLOADER_TARGET_NAME}) | ||
|
||
# Link the libraries | ||
target_link_libraries(${AWS_LOG_UPLOADER_TARGET_NAME} ${UTIL_TARGET_NAME} aws-cpp-sdk-core aws-cpp-sdk-s3) | ||
|
||
# Set some target properties | ||
set_target_properties(${AWS_LOG_UPLOADER_TARGET_NAME} PROPERTIES OUTPUT_NAME "${NAMESPACE}${AWS_LOG_UPLOADER_TARGET_NAME}") | ||
set_target_properties(${AWS_LOG_UPLOADER_TARGET_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN") | ||
set_target_properties(${AWS_LOG_UPLOADER_TARGET_NAME} PROPERTIES VERSION ${PROJECT_VERSION}) | ||
set_target_properties(${AWS_LOG_UPLOADER_TARGET_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) | ||
|
||
# Add the sources | ||
target_sources(${AWS_LOG_UPLOADER_TARGET_NAME} PRIVATE core/log_uploader/AwsLogUploader.cpp) | ||
|
||
# Add the headers | ||
target_sources(${AWS_LOG_UPLOADER_TARGET_NAME} PRIVATE core/log_uploader/AwsLogUploader.h) | ||
|
||
# Add the private include directories | ||
target_include_directories(${AWS_LOG_UPLOADER_TARGET_NAME} | ||
PRIVATE | ||
${PROJECT_SOURCE_DIR}/${AWS_LOG_UPLOADER_SUBDIRECTORY_PATH}) | ||
|
||
# Add the public include directories | ||
target_include_directories(${AWS_LOG_UPLOADER_TARGET_NAME} | ||
PUBLIC | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/${AWS_LOG_UPLOADER_SUBDIRECTORY_PATH}> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) |
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,28 @@ | ||
# Include the CMake modules | ||
include(FetchContent) | ||
|
||
# Define the AWS version | ||
set(AWS_SDK_VERSION 1.8.173) | ||
|
||
# Set the flags for AWS based on the CMake build type | ||
if (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
option(ENABLE_UNITY_BUILD "If enabled, the SDK will be built using a single unified .cpp file for each service library. Reduces the size of static library binaries on Windows and Linux" OFF) | ||
option(MINIMIZE_SIZE "If enabled, the SDK will be built via a unity aggregation process that results in smaller static libraries; additionally, release binaries will favor size optimizations over speed" OFF) | ||
else (CMAKE_BUILD_TYPE STREQUAL "Release") | ||
option(ENABLE_UNITY_BUILD "If enabled, the SDK will be built using a single unified .cpp file for each service library. Reduces the size of static library binaries on Windows and Linux" ON) | ||
option(MINIMIZE_SIZE "If enabled, the SDK will be built via a unity aggregation process that results in smaller static libraries; additionally, release binaries will favor size optimizations over speed" ON) | ||
endif () | ||
|
||
# Set the options | ||
option(ENABLE_TESTING "Flag to enable/disable building unit and integration tests" OFF) | ||
set(BUILD_ONLY s3 CACHE STRING "A semi-colon delimited list of the projects to build") | ||
|
||
# Add AWS | ||
FetchContent_Declare( | ||
aws-sdk-cpp | ||
GIT_REPOSITORY https://github.com/aws/aws-sdk-cpp | ||
GIT_TAG ${AWS_SDK_VERSION} | ||
) | ||
|
||
# Make available | ||
FetchContent_MakeAvailable(aws-sdk-cpp) |
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
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
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,8 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@NAMESPACE@@[email protected]") | ||
|
||
check_required_components(@NAMESPACE@@PROJECT_NAME@) | ||
|
||
find_package(OpenSSL REQUIRED) | ||
find_package(Threads REQUIRED) |
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,22 @@ | ||
# Set the standard and flags | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic \ | ||
-pedantic-errors -Wcast-align \ | ||
-Wcast-qual -Wconversion \ | ||
-Wdisabled-optimization \ | ||
-Wfloat-equal -Wformat=2 \ | ||
-Werror=init-self \ | ||
-Werror=missing-field-initializers -Wmissing-format-attribute \ | ||
-Wmissing-include-dirs -Wmissing-noreturn \ | ||
-Werror=pointer-arith \ | ||
-Wno-packed -Wno-padded -Wredundant-decls \ | ||
-Werror=shadow -Werror=stack-protector \ | ||
-Wstrict-aliasing=2 -Wno-switch \ | ||
-Werror=unreachable-code -Wunused \ | ||
-Wvariadic-macros \ | ||
-Wwrite-strings -Werror=non-virtual-dtor -Werror=return-type") | ||
|
||
# Set the tests flags | ||
if (${BUILD_TESTS}) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -g") | ||
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,123 @@ | ||
# Import the required modules | ||
include(CMakePackageConfigHelpers) | ||
include(GNUInstallDirs) | ||
|
||
# Define the destination for public headers | ||
set(PUBLIC_HEADERS_DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${SOURCE_ROOT_FOLDER}) | ||
string(TOLOWER ${PUBLIC_HEADERS_DESTINATION} PUBLIC_HEADERS_DESTINATION) | ||
|
||
# Define the component names | ||
set(REL_COMPONENT RELEASE) | ||
set(DEV_COMPONENT DEV) | ||
|
||
# Define the targets lists | ||
set(TARGETS_LIST ${UTIL_TARGET_NAME} ${AWS_LOG_UPLOADER_TARGET_NAME} ${CONNECTIVITY_TARGET_NAME}) | ||
set(TARGETS_DIRECTORIES ${UTIL_SUBDIRECTORY_PATH} ${AWS_LOG_UPLOADER_SUBDIRECTORY_PATH} ${CONNECTIVITY_SUBDIRECTORY_PATH}) | ||
|
||
# Go through the targets | ||
list(LENGTH TARGETS_LIST TARGETS_LENGTH) | ||
math(EXPR TARGETS_LENGTH ${TARGETS_LENGTH}-1) | ||
foreach (INDEX RANGE ${TARGETS_LENGTH}) | ||
list(GET TARGETS_LIST ${INDEX} TARGET) | ||
list(GET TARGETS_DIRECTORIES ${INDEX} TARGET_DIRECTORY) | ||
|
||
if (NOT TARGET "${TARGET}") | ||
continue() | ||
endif () | ||
|
||
# Create the install rule for the main target | ||
install(TARGETS ${TARGET} | ||
EXPORT ${PROJECT_NAME}Targets | ||
LIBRARY | ||
COMPONENT ${REL_COMPONENT} | ||
NAMELINK_SKIP | ||
PUBLIC_HEADER | ||
DESTINATION ${PUBLIC_HEADERS_DESTINATION} | ||
INCLUDES DESTINATION ${PUBLIC_HEADERS_DESTINATION}) | ||
|
||
# Install all the header files | ||
get_target_property(HEADER_FILES ${TARGET} SOURCES) | ||
list(FILTER HEADER_FILES INCLUDE REGEX .*.h$) | ||
list(TRANSFORM HEADER_FILES PREPEND ${TARGET_DIRECTORY}/) | ||
string(LENGTH ${TARGET_DIRECTORY}/${SOURCE_ROOT_FOLDER}/ SOURCE_ROOT_FOLDER_LENGTH) | ||
foreach (HEADER_FILE ${HEADER_FILES}) | ||
string(FIND ${HEADER_FILE} / SLASH_POSITION REVERSE) | ||
math(EXPR SLASH_POSITION ${SLASH_POSITION}+1) | ||
string(SUBSTRING ${HEADER_FILE} 0 ${SLASH_POSITION} HEADER_SUBDIRECTORY) | ||
string(SUBSTRING ${HEADER_SUBDIRECTORY} ${SOURCE_ROOT_FOLDER_LENGTH} -1 HEADER_SUBDIRECTORY) | ||
install(FILES ${HEADER_FILE} | ||
COMPONENT ${DEV_COMPONENT} | ||
DESTINATION ${PUBLIC_HEADERS_DESTINATION}/${HEADER_SUBDIRECTORY}) | ||
endforeach () | ||
|
||
# Add the util extra targets | ||
if (${TARGET} STREQUAL ${UTIL_TARGET_NAME}) | ||
install(TARGETS spdlog | ||
EXPORT ${PROJECT_NAME}Targets | ||
LIBRARY | ||
COMPONENT ${REL_COMPONENT} | ||
NAMELINK_SKIP | ||
PUBLIC_HEADER | ||
DESTINATION ${PUBLIC_HEADERS_DESTINATION} | ||
INCLUDES DESTINATION ${PUBLIC_HEADERS_DESTINATION}) | ||
endif () | ||
|
||
# Add the connectivity extra targets | ||
if (${TARGET} STREQUAL ${CONNECTIVITY_TARGET_NAME}) | ||
# Install libpaho files | ||
install(DIRECTORY ${CMAKE_PREFIX_PATH}/lib/ | ||
COMPONENT ${REL_COMPONENT} | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
FILES_MATCHING PATTERN REGEX "libpaho(.*).so") | ||
install(DIRECTORY ${CMAKE_PREFIX_PATH}/lib/ | ||
COMPONENT ${REL_COMPONENT} | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
FILES_MATCHING PATTERN REGEX "(.*)[Pp]aho(.*).cmake") | ||
install(DIRECTORY ${CMAKE_PREFIX_PATH}/include/ | ||
COMPONENT ${DEV_COMPONENT} | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
# Install the json schema validator target | ||
install(TARGETS nlohmann_json nlohmann_json_schema_validator | ||
EXPORT ${PROJECT_NAME}Targets | ||
LIBRARY | ||
COMPONENT ${REL_COMPONENT} | ||
NAMELINK_SKIP | ||
PUBLIC_HEADER | ||
DESTINATION ${PUBLIC_HEADERS_DESTINATION} | ||
INCLUDES DESTINATION ${PUBLIC_HEADERS_DESTINATION}) | ||
endif () | ||
|
||
endforeach () | ||
|
||
# Create the config file | ||
configure_package_config_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${NAMESPACE}${PROJECT_NAME}Config.cmake" | ||
INSTALL_DESTINATION cmake) | ||
|
||
# Generate the version file | ||
write_basic_package_version_file( | ||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${NAMESPACE}${PROJECT_NAME}ConfigVersion.cmake" | ||
VERSION "${PROJECT_VERSION}" | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
|
||
# Expose the Targets.cmake in the CURRENT_BINARY_DIR | ||
export(EXPORT ${PROJECT_NAME}Targets | ||
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${NAMESPACE}${PROJECT_NAME}Targets.cmake" | ||
NAMESPACE ${NAMESPACE}::) | ||
|
||
# Install the CMake files | ||
install(FILES | ||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${NAMESPACE}${PROJECT_NAME}Config.cmake" | ||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${NAMESPACE}${PROJECT_NAME}ConfigVersion.cmake" | ||
COMPONENT ${DEV_COMPONENT} | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}${PROJECT_NAME}") | ||
install(EXPORT | ||
${PROJECT_NAME}Targets | ||
FILE | ||
"${NAMESPACE}${PROJECT_NAME}Targets.cmake" | ||
NAMESPACE ${NAMESPACE}:: | ||
COMPONENT ${DEV_COMPONENT} | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}${PROJECT_NAME}") |
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,16 @@ | ||
# Configure the paths for output | ||
if (NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
endif () | ||
|
||
if (NOT DEFINED CMAKE_LIBRARY_INCLUDE_DIRECTORY) | ||
set(CMAKE_LIBRARY_INCLUDE_DIRECTORY ${CMAKE_BINARY_DIR}/include) | ||
endif () | ||
|
||
if (NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
endif () | ||
|
||
if (NOT DEFINED CMAKE_PREFIX_PATH) | ||
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/build) | ||
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,90 @@ | ||
# Options for Poco | ||
if (${BUILD_POCO}) | ||
|
||
# The Utility bundle | ||
OPTION(POCO_BUILD_UTIL "" ON) | ||
if (${POCO_BUILD_UTIL}) | ||
OPTION(POCO_ENABLE_UTIL "" ON) | ||
endif () | ||
|
||
# The Network bundle | ||
OPTION(POCO_BUILD_NET "" OFF) | ||
if (${POCO_BUILD_NET}) | ||
OPTION(POCO_ENABLE_NET "" ON) | ||
OPTION(POCO_ENABLE_NETSSL "" ON) | ||
OPTION(POCO_ENABLE_CRYPTO "" ON) | ||
if (WIN32) | ||
OPTION(POCO_ENABLE_NETSSL_WIN "" OFF) | ||
else () | ||
OPTION(POCO_ENABLE_NETSSL_WIN "" ON) | ||
endif () | ||
endif () | ||
|
||
# The Data bundle | ||
OPTION(POCO_BUILD_DATA "" OFF) | ||
if (${POCO_BUILD_DATA}) | ||
OPTION(POCO_ENABLE_DATA "" ON) | ||
OPTION(POCO_ENABLE_DATA_SQLITE "" ON) | ||
OPTION(POCO_ENABLE_DATA_MYSQL "" OFF) | ||
OPTION(POCO_ENABLE_DATA_ODBC "" ON) | ||
endif () | ||
|
||
# The Encodings bundle | ||
OPTION(POCO_BUILD_ENCODINGS "" OFF) | ||
if (${POCO_BUILD_ENCODINGS}) | ||
OPTION(POCO_ENABLE_ENCODINGS "" ON) | ||
OPTION(POCO_ENABLE_ENCODINGS_COMPILER "" ON) | ||
OPTION(POCO_ENABLE_XML "" ON) | ||
OPTION(POCO_ENABLE_JSON "" ON) | ||
endif () | ||
|
||
# The MongoDB bundle | ||
OPTION(POCO_BUILD_MONGODB "" OFF) | ||
if (${POCO_BUILD_MONGODB}) | ||
OPTION(POCO_ENABLE_MONGODB "" ON) | ||
endif () | ||
|
||
# The Redis bundle | ||
OPTION(POCO_BUILD_REDIS "" OFF) | ||
if (${POCO_BUILD_REDIS}) | ||
OPTION(POCO_ENABLE_REDIS "" ON) | ||
endif () | ||
|
||
# The ZIP bundle | ||
OPTION(POCO_BUILD_ZIP "" OFF) | ||
if (${POCO_BUILD_ZIP}) | ||
OPTION(POCO_ENABLE_SEVENZIP "" ON) | ||
OPTION(POCO_ENABLE_ZIP "" ON) | ||
endif () | ||
|
||
# The PageCompiler bundle | ||
OPTION(POCO_BUILD_PAGECOMPILER "" OFF) | ||
if (${POCO_BUILD_PAGECOMPILER}) | ||
OPTION(POCO_ENABLE_PAGECOMPILER "" ON) | ||
OPTION(POCO_ENABLE_PAGECOMPILER_FILE2PAGE "" ON) | ||
endif () | ||
|
||
# The PDF bundle | ||
OPTION(POCO_BUILD_PDF "" OFF) | ||
if (${POCO_BUILD_PDF}) | ||
OPTION(POCO_ENABLE_PDF "" ON) | ||
endif () | ||
|
||
# The Apache connection bundle | ||
OPTION(POCO_BUILD_APACHECONNECTOR "" OFF) | ||
if (${POCO_BUILD_APACHECONNECTOR}) | ||
OPTION(POCO_ENABLE_APACHECONNECTOR "" ON) | ||
endif () | ||
|
||
# The CppParser bundle | ||
OPTION(POCO_BUILD_CPPPARSER "" OFF) | ||
if (${POCO_BUILD_CPPPARSER}) | ||
OPTION(POCO_ENABLE_CPPPARSER "" ON) | ||
endif () | ||
|
||
# The PocoDoc bundle | ||
OPTION(POCO_BUILD_POCODOC "" OFF) | ||
if (${POCO_BUILD_POCODOC}) | ||
OPTION(POCO_ENABLE_POCODOC "" ON) | ||
endif () | ||
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
Oops, something went wrong.