From dc142e241fa83727b3406461f4e40f2546644829 Mon Sep 17 00:00:00 2001 From: "Artiom N." Date: Mon, 18 Nov 2024 13:04:38 +0300 Subject: [PATCH 1/9] Dependencies loading fix: #18 --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0df2654..171f7a70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,8 +223,10 @@ if (MSVC) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) endif() -set(CPM_SOURCE_CACHE_DEFAULT "${CMAKE_CURRENT_SOURCE_DIR}/third-party" CACHE STRING "" FORCE) -set(CPM_SOURCE_CACHE "${CMAKE_CURRENT_SOURCE_DIR}/third-party" CACHE STRING "" FORCE) +if (KNP_BUILD_AUTONOMOUS) + set(CPM_SOURCE_CACHE_DEFAULT "${CMAKE_CURRENT_SOURCE_DIR}/third-party" CACHE STRING "") + set(CPM_SOURCE_CACHE "${CMAKE_CURRENT_SOURCE_DIR}/third-party" CACHE STRING "") +endif() # Make cache variables for installation destinations. include(GNUInstallDirs) From cf036217dd126108bf14769742b0459de014f5e8 Mon Sep 17 00:00:00 2001 From: "Artiom N." Date: Mon, 18 Nov 2024 13:31:55 +0300 Subject: [PATCH 2/9] Build fix: #18 --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 171f7a70..d363ce3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -328,8 +328,11 @@ if (KNP_BUILD_TESTS) "INSTALL_GTEST OFF") endif() -file(GLOB THIRD_PARTY_INCLUDES LIST_DIRECTORIES true "${CPM_SOURCE_CACHE}/**/include") -include_directories("${CPM_SOURCE_CACHE}" ${THIRD_PARTY_INCLUDES}) + +if (CPM_SOURCE_CACHE) + file(GLOB THIRD_PARTY_INCLUDES LIST_DIRECTORIES true "${CPM_SOURCE_CACHE}/**/include") + include_directories("${CPM_SOURCE_CACHE}" ${THIRD_PARTY_INCLUDES}) +endif() if (MSVC) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS FALSE) From de156884562c945f78df53609e117279291ecb9d Mon Sep 17 00:00:00 2001 From: "Artiom N." Date: Tue, 19 Nov 2024 13:40:10 +0300 Subject: [PATCH 3/9] CSV2 add do dependencies: #18 --- CMakeLists.txt | 8 ++++---- knp/base-framework/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d363ce3a..30efd1b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,11 +114,11 @@ endif() # Kaspersky Neuromorphic Platform build option set. # -# Build is not from source directory, it is possible to specify it via add_subdirectory(). -if (NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(KNP_BUILD_AUTONOMOUS FALSE) -else() +if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(KNP_BUILD_AUTONOMOUS TRUE) +else() + # Build is not from source directory, it is possible to specify it via add_subdirectory(). + set(KNP_BUILD_AUTONOMOUS FALSE) endif() if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") diff --git a/knp/base-framework/CMakeLists.txt b/knp/base-framework/CMakeLists.txt index 82d0f33a..e4f52f8c 100644 --- a/knp/base-framework/CMakeLists.txt +++ b/knp/base-framework/CMakeLists.txt @@ -75,7 +75,7 @@ knp_add_library("${PROJECT_NAME}-core" ${${PROJECT_NAME}_headers} ALIAS KNP::BaseFramework::Core LINK_PRIVATE - spdlog::spdlog Boost::headers Boost::filesystem #[[RapidJSON]] HighFive ${HDF5_LIB} + spdlog::spdlog Boost::headers Boost::filesystem #[[RapidJSON]] HighFive ${HDF5_LIB} csv2 # Hack to build with CLang. ${ADD_LIBS} LINK_PUBLIC From d6d22b54902acd275ee01d89c02cbaba811baada Mon Sep 17 00:00:00 2001 From: "Artiom N." Date: Wed, 20 Nov 2024 00:50:32 +0300 Subject: [PATCH 4/9] Devices library was maked static: #18 --- .../cpu-multi-threaded-backend/CMakeLists.txt | 152 ++++++++-------- .../CMakeLists.txt | 150 +++++++-------- knp/devices-library/CMakeLists.txt | 172 ++++++++---------- 3 files changed, 231 insertions(+), 243 deletions(-) diff --git a/knp/backends/cpu/cpu-multi-threaded-backend/CMakeLists.txt b/knp/backends/cpu/cpu-multi-threaded-backend/CMakeLists.txt index 67d9c6be..481e1cfd 100644 --- a/knp/backends/cpu/cpu-multi-threaded-backend/CMakeLists.txt +++ b/knp/backends/cpu/cpu-multi-threaded-backend/CMakeLists.txt @@ -14,79 +14,79 @@ See the License for the specific language governing permissions and limitations under the License. ]] -cmake_minimum_required(VERSION 3.25) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -# Required for the linters. -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30") - # Suppress Boost warning. - cmake_policy(SET CMP0167 OLD) -endif() - -project(knp-cpu-multi-threaded-backend VERSION "${KNP_VERSION}" LANGUAGES C CXX - DESCRIPTION "CPU multi-threaded backend" - HOMEPAGE_URL "https://neuro.kaspersky.ru/neyromorfnye-tekhnologii/") - -set(${PROJECT_NAME}_PUBLIC_INCLUDE_DIR "knp/backends/cpu-multi-threaded") - -include(GNUInstallDirs) -include(clang-tidy) -include(knp-functions) - -find_package(Boost ${KNP_BOOST_MIN_VERSION} COMPONENTS system REQUIRED) - -file(GLOB_RECURSE ${PROJECT_NAME}_headers include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}/*.h) -source_group(source REGULAR_EXPRESSION "impl/.*") -source_group(headers REGULAR_EXPRESSION "include/.*") - -knp_add_library("${PROJECT_NAME}" - BOTH - impl/backend.cpp - impl/get_network.cpp - ${${PROJECT_NAME}_headers} - ALIAS KNP::Backends::CPUMultiThreaded - LINK_PRIVATE - Boost::headers spdlog::spdlog - KNP::Backends::CPU::Library KNP::Backends::CPU::ThreadPool - LINK_PUBLIC - KNP::Core KNP::Devices::CPUStatic -) - -set_target_properties( - "${PROJECT_NAME}" - PROPERTIES - VERSION "${CMAKE_PROJECT_VERSION}" - SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}") - -if (KNP_INSTALL) - knp_get_component_name("${PROJECT_NAME}" COMPONENT_NAME) - - install(TARGETS "${PROJECT_NAME}" - EXPORT "${PROJECT_NAME}" - COMPONENT "${COMPONENT_NAME}" - LIBRARY) - - install(TARGETS "${PROJECT_NAME}_static" - EXPORT "${PROJECT_NAME}_static" - COMPONENT "${COMPONENT_NAME}-dev" - ARCHIVE) - - install(DIRECTORY "include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}" - COMPONENT "${COMPONENT_NAME}-dev" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/knp/backends" - FILES_MATCHING PATTERN "*.h") - - knp_packaging_set_parameters("${COMPONENT_NAME}" "${PROJECT_NAME}" - DESCRIPTION "${PROJECT_DESCRIPTION}" - DEPENDS "libboost-all (= ${Boost_VERSION})" "libzmq" - PROVIDES "knp-backend") - - knp_packaging_set_parameters("${COMPONENT_NAME}-dev" "${PROJECT_NAME}" - DESCRIPTION "${PROJECT_DESCRIPTION} development package: C++ headers and CMake modules" - DEPENDS "${COMPONENT_NAME}") -endif() +cmake_minimum_required(VERSION 3.25) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +# Required for the linters. +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30") + # Suppress Boost warning. + cmake_policy(SET CMP0167 OLD) +endif() + +project(knp-cpu-multi-threaded-backend VERSION "${KNP_VERSION}" LANGUAGES C CXX + DESCRIPTION "CPU multi-threaded backend" + HOMEPAGE_URL "https://neuro.kaspersky.ru/neyromorfnye-tekhnologii/") + +set(${PROJECT_NAME}_PUBLIC_INCLUDE_DIR "knp/backends/cpu-multi-threaded") + +include(GNUInstallDirs) +include(clang-tidy) +include(knp-functions) + +find_package(Boost ${KNP_BOOST_MIN_VERSION} COMPONENTS system REQUIRED) + +file(GLOB_RECURSE ${PROJECT_NAME}_headers include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}/*.h) +source_group(source REGULAR_EXPRESSION "impl/.*") +source_group(headers REGULAR_EXPRESSION "include/.*") + +knp_add_library("${PROJECT_NAME}" + BOTH + impl/backend.cpp + impl/get_network.cpp + ${${PROJECT_NAME}_headers} + ALIAS KNP::Backends::CPUMultiThreaded + LINK_PRIVATE + Boost::headers spdlog::spdlog + KNP::Backends::CPU::Library KNP::Backends::CPU::ThreadPool + LINK_PRUBLIC + KNP::Devices::CPU +) + +set_target_properties( + "${PROJECT_NAME}" + PROPERTIES + VERSION "${CMAKE_PROJECT_VERSION}" + SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}") + +if (KNP_INSTALL) + knp_get_component_name("${PROJECT_NAME}" COMPONENT_NAME) + + install(TARGETS "${PROJECT_NAME}" + EXPORT "${PROJECT_NAME}" + COMPONENT "${COMPONENT_NAME}" + LIBRARY) + + install(TARGETS "${PROJECT_NAME}_static" + EXPORT "${PROJECT_NAME}_static" + COMPONENT "${COMPONENT_NAME}-dev" + ARCHIVE) + + install(DIRECTORY "include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}" + COMPONENT "${COMPONENT_NAME}-dev" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/knp/backends" + FILES_MATCHING PATTERN "*.h") + + knp_packaging_set_parameters("${COMPONENT_NAME}" "${PROJECT_NAME}" + DESCRIPTION "${PROJECT_DESCRIPTION}" + DEPENDS "libboost-all (= ${Boost_VERSION})" "libzmq" + PROVIDES "knp-backend") + + knp_packaging_set_parameters("${COMPONENT_NAME}-dev" "${PROJECT_NAME}" + DESCRIPTION "${PROJECT_DESCRIPTION} development package: C++ headers and CMake modules" + DEPENDS "${COMPONENT_NAME}") +endif() diff --git a/knp/backends/cpu/cpu-single-threaded-backend/CMakeLists.txt b/knp/backends/cpu/cpu-single-threaded-backend/CMakeLists.txt index 8cd96dac..0d20cabd 100644 --- a/knp/backends/cpu/cpu-single-threaded-backend/CMakeLists.txt +++ b/knp/backends/cpu/cpu-single-threaded-backend/CMakeLists.txt @@ -14,78 +14,78 @@ See the License for the specific language governing permissions and limitations under the License. ]] -cmake_minimum_required(VERSION 3.25) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -# Required for the linters. -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30") - # Suppress Boost warning. - cmake_policy(SET CMP0167 OLD) -endif() - -project(knp-cpu-single-threaded-backend VERSION "${KNP_VERSION}" LANGUAGES C CXX - DESCRIPTION "Kaspersky Neuromorphic Platform single-threaded CPU backend" - HOMEPAGE_URL "https://neuro.kaspersky.ru/neyromorfnye-tekhnologii/") - -set(${PROJECT_NAME}_PUBLIC_INCLUDE_DIR "knp/backends/cpu-single-threaded") - -include(GNUInstallDirs) -include(clang-tidy) -include(knp-functions) - -find_package(Boost ${KNP_BOOST_MIN_VERSION} COMPONENTS system filesystem REQUIRED) - -file(GLOB_RECURSE ${PROJECT_NAME}_headers include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}/*.h) -source_group(source REGULAR_EXPRESSION "impl/.*") -source_group(headers REGULAR_EXPRESSION "include/.*") - -knp_add_library("${PROJECT_NAME}" - BOTH - impl/backend.cpp - impl/get_network.cpp - ${${PROJECT_NAME}_headers} - ALIAS KNP::Backends::CPUSingleThreaded - LINK_PRIVATE - Boost::headers ${Boost_LIBRARIES} spdlog::spdlog KNP::Backends::CPU::Library - LINK_PUBLIC - KNP::Core KNP::Devices::CPUStatic -) - -set_target_properties( - "${PROJECT_NAME}" - PROPERTIES - VERSION "${CMAKE_PROJECT_VERSION}" - SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}") - -if (KNP_INSTALL) - knp_get_component_name("${PROJECT_NAME}" COMPONENT_NAME) - - install(TARGETS "${PROJECT_NAME}" - EXPORT "${PROJECT_NAME}" - COMPONENT "${COMPONENT_NAME}" - LIBRARY) - - install(TARGETS "${PROJECT_NAME}_static" - EXPORT "${PROJECT_NAME}_static" - COMPONENT "${COMPONENT_NAME}-dev" - ARCHIVE) - - install(DIRECTORY "include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}" - COMPONENT "${COMPONENT_NAME}-dev" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/knp/backends" - FILES_MATCHING PATTERN "*.h") - - knp_packaging_set_parameters("${COMPONENT_NAME}" "${PROJECT_NAME}" - DESCRIPTION "${PROJECT_DESCRIPTION}" - DEPENDS "libboost-all (= ${Boost_VERSION})" "libzmq" - PROVIDES "knp-backend") - - knp_packaging_set_parameters("${COMPONENT_NAME}-dev" "${PROJECT_NAME}" - DESCRIPTION "${PROJECT_DESCRIPTION} development package: C++ headers and CMake modules" - DEPENDS "${COMPONENT_NAME}") -endif() +cmake_minimum_required(VERSION 3.25) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +# Required for the linters. +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30") + # Suppress Boost warning. + cmake_policy(SET CMP0167 OLD) +endif() + +project(knp-cpu-single-threaded-backend VERSION "${KNP_VERSION}" LANGUAGES C CXX + DESCRIPTION "Kaspersky Neuromorphic Platform single-threaded CPU backend" + HOMEPAGE_URL "https://neuro.kaspersky.ru/neyromorfnye-tekhnologii/") + +set(${PROJECT_NAME}_PUBLIC_INCLUDE_DIR "knp/backends/cpu-single-threaded") + +include(GNUInstallDirs) +include(clang-tidy) +include(knp-functions) + +find_package(Boost ${KNP_BOOST_MIN_VERSION} COMPONENTS system filesystem REQUIRED) + +file(GLOB_RECURSE ${PROJECT_NAME}_headers include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}/*.h) +source_group(source REGULAR_EXPRESSION "impl/.*") +source_group(headers REGULAR_EXPRESSION "include/.*") + +knp_add_library("${PROJECT_NAME}" + BOTH + impl/backend.cpp + impl/get_network.cpp + ${${PROJECT_NAME}_headers} + ALIAS KNP::Backends::CPUSingleThreaded + LINK_PRIVATE + Boost::headers ${Boost_LIBRARIES} spdlog::spdlog KNP::Backends::CPU::Library + LINK_PUBLIC + KNP::Core KNP::Devices::CPU +) + +set_target_properties( + "${PROJECT_NAME}" + PROPERTIES + VERSION "${CMAKE_PROJECT_VERSION}" + SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}") + +if (KNP_INSTALL) + knp_get_component_name("${PROJECT_NAME}" COMPONENT_NAME) + + install(TARGETS "${PROJECT_NAME}" + EXPORT "${PROJECT_NAME}" + COMPONENT "${COMPONENT_NAME}" + LIBRARY) + + install(TARGETS "${PROJECT_NAME}_static" + EXPORT "${PROJECT_NAME}_static" + COMPONENT "${COMPONENT_NAME}-dev" + ARCHIVE) + + install(DIRECTORY "include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}" + COMPONENT "${COMPONENT_NAME}-dev" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/knp/backends" + FILES_MATCHING PATTERN "*.h") + + knp_packaging_set_parameters("${COMPONENT_NAME}" "${PROJECT_NAME}" + DESCRIPTION "${PROJECT_DESCRIPTION}" + DEPENDS "libboost-all (= ${Boost_VERSION})" "libzmq" + PROVIDES "knp-backend") + + knp_packaging_set_parameters("${COMPONENT_NAME}-dev" "${PROJECT_NAME}" + DESCRIPTION "${PROJECT_DESCRIPTION} development package: C++ headers and CMake modules" + DEPENDS "${COMPONENT_NAME}") +endif() diff --git a/knp/devices-library/CMakeLists.txt b/knp/devices-library/CMakeLists.txt index e7f1a2c0..ce2f2381 100644 --- a/knp/devices-library/CMakeLists.txt +++ b/knp/devices-library/CMakeLists.txt @@ -14,95 +14,83 @@ See the License for the specific language governing permissions and limitations under the License. ]] -cmake_minimum_required(VERSION 3.25) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -# Required for the linters. -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -project(knp-devices VERSION "${KNP_VERSION}" LANGUAGES C CXX - DESCRIPTION "Kaspersky Neuromorphic Platform device parameters library" - HOMEPAGE_URL "https://neuro.kaspersky.ru/neyromorfnye-tekhnologii/") - -include(GNUInstallDirs) -include(clang-tidy) -include(knp-functions) - -set(${PROJECT_NAME}_PUBLIC_INCLUDE_DIR "knp/devices") - -file(GLOB_RECURSE ${PROJECT_NAME}_headers include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}/*.h) - -source_group(source REGULAR_EXPRESSION "impl/.*") -source_group(headers REGULAR_EXPRESSION "include/.*") - -knp_add_library("${PROJECT_NAME}-cpu" - BOTH - impl/cpu.cpp impl/cpu_power.cpp impl/cpu_power.h - - ${${PROJECT_NAME}_headers} - - LINK_PRIVATE - spdlog::spdlog PCM_STATIC - KNP::Core - ALIAS KNP::Devices::CPU -) - -set_target_properties( - "${PROJECT_NAME}-cpu" - PROPERTIES - VERSION "${CMAKE_PROJECT_VERSION}" - SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}") - -knp_add_library("${PROJECT_NAME}-altai" - BOTH - impl/altai.cpp - - include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}/altai.h - - LINK_PRIVATE - spdlog::spdlog PCM_STATIC - KNP::Core - ALIAS KNP::Devices::AltAI -) - -set_target_properties( - "${PROJECT_NAME}-altai" - PROPERTIES - VERSION "${CMAKE_PROJECT_VERSION}" - SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}" -) - -if (KNP_INSTALL) - set(COMPONENT_NAME "cpp-framework") - - install(TARGETS "${PROJECT_NAME}-cpu" - COMPONENT "${COMPONENT_NAME}-dev" - EXPORT "${PROJECT_NAME}-cpu" - LIBRARY - ) - - install(TARGETS "${PROJECT_NAME}-cpu_static" - EXPORT "${PROJECT_NAME}-cpu_static" - COMPONENT "${COMPONENT_NAME}-dev" - ARCHIVE) - - # Install for AltAI - install(TARGETS "${PROJECT_NAME}-altai" - COMPONENT "${COMPONENT_NAME}-dev" - EXPORT "${PROJECT_NAME}-altai" - LIBRARY - ) - - install(TARGETS "${PROJECT_NAME}-altai_static" - EXPORT "${PROJECT_NAME}-altai_static" - COMPONENT "${COMPONENT_NAME}-dev" - ARCHIVE) - - install(DIRECTORY "include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}" - COMPONENT "${COMPONENT_NAME}-dev" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/knp" - FILES_MATCHING PATTERN "*.h") -endif() +cmake_minimum_required(VERSION 3.25) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +# Required for the linters. +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +project(knp-devices VERSION "${KNP_VERSION}" LANGUAGES C CXX + DESCRIPTION "Kaspersky Neuromorphic Platform device parameters library" + HOMEPAGE_URL "https://neuro.kaspersky.ru/neyromorfnye-tekhnologii/") + +include(GNUInstallDirs) +include(clang-tidy) +include(knp-functions) + +set(${PROJECT_NAME}_PUBLIC_INCLUDE_DIR "knp/devices") + +file(GLOB_RECURSE ${PROJECT_NAME}_headers include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}/*.h) + +source_group(source REGULAR_EXPRESSION "impl/.*") +source_group(headers REGULAR_EXPRESSION "include/.*") + +knp_add_library("${PROJECT_NAME}-cpu" + STATIC + impl/cpu.cpp impl/cpu_power.cpp impl/cpu_power.h + + ${${PROJECT_NAME}_headers} + + LINK_PRIVATE + spdlog::spdlog PCM_STATIC + KNP::Core + ALIAS KNP::Devices::CPU +) + +set_target_properties( + "${PROJECT_NAME}-cpu" + PROPERTIES + VERSION "${CMAKE_PROJECT_VERSION}" + SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}") + +knp_add_library("${PROJECT_NAME}-altai" + STATIC + impl/altai.cpp + + include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}/altai.h + + LINK_PRIVATE + spdlog::spdlog PCM_STATIC + KNP::Core + ALIAS KNP::Devices::AltAI +) + +set_target_properties( + "${PROJECT_NAME}-altai" + PROPERTIES + VERSION "${CMAKE_PROJECT_VERSION}" + SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}" +) + +if (KNP_INSTALL) + set(COMPONENT_NAME "cpp-framework") + + install(TARGETS "${PROJECT_NAME}-cpu" + EXPORT "${PROJECT_NAME}-cpu" + COMPONENT "${COMPONENT_NAME}-dev" + ARCHIVE) + + # Install for AltAI + install(TARGETS "${PROJECT_NAME}-altai" + EXPORT "${PROJECT_NAME}-altai" + COMPONENT "${COMPONENT_NAME}-dev" + ARCHIVE) + + install(DIRECTORY "include/${${PROJECT_NAME}_PUBLIC_INCLUDE_DIR}" + COMPONENT "${COMPONENT_NAME}-dev" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/knp" + FILES_MATCHING PATTERN "*.h") +endif() From 5e96d5a3ac343f522bd36e107bb7003f84256f4e Mon Sep 17 00:00:00 2001 From: "Artiom N." Date: Fri, 22 Nov 2024 01:05:42 +0300 Subject: [PATCH 5/9] MP backend CMakeLists fix: #18 --- knp/backends/cpu/cpu-multi-threaded-backend/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knp/backends/cpu/cpu-multi-threaded-backend/CMakeLists.txt b/knp/backends/cpu/cpu-multi-threaded-backend/CMakeLists.txt index 481e1cfd..83acc170 100644 --- a/knp/backends/cpu/cpu-multi-threaded-backend/CMakeLists.txt +++ b/knp/backends/cpu/cpu-multi-threaded-backend/CMakeLists.txt @@ -53,7 +53,7 @@ knp_add_library("${PROJECT_NAME}" LINK_PRIVATE Boost::headers spdlog::spdlog KNP::Backends::CPU::Library KNP::Backends::CPU::ThreadPool - LINK_PRUBLIC + LINK_PUBLIC KNP::Devices::CPU ) From 11ad1cda906bb58457d49b24596643869d17397c Mon Sep 17 00:00:00 2001 From: "Artiom N." Date: Fri, 22 Nov 2024 01:07:25 +0300 Subject: [PATCH 6/9] Third-party build fix: #18 --- CMakeLists.txt | 23 ++++++--- cmake/CPM.cmake | 1 - cmake/third-party.cmake | 68 +++++++++++++------------- knp/devices-library/impl/cpu.cpp | 2 +- knp/devices-library/impl/cpu_power.cpp | 2 +- knp/devices-library/impl/cpu_power.h | 26 +++++----- 6 files changed, 64 insertions(+), 58 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30efd1b7..f686d28b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -187,7 +187,7 @@ if (KNP_ENABLE_AVX) # -include bits/stdc++.h endif() -if (NOT KNP_MAINTAINER_BUILD) +if (NOT KNP_MAINTAINER_BUILD AND KNP_BUILD_AUTONOMOUS) execute_process(COMMAND pre-commit install WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") if(ret AND NOT ret EQUAL 0) @@ -224,8 +224,14 @@ if (MSVC) endif() if (KNP_BUILD_AUTONOMOUS) - set(CPM_SOURCE_CACHE_DEFAULT "${CMAKE_CURRENT_SOURCE_DIR}/third-party" CACHE STRING "") - set(CPM_SOURCE_CACHE "${CMAKE_CURRENT_SOURCE_DIR}/third-party" CACHE STRING "") + if (NOT CPM_SOURCE_CACHE_DEFAULT) + set(CPM_SOURCE_CACHE_DEFAULT "${CMAKE_CURRENT_SOURCE_DIR}/third-party") + endif() + + if (NOT CPM_SOURCE_CACHE) + message(STATUS "Autonomous build. Setting source cached directory to \"${CPM_SOURCE_CACHE_DEFAULT}\".") + set(CPM_SOURCE_CACHE "${CPM_SOURCE_CACHE_DEFAULT}") + endif() endif() # Make cache variables for installation destinations. @@ -304,6 +310,8 @@ add_third_party("gh:intel/pcm" "NO_STATIC_MSVC_RUNTIME_LIBRARY ON" "NO_ASAN ON") +include_directories("${CPM_PACKAGE_pcm_SOURCE_DIR}/src") + add_third_party("gh:gabime/spdlog@1.13.0" OPTIONS "SPDLOG_BUILD_PIC ON" @@ -328,11 +336,10 @@ if (KNP_BUILD_TESTS) "INSTALL_GTEST OFF") endif() - -if (CPM_SOURCE_CACHE) - file(GLOB THIRD_PARTY_INCLUDES LIST_DIRECTORIES true "${CPM_SOURCE_CACHE}/**/include") - include_directories("${CPM_SOURCE_CACHE}" ${THIRD_PARTY_INCLUDES}) -endif() +#if (CPM_SOURCE_CACHE) +# file(GLOB THIRD_PARTY_INCLUDES LIST_DIRECTORIES true "${CPM_SOURCE_CACHE}/**/include") +# include_directories("${CPM_SOURCE_CACHE}" ${THIRD_PARTY_INCLUDES}) +#endif() if (MSVC) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS FALSE) diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 8269a8bf..5236ca56 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -59,7 +59,6 @@ See https://github.com/cpm-cmake/CPM.cmake for more information." if(${CMAKE_VERSION} VERSION_LESS "3.17.0") include(FetchContent) endif() - return() endif() get_property( diff --git a/cmake/third-party.cmake b/cmake/third-party.cmake index b9b4e88a..3f6dc14a 100644 --- a/cmake/third-party.cmake +++ b/cmake/third-party.cmake @@ -14,37 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. ]] -# -# CMake third-party support functions. Artiom N.(cl)2022 -# - -include_guard(GLOBAL) - -# include(get_cpm) -include("CPM") - - -function(add_third_party module_name) -# add_git_submodule("${CMAKE_CURRENT_SOURCE_DIR}/third-party/${module_name}") - set(CPM_USE_LOCAL_PACKAGES ON) - if(NOT KNP_ROOT_DIR) - set(KNP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - endif() - - if(NOT "${module_name}" STREQUAL NAME) - cpm_parse_add_package_single_arg("${module_name};${ARGN}" ARGN) - # The shorthand syntax implies EXCLUDE_FROM_ALL and SYSTEM - list(GET ARGN 1 _repo_name) - get_filename_component(_repo_name ${_repo_name} NAME) - CPMADDPackage(${ARGN} - EXCLUDE_FROM_ALL YES - SYSTEM YES - SOURCE_DIR "${KNP_ROOT_DIR}/third-party/${_repo_name}") - else() - list(GET ARGN 0 _m_name) - CPMADDPackage("${module_name}" ${ARGN} - EXCLUDE_FROM_ALL YES - SYSTEM YES - SOURCE_DIR "${KNP_ROOT_DIR}/third-party/${_m_name}") - endif() -endfunction() +# +# CMake third-party support functions. Artiom N.(cl)2022 +# + +include_guard(GLOBAL) + +# include(get_cpm) +include(CPM) + + +function(add_third_party module_name) +# add_git_submodule("${CMAKE_CURRENT_SOURCE_DIR}/third-party/${module_name}") + set(CPM_USE_LOCAL_PACKAGES ON) + if(NOT KNP_ROOT_DIR) + set(KNP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + endif() + + if(NOT "${module_name}" STREQUAL NAME) + cpm_parse_add_package_single_arg("${module_name};${ARGN}" ARGN) + # The shorthand syntax implies EXCLUDE_FROM_ALL and SYSTEM + list(GET ARGN 1 _repo_name) + get_filename_component(_repo_name ${_repo_name} NAME) + CPMAddPackage(${ARGN} + EXCLUDE_FROM_ALL YES + SYSTEM YES) + # SOURCE_DIR "${KNP_ROOT_DIR}/third-party/${_repo_name}") + else() + list(GET ARGN 0 _m_name) + CPMAddPackage("${module_name}" ${ARGN} + EXCLUDE_FROM_ALL YES + SYSTEM YES) + # SOURCE_DIR "${KNP_ROOT_DIR}/third-party/${_m_name}") + endif() +endfunction() diff --git a/knp/devices-library/impl/cpu.cpp b/knp/devices-library/impl/cpu.cpp index abb2db37..8014f55f 100644 --- a/knp/devices-library/impl/cpu.cpp +++ b/knp/devices-library/impl/cpu.cpp @@ -26,7 +26,7 @@ # pragma clang diagnostic ignored "-Wdocumentation" #endif -#include +#include #if defined(__clang__) # pragma clang diagnostic pop diff --git a/knp/devices-library/impl/cpu_power.cpp b/knp/devices-library/impl/cpu_power.cpp index 20002d53..9e4674f4 100644 --- a/knp/devices-library/impl/cpu_power.cpp +++ b/knp/devices-library/impl/cpu_power.cpp @@ -21,8 +21,8 @@ #include "cpu_power.h" -#include #include +#include #include #include diff --git a/knp/devices-library/impl/cpu_power.h b/knp/devices-library/impl/cpu_power.h index 59cccfe6..81029f0d 100644 --- a/knp/devices-library/impl/cpu_power.h +++ b/knp/devices-library/impl/cpu_power.h @@ -4,18 +4,18 @@ * @kaspersky_support Artiom N. * @date 20.02.2023 * @license Apache 2.0 - * @copyright © 2024 AO Kaspersky Lab - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * @copyright © 2024 AO Kaspersky Lab + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. */ @@ -28,7 +28,7 @@ # pragma clang diagnostic ignored "-Wdocumentation" #endif -#include +#include #if defined(__clang__) # pragma clang diagnostic pop From 25ab2cadce926ca9cc7b9a5e71e53e72ac9941e8 Mon Sep 17 00:00:00 2001 From: "Artiom N." Date: Fri, 22 Nov 2024 01:08:34 +0300 Subject: [PATCH 7/9] Version get fix: #18 --- cmake/version.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/version.cmake b/cmake/version.cmake index 24ee42b8..f315050f 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -33,9 +33,9 @@ endfunction() function(determine_version_with_git) - message(STATUS "Determining version from Git...") + message(STATUS "Determining version from Git in \"${CMAKE_CURRENT_SOURCE_DIR}\"...") execute_process(COMMAND git describe --tags - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE GIT_EXECUTION_RESULT OUTPUT_VARIABLE GIT_PKG_VERSION_FULL ERROR_VARIABLE GIT_VERSION_ERROR @@ -60,7 +60,7 @@ function(knp_get_version) determine_version_with_git() if (NOT KNP_VERSION) - read_version_file("${CMAKE_SOURCE_DIR}/VERSION") + read_version_file("${CMAKE_CURRENT_SOURCE_DIR}/VERSION") endif() message(STATUS "Kaspersky Neuromorphic Platform version: ${KNP_VERSION}.") From 4a567f52de4f46a5307af8c7c4bdb8478978da53 Mon Sep 17 00:00:00 2001 From: "Artiom N." Date: Fri, 22 Nov 2024 01:08:54 +0300 Subject: [PATCH 8/9] Build script fix: #18 --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index ff430244..f2165598 100755 --- a/build.sh +++ b/build.sh @@ -33,7 +33,7 @@ build() fi if [[ ${SINGLE_PROCESS} == 0 ]]; then - BUILD_ADD_OPTS="${BUILD_ADD_OPTS} --parallel" + BUILD_ADD_OPTS="${BUILD_ADD_OPTS} --parallel $(nproc)" fi set -e From e314a0fe8843a3016a6e53bebd03af4d45ef77ed Mon Sep 17 00:00:00 2001 From: "Artiom N." Date: Fri, 22 Nov 2024 01:57:01 +0300 Subject: [PATCH 9/9] RapidJSON fix: #18 --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f686d28b..167bb4a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,8 +310,6 @@ add_third_party("gh:intel/pcm" "NO_STATIC_MSVC_RUNTIME_LIBRARY ON" "NO_ASAN ON") -include_directories("${CPM_PACKAGE_pcm_SOURCE_DIR}/src") - add_third_party("gh:gabime/spdlog@1.13.0" OPTIONS "SPDLOG_BUILD_PIC ON" @@ -324,10 +322,15 @@ add_third_party("gh:zeromq/cppzmq@4.10.0" add_third_party("gh:Tencent/rapidjson#7c73dd7" OPTIONS "RAPIDJSON_BUILD_DOC OFF" + "RAPIDJSON_BUILD_ASAN OFF" + "RAPIDJSON_BUILD_UBSAN OFF" + "RAPIDJSON_BUILD_CXX17 ON" "RAPIDJSON_BUILD_EXAMPLES OFF" "RAPIDJSON_BUILD_TESTS OFF" "RAPIDJSON_HAS_STDSTRING ON") +include_directories("${CPM_PACKAGE_pcm_SOURCE_DIR}/src" "${CPM_PACKAGE_rapidjson_SOURCE_DIR}/include") + if (KNP_BUILD_TESTS) add_compile_definitions(SPDLOG_ACTIVE_LEVEL=0) add_third_party("gh:google/googletest@1.14.0"