2022-04-03 22:55:22 +01:00
|
|
|
cmake_minimum_required(VERSION 3.22)
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2023-09-26 14:29:25 +01:00
|
|
|
project(Bloom LANGUAGES CXX VERSION 1.0.0)
|
2022-04-02 17:12:40 +01:00
|
|
|
set(CMAKE_PROJECT_HOMEPAGE_URL "https://bloom.oscillate.io")
|
2023-12-12 23:19:21 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
|
|
|
|
|
|
set(AUTOGEN_BUILD_DIR ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}_autogen/)
|
2022-04-02 17:12:40 +01:00
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
set(CMAKE_VERBOSE_MAKEFILE off)
|
|
|
|
|
|
|
|
|
|
set(ENABLE_SANITIZERS off)
|
|
|
|
|
|
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
2023-01-15 21:20:09 +00:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2023-05-10 19:53:39 +01:00
|
|
|
option(EXCLUDE_INSIGHT "Exclude the Insight component from this build" OFF)
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2023-09-28 22:36:02 +01:00
|
|
|
set(CMAKE_SKIP_RPATH true)
|
2023-05-24 23:15:47 +01:00
|
|
|
set(COMPILED_RESOURCES_BUILD_DIR ${CMAKE_BINARY_DIR}/compiled_resources/)
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-01-22 16:46:41 +00:00
|
|
|
add_compile_definitions(BLOOM_VERSION="${CMAKE_PROJECT_VERSION}")
|
|
|
|
|
|
2022-04-02 17:13:17 +01:00
|
|
|
if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
2022-01-02 21:23:50 +00:00
|
|
|
add_compile_definitions(BLOOM_DEBUG_BUILD)
|
|
|
|
|
|
|
|
|
|
# BLOOM_COMPILED_RESOURCES_PATH_OVERRIDE can be used to override the file path used for compiled resources.
|
|
|
|
|
# We override this path in debug builds to avoid using compiled resources. This makes debugging and small tweaks
|
|
|
|
|
# a lot easier, as it removes the need to recompile for each tweak.
|
|
|
|
|
# CAUTION: Although convenient, this does add a limitation; the debug build can only be run on the same machine
|
|
|
|
|
# that compiled it. Or a machine that has the Bloom source located in the same place.
|
2022-12-26 21:47:09 +00:00
|
|
|
# See Services::PathService::compiledResourcesPath() for more.
|
2022-01-02 21:23:50 +00:00
|
|
|
add_compile_definitions(BLOOM_COMPILED_RESOURCES_PATH_OVERRIDE="${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
|
|
|
|
|
|
# BLOOM_HOME_DOMAIN_NAME_OVERRIDE can be used to override the domain name used in URLs to the Bloom website.
|
|
|
|
|
# I (Nav) use this in debug builds, so I can test local changes that involve the Bloom website as well as Bloom
|
|
|
|
|
# itself. Other users can comment out this override if they don't have a copy of the Bloom website running on their
|
2022-12-26 21:47:09 +00:00
|
|
|
# local machine. See Services::PathService::homeDomainName() for more.
|
2022-01-02 21:23:50 +00:00
|
|
|
add_compile_definitions(BLOOM_HOME_DOMAIN_NAME_OVERRIDE="http://bloom.local")
|
|
|
|
|
|
|
|
|
|
# CMAKE_BUILD_RPATH needs to point to the local Qt installation, to use Gammaray during development.
|
|
|
|
|
# This is because the distributed Qt binaries may not be compatible with the local installation of Gammaray
|
2022-04-29 22:12:47 +01:00
|
|
|
# If you don't intend to use Gammaray, you can comment this out
|
2023-09-28 22:36:02 +01:00
|
|
|
set(CMAKE_SKIP_RPATH false)
|
|
|
|
|
set(CMAKE_SKIP_BUILD_RPATH false)
|
2022-07-13 20:37:35 +01:00
|
|
|
set(CMAKE_BUILD_RPATH /opt/Qt/6.2.4/gcc_64/lib/)
|
2022-01-02 21:23:50 +00:00
|
|
|
endif()
|
|
|
|
|
|
2022-04-29 22:12:47 +01:00
|
|
|
add_executable(Bloom)
|
2023-05-10 19:53:39 +01:00
|
|
|
set_target_properties(Bloom PROPERTIES OUTPUT_NAME bloom)
|
|
|
|
|
|
|
|
|
|
find_package(yaml-cpp 0.7.0 REQUIRED)
|
|
|
|
|
find_package(Qt6Core REQUIRED)
|
|
|
|
|
find_package(Qt6Xml REQUIRED)
|
2023-06-03 13:10:32 +01:00
|
|
|
find_package(Qt6Network REQUIRED)
|
2023-05-10 19:53:39 +01:00
|
|
|
|
|
|
|
|
if (NOT ${EXCLUDE_INSIGHT})
|
|
|
|
|
find_package(Qt6Widgets REQUIRED)
|
|
|
|
|
find_package(Qt6Gui REQUIRED)
|
|
|
|
|
find_package(Qt6Widgets REQUIRED)
|
|
|
|
|
find_package(Qt6Xml REQUIRED)
|
|
|
|
|
find_package(Qt6Svg REQUIRED)
|
|
|
|
|
find_package(Qt6UiTools REQUIRED)
|
|
|
|
|
find_package(Qt6SvgWidgets REQUIRED)
|
|
|
|
|
|
|
|
|
|
target_link_libraries(Bloom Qt6::Gui)
|
|
|
|
|
target_link_libraries(Bloom Qt6::UiTools)
|
|
|
|
|
target_link_libraries(Bloom Qt6::Widgets)
|
|
|
|
|
target_link_libraries(Bloom Qt6::Xml)
|
|
|
|
|
target_link_libraries(Bloom Qt6::Svg)
|
|
|
|
|
target_link_libraries(Bloom Qt6::SvgWidgets)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
target_link_libraries(Bloom -lstdc++fs)
|
|
|
|
|
target_link_libraries(Bloom -lpthread)
|
|
|
|
|
target_link_libraries(Bloom -lusb-1.0)
|
|
|
|
|
target_link_libraries(Bloom -lhidapi-libusb)
|
|
|
|
|
target_link_libraries(Bloom -lprocps)
|
|
|
|
|
target_link_libraries(Bloom ${YAML_CPP_LIBRARIES})
|
|
|
|
|
target_link_libraries(Bloom Qt6::Core)
|
|
|
|
|
target_link_libraries(Bloom Qt6::Xml)
|
2023-06-03 13:10:32 +01:00
|
|
|
target_link_libraries(Bloom Qt6::Network)
|
2022-04-29 22:12:47 +01:00
|
|
|
|
2022-07-13 20:39:44 +01:00
|
|
|
qt_add_resources(
|
|
|
|
|
Bloom
|
|
|
|
|
"ApplicationResources"
|
|
|
|
|
PREFIX
|
|
|
|
|
"/compiled"
|
|
|
|
|
FILES
|
2022-07-23 15:42:16 +01:00
|
|
|
"./resources/bloom.template.yaml"
|
2022-07-13 20:39:44 +01:00
|
|
|
"./resources/help.txt"
|
|
|
|
|
)
|
|
|
|
|
|
2022-04-03 21:36:43 +01:00
|
|
|
add_subdirectory(src)
|
2021-04-04 21:04:12 +01:00
|
|
|
target_include_directories(Bloom PUBLIC ./)
|
2022-07-23 02:28:41 +01:00
|
|
|
target_include_directories(Bloom PUBLIC ${YAML_CPP_INCLUDE_DIR})
|
2021-12-30 13:58:46 +00:00
|
|
|
|
2022-04-02 17:13:17 +01:00
|
|
|
if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
2021-12-30 13:58:46 +00:00
|
|
|
# When Qt isn't playing nice, it's very useful to have access to the Qt source code, to step through.
|
|
|
|
|
# The QT source directory is specified as an include path just so that CLion can navigate to the Qt implementation
|
|
|
|
|
# files, during debugging. No QT headers are actually included via this method. Feel free to comment this out if
|
|
|
|
|
# you don't possess the Qt source code on your machine. You may need to invalidate CMake cache.
|
2023-05-24 19:37:59 +01:00
|
|
|
# target_include_directories(Bloom PUBLIC /opt/Qt/6.2.4/Src)
|
2021-12-30 13:58:46 +00:00
|
|
|
endif()
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2023-05-10 19:53:39 +01:00
|
|
|
target_compile_definitions(
|
|
|
|
|
Bloom
|
|
|
|
|
PUBLIC $<$<BOOL:${EXCLUDE_INSIGHT}>:EXCLUDE_INSIGHT>
|
|
|
|
|
)
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
target_compile_options(
|
|
|
|
|
Bloom
|
|
|
|
|
PUBLIC -std=c++2a
|
|
|
|
|
PUBLIC -pedantic
|
|
|
|
|
PUBLIC -Wconversion
|
2021-10-21 19:25:58 +01:00
|
|
|
PUBLIC -Wpessimizing-move
|
|
|
|
|
PUBLIC -Wredundant-move
|
2022-05-03 20:01:32 +01:00
|
|
|
PUBLIC -Wsuggest-override
|
2023-08-19 21:53:00 +01:00
|
|
|
PUBLIC -Wreorder
|
2021-04-04 21:04:12 +01:00
|
|
|
PUBLIC -fno-sized-deallocation
|
|
|
|
|
PUBLIC $<$<CONFIG:DEBUG>:-g>
|
2022-06-22 22:23:56 +01:00
|
|
|
# PUBLIC $<$<CONFIG:DEBUG>:-O0>
|
2023-02-20 21:54:55 +00:00
|
|
|
PUBLIC $<$<CONFIG:DEBUG>:-Ofast>
|
2021-08-20 22:52:39 +01:00
|
|
|
PUBLIC $<$<CONFIG:RELEASE>:-Ofast>
|
2021-04-04 21:04:12 +01:00
|
|
|
PUBLIC $<$<CONFIG:DEBUG>:-fno-inline>
|
|
|
|
|
PUBLIC $<$<CONFIG:DEBUG>:-fkeep-static-functions>
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (${ENABLE_SANITIZERS})
|
|
|
|
|
message(WARNING "Sanitizers have been enabled")
|
|
|
|
|
|
|
|
|
|
# Some sanitizers are not compatible with each other.
|
|
|
|
|
target_compile_options(
|
|
|
|
|
Bloom
|
|
|
|
|
PUBLIC "-fsanitize=address"
|
|
|
|
|
#PUBLIC "-fsanitize=undefined"
|
2022-04-03 22:55:22 +01:00
|
|
|
# PUBLIC "-fsanitize=thread"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=address>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=undefined>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=integer-divide-by-zero>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=unreachable>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=vla-bound>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=null>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=return>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=signed-integer-overflow>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=bounds>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=alignment>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=object-size>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=float-divide-by-zero>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=float-cast-overflow>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=nonnull-attribute>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=returns-nonnull-attribute>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=bool>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=enum>"
|
|
|
|
|
# PUBLIC "$<$<BOOL:${ENABLE_SANITIZERS}>:-fsanitize=vptr>"
|
2021-04-04 21:04:12 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_link_libraries(
|
|
|
|
|
Bloom
|
|
|
|
|
"-fsanitize=address"
|
2022-04-03 22:55:22 +01:00
|
|
|
# "-fsanitize=undefined"
|
|
|
|
|
# "-fsanitize=thread"
|
2021-04-04 21:04:12 +01:00
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
|
2023-12-12 23:19:21 +00:00
|
|
|
# Validate TDF files
|
|
|
|
|
add_custom_command(
|
|
|
|
|
OUTPUT ${CMAKE_BINARY_DIR}/tdf_validation_timestamp.txt
|
|
|
|
|
COMMAND echo 'Validating target description files'
|
|
|
|
|
COMMAND php
|
|
|
|
|
ARGS
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/build/scripts/ValidateTargetDescriptionFiles.php
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/Targets/TargetDescriptionFiles/
|
|
|
|
|
COMMAND date > ${CMAKE_BINARY_DIR}/tdf_validation_timestamp.txt
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Copy TDF files to build directory and generate TDF mapping
|
|
|
|
|
set(GENERATED_TDF_MAPPING_PATH "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}_autogen/GeneratedMapping.hpp")
|
|
|
|
|
|
|
|
|
|
target_sources(
|
|
|
|
|
Bloom
|
|
|
|
|
PRIVATE
|
|
|
|
|
${GENERATED_TDF_MAPPING_PATH}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_compile_definitions(
|
|
|
|
|
Bloom
|
|
|
|
|
PUBLIC GENERATED_TDF_MAPPING_PATH="${GENERATED_TDF_MAPPING_PATH}"
|
|
|
|
|
)
|
|
|
|
|
|
2022-04-03 22:55:22 +01:00
|
|
|
add_custom_command(
|
|
|
|
|
OUTPUT
|
2023-12-12 23:19:21 +00:00
|
|
|
${GENERATED_TDF_MAPPING_PATH}
|
|
|
|
|
${CMAKE_BINARY_DIR}/resources/TargetDescriptionFiles/
|
2022-04-03 22:55:22 +01:00
|
|
|
DEPENDS
|
2023-12-12 23:19:21 +00:00
|
|
|
${CMAKE_BINARY_DIR}/tdf_validation_timestamp.txt
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/build/scripts/GenerateTargetDescriptionFileMapping.php
|
|
|
|
|
COMMAND echo 'Processing target description files'
|
|
|
|
|
COMMAND php
|
|
|
|
|
ARGS
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/build/scripts/GenerateTargetDescriptionFileMapping.php
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/Targets/TargetDescriptionFiles/
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/Targets/TargetDescription/GeneratedMapping.hpp.in
|
|
|
|
|
${GENERATED_TDF_MAPPING_PATH}
|
|
|
|
|
${CMAKE_BINARY_DIR}/resources/TargetDescriptionFiles/
|
2022-04-03 22:55:22 +01:00
|
|
|
)
|
|
|
|
|
|
2022-05-08 19:57:20 +01:00
|
|
|
include(./cmake/Installing.cmake)
|
|
|
|
|
include(./cmake/Packaging.cmake)
|