Skip to content

Commit

Permalink
Merge branch 'release/0.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjp committed Aug 12, 2022
2 parents 0f8ee56 + beb6a1d commit 13185c1
Show file tree
Hide file tree
Showing 13 changed files with 202 additions and 136 deletions.
89 changes: 25 additions & 64 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,17 @@
#
# This is the Top level CMakelists file which creates the namespace and
# organizes all sublibraries under it.
#
# The project name in this file is considered the "Namespace"
# and any libraries under it will be given a target of
#
# Namespace::library_name
#
#
# This Lists file was modified from https://github.com/forexample/package-example
#
# This file creates project 'Foo' with two library targets 'bar' and 'cat'.
# Target 'cat' depends on 'bar'. After installation this project can be found
# by 'find_package(... CONFIG)' command:
#
# find_package(foo CONFIG REQUIRED)
# target_link_libraries(... foo::bar)
#
# Note that requirements propagated automatically, for example:
# * Foo::baz linked automatically
# * <prefix>/include added to header search path
# * FOO_BAZ_DEBUG=1/FOO_BAR_DEBUG=1 added on Debug
# * FOO_BAZ_DEBUG=0/FOO_BAR_DEBUG=0 added on other configurations
cmake_minimum_required(VERSION 3.13)

####
# Set minimum version of CMake. We need 3.13 at least.
cmake_minimum_required(VERSION 3.13) # GENERATOR_IS_MULTI_CONFIG
set(PROJECT_NAME "kami")

set(KAMI_VERSION_MAJOR 0)
set(KAMI_VERSION_MINOR 5)
set(KAMI_VERSION_PATCH 0)
set(KAMI_VERSION_STRING ${KAMI_VERSION_MAJOR}.${KAMI_VERSION_MINOR}.${KAMI_VERSION_PATCH})
set(VERSION_MAJOR 0)
set(VERSION_MINOR 5)
set(VERSION_PATCH 1)
set(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})

################################################################################
# Set variables for the project. The:
# * PROJECT_NAME
# * PROJECT_VERSION
# * PROJECT_NAMESPACE should be the same as the project.
project(kami VERSION ${KAMI_VERSION_STRING}
LANGUAGES CXX)
project(${PROJECT_NAME}
VERSION ${VERSION_STRING}
LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -48,11 +21,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_BINARY_DIR}" CACHE STRING "M
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(PROJECT_NAMESPACE kami ) # The project namespace. Library targets
# will be referred by
# foo::bar. This value should usually be
# the same as the project.
################################################################################
set(PROJECT_NAMESPACE ${PROJECT_NAME})

find_package(spdlog)
find_package(Threads)
Expand Down Expand Up @@ -95,7 +64,7 @@ ENDFOREACH()
################################################################################
# Examples.
#
# Each example will be built as a static or shared library and a
# Each example will be built as a static or shared binary and a
# target will be created for it.
################################################################################

Expand Down Expand Up @@ -125,7 +94,7 @@ include(GNUInstallDirs)
# * <prefix>/include/
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")

set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")

