Skip to content

Commit

Permalink
Merge pull request #33 from artiomn/master
Browse files Browse the repository at this point in the history
SPDLog maked header-only
  • Loading branch information
artiomn authored Dec 9, 2024
2 parents 3d2ce57 + 611ec15 commit a7f005c
Show file tree
Hide file tree
Showing 13 changed files with 364 additions and 358 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cmake-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:
branches: [ "master" ]
paths:
- 'knp/**'
- 'examples/**'
- 'CMakeLists.txt'
- '.github/workflows/cmake-build.yml'
- '!/doc/**'
- '!/docker/**'
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,7 @@ gmon.out
# QtCreator

CMakeLists.txt.user

# MSVS.

/.vs
4 changes: 2 additions & 2 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"CurrentProjectSetting": "Windows x64 Debug (windows-default)"
}
"CurrentProjectSetting": "Windows x64 Debug (windows-ninja)"
}
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ include(print-variables)
# Build third-party.
#

if (MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()

if (KNP_BUILD_AUTONOMOUS)
if (NOT CPM_SOURCE_CACHE_DEFAULT)
set(CPM_SOURCE_CACHE_DEFAULT "${CMAKE_CURRENT_SOURCE_DIR}/third-party")
Expand All @@ -243,6 +239,15 @@ else()
set(ZMQ_ENABLE_PRECOMPS ON)
endif()

add_third_party("gh:gabime/[email protected]"
OPTIONS
"SPDLOG_BUILD_PIC ON"
"SPDLOG_BUILD_SHARED OFF")

if (MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()

add_third_party(NAME "libzmq"
GITHUB_REPOSITORY "zeromq/libzmq"
VERSION "4.3.5"
Expand Down Expand Up @@ -305,7 +310,7 @@ add_third_party("gh:p-ranav/[email protected]"
"CSV2_TEST OFF"
"CSV2_SAMPLES OFF")

if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^x86.*")
if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86.*)|(X86.*)|(amd64)|(AMD64)")
add_third_party("gh:intel/pcm"
GIT_TAG 2f9b0c2
OPTIONS
Expand All @@ -314,16 +319,11 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^x86.*")
include_directories("${CPM_PACKAGE_pcm_SOURCE_DIR}/src")
endif()

add_third_party("gh:gabime/[email protected]"
OPTIONS
"SPDLOG_BUILD_PIC ON"
"SPDLOG_BUILD_SHARED OFF")

add_third_party("gh:zeromq/[email protected]"
OPTIONS
"CPPZMQ_BUILD_TESTS OFF")

add_third_party("gh:Tencent/rapidjson#7c73dd7"
add_third_party("gh:Tencent/rapidjson#ebd87cb"
OPTIONS
"RAPIDJSON_BUILD_DOC OFF"
"RAPIDJSON_BUILD_ASAN OFF"
Expand Down
80 changes: 40 additions & 40 deletions knp/backends/cpu/cpu-library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,43 @@ 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)

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-backends-library VERSION "${KNP_VERSION}" LANGUAGES C CXX)

find_package(Boost ${KNP_BOOST_MIN_VERSION} REQUIRED)

include(clang-tidy)
include(knp-functions)

file(GLOB_RECURSE ${PROJECT_NAME}_headers include/knp/backends/cpu-library/*.h)

knp_add_library("${PROJECT_NAME}"
INTERFACE
include/knp/backends/cpu-library/impl/synaptic_resource_stdp_impl.h
${${PROJECT_NAME}_headers})
add_library(KNP::Backends::CPU::Library ALIAS "${PROJECT_NAME}")

source_group(source REGULAR_EXPRESSION "impl/.*")
source_group(headers FILES ${${PROJECT_NAME}_headers} REGULAR_EXPRESSION "include/.*")
source_group(headers REGULAR_EXPRESSION "impl/.*")

target_include_directories("${PROJECT_NAME}" INTERFACE ${Boost_INCLUDE_DIRS})
target_include_directories("${PROJECT_NAME}" INTERFACE "impl")

target_link_libraries("${PROJECT_NAME}" INTERFACE Boost::headers spdlog::spdlog)
target_link_libraries("${PROJECT_NAME}" INTERFACE KNP::Core KNP::Devices::CPU)

# Internal library, used by backends.
# This doesn't require installation.
cmake_minimum_required(VERSION 3.25)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

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-backends-library VERSION "${KNP_VERSION}" LANGUAGES C CXX)

find_package(Boost ${KNP_BOOST_MIN_VERSION} REQUIRED)

include(clang-tidy)
include(knp-functions)

file(GLOB_RECURSE ${PROJECT_NAME}_headers include/knp/backends/cpu-library/*.h)

knp_add_library("${PROJECT_NAME}"
INTERFACE
include/knp/backends/cpu-library/impl/synaptic_resource_stdp_impl.h
${${PROJECT_NAME}_headers})
add_library(KNP::Backends::CPU::Library ALIAS "${PROJECT_NAME}")

source_group(source REGULAR_EXPRESSION "impl/.*")
source_group(headers FILES ${${PROJECT_NAME}_headers} REGULAR_EXPRESSION "include/.*")
source_group(headers REGULAR_EXPRESSION "impl/.*")

target_include_directories("${PROJECT_NAME}" INTERFACE ${Boost_INCLUDE_DIRS})
target_include_directories("${PROJECT_NAME}" INTERFACE "impl")

target_link_libraries("${PROJECT_NAME}" INTERFACE Boost::headers spdlog::spdlog_header_only)
target_link_libraries("${PROJECT_NAME}" INTERFACE KNP::Core KNP::Devices::CPU)

# Internal library, used by backends.
# This doesn't require installation.
2 changes: 1 addition & 1 deletion knp/backends/cpu/cpu-multi-threaded-backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ knp_add_library("${PROJECT_NAME}"
${${PROJECT_NAME}_headers}
ALIAS KNP::Backends::CPUMultiThreaded
LINK_PRIVATE
Boost::headers spdlog::spdlog
Boost::headers spdlog::spdlog_header_only
KNP::Backends::CPU::Library KNP::Backends::CPU::ThreadPool
LINK_PUBLIC
KNP::Devices::CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ knp_add_library("${PROJECT_NAME}"
${${PROJECT_NAME}_headers}
ALIAS KNP::Backends::CPUSingleThreaded
LINK_PRIVATE
Boost::headers ${Boost_LIBRARIES} spdlog::spdlog KNP::Backends::CPU::Library
Boost::headers ${Boost_LIBRARIES} spdlog::spdlog_header_only KNP::Backends::CPU::Library
LINK_PUBLIC
KNP::Core KNP::Devices::CPU
)
Expand Down
76 changes: 38 additions & 38 deletions knp/backends/cpu/thread_pool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,41 @@ See the License for the specific language governing permissions and
limitations under the License.
]]

cmake_minimum_required(VERSION 3.22)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

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-thread-pool-library VERSION "${KNP_VERSION}" LANGUAGES C CXX)

find_package(Boost ${KNP_BOOST_MIN_VERSION} REQUIRED)

include(clang-tidy)
include(knp-functions)

file(GLOB_RECURSE ${PROJECT_NAME}_headers include/knp/backends/thread_pool/*.h)

knp_add_library("${PROJECT_NAME}"
STATIC
impl/thread_pool_context.cpp
${${PROJECT_NAME}_headers}
)
add_library(KNP::Backends::CPU::ThreadPool ALIAS "${PROJECT_NAME}")

source_group(source REGULAR_EXPRESSION "impl/.*")
source_group(headers FILES ${${PROJECT_NAME}_headers} REGULAR_EXPRESSION "include/.*")

target_include_directories("${PROJECT_NAME}" PRIVATE ${Boost_INCLUDE_DIRS})

target_link_libraries("${PROJECT_NAME}" PRIVATE Boost::headers spdlog::spdlog)

# Internal library, used by backends.
# This doesn't require installation.
cmake_minimum_required(VERSION 3.22)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

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-thread-pool-library VERSION "${KNP_VERSION}" LANGUAGES C CXX)

find_package(Boost ${KNP_BOOST_MIN_VERSION} REQUIRED)

include(clang-tidy)
include(knp-functions)

file(GLOB_RECURSE ${PROJECT_NAME}_headers include/knp/backends/thread_pool/*.h)

knp_add_library("${PROJECT_NAME}"
STATIC
impl/thread_pool_context.cpp
${${PROJECT_NAME}_headers}
)
add_library(KNP::Backends::CPU::ThreadPool ALIAS "${PROJECT_NAME}")

source_group(source REGULAR_EXPRESSION "impl/.*")
source_group(headers FILES ${${PROJECT_NAME}_headers} REGULAR_EXPRESSION "include/.*")

target_include_directories("${PROJECT_NAME}" PRIVATE ${Boost_INCLUDE_DIRS})

target_link_libraries("${PROJECT_NAME}" PRIVATE Boost::headers spdlog::spdlog_header_only)

# Internal library, used by backends.
# This doesn't require installation.
2 changes: 1 addition & 1 deletion knp/base-framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ knp_add_library("${PROJECT_NAME}-core"
${${PROJECT_NAME}_headers}
ALIAS KNP::BaseFramework::Core
LINK_PRIVATE
spdlog::spdlog Boost::headers Boost::filesystem HighFive ${HDF5_LIB} csv2 # RapidJSON
spdlog::spdlog_header_only Boost::headers Boost::filesystem HighFive ${HDF5_LIB} csv2
# Hack to build with CLang.
${ADD_LIBS}
LINK_PUBLIC
Expand Down
8 changes: 4 additions & 4 deletions knp/base-framework/impl/storage/native/data_storage_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ bool is_json_has_magic(const rapidjson::Document &doc) // cppcheck-suppress con
bool has_magic = false;
for (auto group_iter = attributes.Begin(); group_iter != attributes.End(); ++group_iter)
{
const auto &group = group_iter->GetObject();
const auto &group = *group_iter;
if (group.HasMember("name") && group["name"].GetString() == magic)
{
if (group.HasMember("value") && group["value"].GetInt() != MAGIC_NUMBER) break;
Expand All @@ -163,7 +163,7 @@ bool is_correct_version(const rapidjson::Document &doc) // cppcheck-suppress co

for (auto group_iter = attributes.Begin(); group_iter != attributes.End(); ++group_iter)
{
const auto &group = group_iter->GetObject();
const auto &group = *group_iter;

if (!group.HasMember("name") || group["name"].GetString() != version_str) continue;
if (!group.HasMember("value") || !group["value"].IsArray()) return false;
Expand Down Expand Up @@ -191,7 +191,7 @@ auto read_nodes(const rapidjson::Document::Object &spikes_group)
// Reading node IDs.
if (!spikes_group.HasMember("node_ids") || !spikes_group["node_ids"].IsObject())
throw std::runtime_error("No \"node_ids\" array in \"spikes\" group.");
const auto &nodes_ids = spikes_group["node_ids"].GetObject();
const auto &nodes_ids = spikes_group["node_ids"];

if (!nodes_ids.HasMember("value") || !nodes_ids["value"].IsArray())
throw std::runtime_error("Missing node data in JSON data file.");
Expand Down Expand Up @@ -253,7 +253,7 @@ KNP_DECLSPEC std::vector<core::messaging::SpikeMessage> load_messages_from_json(

if (!doc.HasMember("spikes") || !doc["spikes"].IsObject())
throw std::runtime_error("Unable to find \"spikes\" group in data file.");
const auto &spikes_group = doc["spikes"].GetObject();
const auto &spikes_group = doc["spikes"].GetObj();

auto nodes = read_nodes(spikes_group);
auto timestamps = read_timestamps(spikes_group);
Expand Down
Loading

0 comments on commit a7f005c

Please sign in to comment.