# Configuration
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
Expand Down Expand Up @@ -158,38 +127,30 @@ configure_package_config_file(
# * <prefix>/lib/libbaz.a
# * header location after install: <prefix>/include/foo/Bar.hpp
# * headers can be included by C++ code `#include <foo/Bar.hpp>`
install(
TARGETS
${sub_modules} ${example_modules}
${COVERAGE_INSTALL_TARGET}
EXPORT
"${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(
TARGETS ${sub_modules} ${example_modules} ${COVERAGE_INSTALL_TARGET}
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)


# Config
# * <prefix>/lib/cmake/Foo/FooConfig.cmake
# * <prefix>/lib/cmake/Foo/FooConfigVersion.cmake
install(
FILES
"${project_config}" "${version_config}"
DESTINATION
"${config_install_dir}"
FILES "${project_config}" "${version_config}"
DESTINATION "${config_install_dir}"
)

# Config
# * <prefix>/lib/cmake/Foo/FooTargets.cmake
install(
EXPORT
"${TARGETS_EXPORT_NAME}"
NAMESPACE
"${namespace}"
DESTINATION
"${config_install_dir}"
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
)

add_subdirectory(docs)
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
[![Build (main)](https://github.com/JHUAPL/kami/actions/workflows/build-main.yml/badge.svg)](https://github.com/JHUAPL/kami/actions/workflows/build-main.yml)
[![Build (develop)](https://github.com/JHUAPL/kami/actions/workflows/build-develop.yml/badge.svg)](https://github.com/JHUAPL/kami/actions/workflows/build-develop.yml)
[![Documentation status](https://readthedocs.org/projects/kami/badge/?version=latest)](https://kami.readthedocs.io/en/latest/?badge=latest)
[![Documentation status](https://readthedocs.org/projects/kami/badge/?version=main)](https://kami.readthedocs.io/en/main/)
[![Release status](https://img.shields.io/github/release/JHUAPL/kami.svg)](https://github.com/JHUAPL/kami/releases)
![License](https://img.shields.io/github/license/JHUAPL/kami)

# Kami is Agent-Based Modeling in Modern C++

Agent-based models (ABMs) are models for simulating the actions of
individual actors within a provided environment to understand the
behavior of the agents, most individually and collectively. ABMs
are particularly suited for addressing problems governed by nonlinear
processes or where there is a wide variety of potential responses
an individual agent may provide depending on the environment and
behavior of other agents. Because of this, ABMs have become powerful
tools in both simulation and modeling, especially in public health
and ecology, where they are also known as individual-based models.
ABMs also provide support in economic, business, robotics, and many
other fields.

## Compiling

```Bash
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class KamiConan(ConanFile):
name = "kami"
version = "0.5.0"
version = "0.5.1"
license = "MIT"
author = "James P. Howard, II <[email protected]>"
url = "https://github.com/jhuapl/kami"
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

- :release:`0.5.1 <2022.08.11>`
- :support:`0` Completed initial unit tests
- :support:`0` Added background info to READ ME

- :release:`0.5.0 <2022.08.08>`
- :feature:`0` Added a barebones "starter" model to build from
- :support:`0` Numerous documentation cleanups
- :bug:`0` Numerous code cleanups to remove void returns and eliminate stored Model references
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Introduction
.. image:: https://github.com/JHUAPL/kami/actions/workflows/build-develop.yml/badge.svg?branch=develop
:target: https://github.com/JHUAPL/kami/actions/workflows/build-develop.yml
:alt: Build Status (develop)
.. image:: https://readthedocs.org/projects/kami/badge/?version=latest
:target: https://kami.readthedocs.io/en/latest/?badge=latest
.. image:: https://readthedocs.org/projects/kami/badge/?version=main
:target: https://kami.readthedocs.io/en/main/
:alt: Documentation Status
.. image:: https://img.shields.io/github/release/JHUAPL/kami.svg
:target: https://github.com/JHUAPL/kami/releases
Expand Down
2 changes: 1 addition & 1 deletion examples/boltzmann1d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ create_executable(
PUBLIC_LINKED_TARGETS fmt spdlog::spdlog kami::libkami
)

set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${KAMI_VERSION_STRING})
set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${VERSION_STRING})
2 changes: 1 addition & 1 deletion examples/boltzmann2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ create_executable(
PUBLIC_LINKED_TARGETS fmt spdlog::spdlog kami::libkami
)

set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${KAMI_VERSION_STRING})
set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${VERSION_STRING})
2 changes: 1 addition & 1 deletion examples/starter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ create_executable(
PUBLIC_LINKED_TARGETS fmt spdlog::spdlog kami::libkami
)

set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${KAMI_VERSION_STRING})
set_target_properties(${EXAMPLE_NAME} PROPERTIES VERSION ${VERSION_STRING})
8 changes: 3 additions & 5 deletions include/kami/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,23 @@
/**
* The major version of the Kami library.
*/
#define KAMI_VERSION_MAJOR @KAMI_VERSION_MAJOR@
#define KAMI_VERSION_MAJOR @VERSION_MAJOR@

/**
* The minor version of the Kami library.
*/
#define KAMI_VERSION_MINOR @KAMI_VERSION_MINOR@
#define KAMI_VERSION_MINOR @VERSION_MINOR@

/**
* The patch level of the Kami library.
*/
#define KAMI_VERSION_PATCH @KAMI_VERSION_PATCH@
#define KAMI_VERSION_PATCH @VERSION_PATCH@

namespace kami {

namespace {
/**
* @brief A reference copy of the current version of Kami
*
* @return the version as a `semver` object
*/
constexpr auto version = semver::version{KAMI_VERSION_MAJOR, KAMI_VERSION_MINOR, KAMI_VERSION_PATCH};
}
Expand Down
114 changes: 60 additions & 54 deletions src/libkami/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,71 @@
# Set minimum version of CMake.
cmake_minimum_required(VERSION 3.13)

project(libkami VERSION ${KAMI_VERSION_STRING}
LANGUAGES CXX)
set(LIBRARY_NAME "libkami")

create_library(NAME libkami
NAMESPACE libkami
SOURCES
agent.cc
domain.cc
grid1d.cc
grid2d.cc
model.cc
multigrid1d.cc
multigrid2d.cc
population.cc
random.cc
sequential.cc
sologrid1d.cc
sologrid2d.cc
staged.cc
PUBLIC_INCLUDE_PATHS
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated_headers>"
PRIVATE_LINKED_TARGETS
${COVERAGE_TARGET}
EXPORT_FILE_PATH
"${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/KAMI_EXPORT.h"
)
project(${LIBRARY_NAME} LANGUAGES CXX)

project(${LIBRARY_NAME}
VERSION ${VERSION_STRING}
LANGUAGES CXX)

create_library(
NAME ${LIBRARY_NAME}
NAMESPACE ${LIBRARY_NAME}
SOURCES
agent.cc
domain.cc
grid1d.cc
grid2d.cc
model.cc
multigrid1d.cc
multigrid2d.cc
population.cc
random.cc
sequential.cc
sologrid1d.cc
sologrid2d.cc
staged.cc
PUBLIC_INCLUDE_PATHS "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated_headers>"
PRIVATE_LINKED_TARGETS ${COVERAGE_TARGET}
EXPORT_FILE_PATH "${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/KAMI_EXPORT.h"
)

configure_file(
"${CMAKE_SOURCE_DIR}/include/kami/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/config.h")
"${CMAKE_SOURCE_DIR}/include/kami/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/config.h"
)

set_target_properties(libkami PROPERTIES VERSION ${KAMI_VERSION_STRING}
SOVERSION ${KAMI_VERSION_MAJOR}
OUTPUT_NAME kami)
set_target_properties(
${LIBRARY_NAME}
PROPERTIES VERSION ${VERSION_STRING}
SOVERSION ${VERSION_MAJOR}
OUTPUT_NAME kami
)

# Introduce variables:
# * CMAKE_INSTALL_LIBDIR
# * CMAKE_INSTALL_BINDIR
# * CMAKE_INSTALL_INCLUDEDIR
include(GNUInstallDirs)
# Introduce variables:
# * CMAKE_INSTALL_LIBDIR
# * CMAKE_INSTALL_BINDIR
# * CMAKE_INSTALL_INCLUDEDIR
include(GNUInstallDirs)

# Headers:
# * include/foo/bar/bar.h -> <prefix>/include/NAMESPACE/LIBRARY_NAME/*.h
# * include/foo/bar/bar.h -> <prefix>/include/foo/bar/bar.h
install(
DIRECTORY "${CMAKE_SOURCE_DIR}/include/kami"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILES_MATCHING PATTERN "*"
)
# Headers:
# * include/foo/bar/bar.h -> <prefix>/include/NAMESPACE/LIBRARY_NAME/*.h
# * include/foo/bar/bar.h -> <prefix>/include/foo/bar/bar.h
install(
DIRECTORY "${CMAKE_SOURCE_DIR}/include/kami"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILES_MATCHING PATTERN "*"
)

# Export headers:
# The export header will be stored in:
# <prefix>/include/${NAMESPACE}/LIBRARY_NAME/LIBRARY_NAME_export.h
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/KAMI_EXPORT.h"
"${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/config.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/kami"
)
# Export headers:
# The export header will be stored in:
# <prefix>/include/${NAMESPACE}/LIBRARY_NAME/LIBRARY_NAME_export.h
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/KAMI_EXPORT.h"
"${CMAKE_CURRENT_BINARY_DIR}/generated_headers/kami/config.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/kami"
)

add_library(kami::libkami ALIAS libkami)
add_library(kami::libkami ALIAS libkami)
16 changes: 16 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ create_test(
PUBLIC_COMPILE_FEATURES ${COVERAGE_FLAGS}
)

create_test(
NAME unit-kami-model
SOURCES unit-kami-model.cc
PUBLIC_LINKED_TARGETS gmock gtest kami::libkami Threads::Threads
COMMAND unit-kami-model
PUBLIC_COMPILE_FEATURES ${COVERAGE_FLAGS}
)

create_test(
NAME unit-kami-multigrid1d
SOURCES unit-kami-multigrid1d.cc
PUBLIC_LINKED_TARGETS gmock gtest kami::libkami Threads::Threads
COMMAND unit-kami-multigrid1d
PUBLIC_COMPILE_FEATURES ${COVERAGE_FLAGS}
)

create_test(
NAME unit-kami-stagedagent
SOURCES unit-kami-stagedagent.cc
Expand Down
Loading

0 comments on commit 13185c1

Please sign in to comment.