Skip to content
Merged

CI #67

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 5 additions & 22 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Build and Upload Release
name: Build and Upload Static Release

on:
workflow_dispatch:
branches:
- main
release:
types: [published]

Expand All @@ -18,7 +15,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest]
name: Build Release
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -30,41 +27,27 @@ jobs:
uses: MarkusJx/install-boost@v2.4.5
id: install-boost
with:
boost_version: 1.82.0
boost_version: 1.84.0
platform_version: 22.04

- name: MacOS Install Boost
if: ${{ matrix.os == 'macos-latest' }}
uses: MarkusJx/install-boost@v2.4.5
id: install-boost
with:
boost_version: 1.82.0
platform_version: 13

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBoost_INCLUDE_DIR=${{steps.install-boost.outputs.BOOST_ROOT}}/include -DBoost_LIBRARY_DIRS=${{steps.install-boost.outputs.BOOST_ROOT}}/lib
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_SHARED_LIBS=OFF
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Install DataManagement
run: cmake --install ${{github.workspace}}/build/ --prefix "dminstall"

- name: Zip DataManagement
run: zip -r dminstall-${{ matrix.os }}.zip "dminstall"

- name: Get Latest Release Tag
id: get-latest-release
uses: ddbaptiste/get-latest-release@v1.0.0

- name: Release and Upload
run: gh release upload ${{ steps.get-latest-release.outputs.latest-release }} dminstall-${{ matrix.os }}.zip
run: gh release upload ${{ steps.get-latest-release.outputs.latest-release }} libDataManagement.a include/DataManagerBase.hpp include/DataManager.hpp
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
shell: bash
57 changes: 14 additions & 43 deletions .github/workflows/unit_testing.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: Cross Platform Testing

on:
Expand All @@ -9,7 +7,6 @@ on:
branches: [ "main" ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug

jobs:
Expand All @@ -25,52 +22,26 @@ jobs:
uses: MarkusJx/install-boost@v2.4.5
id: install-boost
with:
boost_version: 1.82.0
boost_version: 1.84.0
platform_version: 22.04
toolset: 'gcc'

- name: Install GTest Ubuntu
run: sudo apt-get install libgtest-dev

- name: Build and Test
working-directory: ${{github.workspace}}
shell: bash {0}
run: BOOST_ROOT="${{ steps.install-boost.outputs.BOOST_ROOT }}" ./scripts/build.sh -p
- name: Create Build Directory
run: mkdir build

# windows-build:
# # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# # You can convert this to a matrix build if you need cross-platform coverage.
# # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
# runs-on: windows-latest
# steps:
# - uses: actions/checkout@v3
- name: Configure CMake
working-directory: ${{github.workspace}}/build
run: cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON -DBUILD_SHARED_LIBS=OFF -DDATAMANAGEMENT_INSTALL=OFF
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}

# - name: Install Boost
# uses: MarkusJx/install-boost@v2.4.4
# id: install-boost
# with:
# boost_version: 1.82.0
# platform_version: 2022
# toolset: 'mingw'
- name: Build Project
working-directory: ${{github.workspace}}/build
run: cmake --build .

# - name: Install MSYS2
# uses: msys2/setup-msys2@v2

# - name: Install GTest Windows
# run: msys2 -c 'yes | pacman -S mingw-w64-x86_64-gtest'

# - name: Configure CMake
# # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
# run: |
# cmake -B ${{github.workspace}}/build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_DATA_TESTS=ON -DBoost_INCLUDE_DIR=${{steps.install-boost.outputs.BOOST_ROOT}}/include -DBoost_LIBRARY_DIRS=${{steps.install-boost.outputs.BOOST_ROOT}}/lib
# env:
# BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}

# - name: Build
# # Build your program with the given configuration
# run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

# - name: Test
# working-directory: ${{github.workspace}}/build
# run: 'test/dataTests.exe'
- name: Run Tests
working-directory: ${{github.workspace}}/build
run: tests/dataTests
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ compile_commands.json
CTestTestfile.cmake
_deps

docs/
docs/doxygen/
.vscode/
build/*
!build/.gitkeep
_install/

!.gitkeep
lib/*
bin/*
183 changes: 84 additions & 99 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,123 +1,108 @@
cmake_minimum_required(VERSION 3.19)
set(CMAKE_CXX_STANDARD 17)
cmake_minimum_required(VERSION 3.20)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(utils)
datamanagement_extract_version()

project(
DataManagement
VERSION 1.0.0
datamanagement
VERSION ${DATAMANAGEMENT_VERSION}
DESCRIPTION "A Data Management Library Used By Syndemics Lab Simulation Models"
LANGUAGES CXX
)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)

SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
message(STATUS "Build data management: ${DATAMANAGEMENT_VERSION}")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)

find_package(SQLite3 REQUIRED)
find_package(Boost REQUIRED)
include(GNUInstallDirs)

option(BUILD_TESTS "enable DataManagement unit tests" OFF)
if (NOT BUILD_TESTS STREQUAL OFF)
add_subdirectory(tests)
# ---------------------------------------------------------------------------------------
# Set default build to release
# ---------------------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
endif()

option(BUILD_SHARED_LIBS "Build Using Shared Libraries" ON)
# ---------------------------------------------------------------------------------------
# Compiler config
# ---------------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# ---------------------------------------------------------------------------------------
# Windows CXX Extensions
# ---------------------------------------------------------------------------------------
set(CMAKE_CXX_EXTENSIONS OFF)
if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS" OR CMAKE_SYSTEM_NAME MATCHES "MINGW")
set(CMAKE_CXX_EXTENSIONS ON)
endif()

if(BUILD_SHARED_LIBS)
add_library(${PROJECT_NAME} SHARED)
else()
add_library(${PROJECT_NAME} STATIC)
# ---------------------------------------------------------------------------------------
# Set DATAMANAGEMENT_MASTER_PROJECT to ON if we are building synmodels directly
# ---------------------------------------------------------------------------------------
if(NOT DEFINED DATAMANAGEMENT_MASTER_PROJECT)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set( DATAMANAGEMENT_MASTER_PROJECT ON)
else()
set( DATAMANAGEMENT_MASTER_PROJECT OFF)
endif()
endif()

target_sources(${PROJECT_NAME}
PRIVATE
${PROJECT_SOURCE_DIR}/src/DataManager.cpp
)
# ---------------------------------------------------------------------------------------
# Set all default options
# ---------------------------------------------------------------------------------------
include(options)

target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE
${Boost_INCLUDE_DIRS}
)
# ---------------------------------------------------------------------------------------
# Set position independent code
# ---------------------------------------------------------------------------------------
if(DATAMANAGEMENT_BUILD_PIC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

target_link_libraries(${PROJECT_NAME}
PRIVATE
${SQLite3_LIBRARIES}
${Boost_LIBRARY_DIRS}
${Boost_LIBRARIES}
)
# ---------------------------------------------------------------------------------------
# Build the library
# ---------------------------------------------------------------------------------------
add_library(datamanagement INTERFACE)
add_library(datamanagement::datamanagement ALIAS datamanagement)

# note that it is not CMAKE_INSTALL_PREFIX we are checking here
if(DEFINED CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message(
STATUS
"CMAKE_INSTALL_PREFIX is not set\n"
"Default value: ${CMAKE_INSTALL_PREFIX}\n"
"Will set it to ${CMAKE_SOURCE_DIR}/install"
)
set(CMAKE_INSTALL_PREFIX
"${CMAKE_SOURCE_DIR}/install"
CACHE PATH "Where the library will be installed to" FORCE
)
else()
message(
STATUS
"CMAKE_INSTALL_PREFIX was already set\n"
"Current value: ${CMAKE_INSTALL_PREFIX}"
)
option(BUILD_TESTS "enable datamanagement unit tests" OFF)
if (NOT BUILD_TESTS STREQUAL OFF)
add_subdirectory(tests)
endif()

SET(public_headers
include/DataManager.hpp
include/DataManagerBase.hpp
target_include_directories(${PROJECT_NAME}
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>
)

set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${public_headers}")

set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d")
# ---------------------------------------------------------------------------------------
# Link Dependencies
# ---------------------------------------------------------------------------------------
include(MakeDependenciesAvailable)

include(GNUInstallDirs)

# install the target and create export-set
install(TARGETS ${PROJECT_NAME}
EXPORT "${PROJECT_NAME}Targets"
# these get default values from GNUInstallDirs, no need to set them
#RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # bin
#LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # lib
#ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # lib
# except for public headers, as we want them to be inside a library folder
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} # include/SomeLibrary
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # include
target_link_libraries(${PROJECT_NAME}
INTERFACE
SQLiteCpp
Boost::boost
spdlog::spdlog
Eigen3::Eigen
)

# generate and install export file
install(EXPORT "${PROJECT_NAME}Targets"
FILE "${PROJECT_NAME}Targets.cmake"
NAMESPACE DataManagement::
DESTINATION cmake
)
set_target_properties(datamanagement PROPERTIES VERSION ${DATAMANAGEMENT_VERSION} SOVERSION ${DATAMANAGEMENT_VERSION_MAJOR}.${DATAMANAGEMENT_VERSION_MINOR})

include(CMakePackageConfigHelpers)
# ---------------------------------------------------------------------------------------
# Build Tests
# ---------------------------------------------------------------------------------------
if(DATAMANAGEMENT_BUILD_TESTS)
message(STATUS "Generating tests")
enable_testing()
add_subdirectory(tests)
endif()

# generate the version file for the config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION "${version}"
COMPATIBILITY AnyNewerVersion
)
# create config file
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION cmake
)
# install config files
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION cmake
)
# ---------------------------------------------------------------------------------------
# Install
# ---------------------------------------------------------------------------------------
if(DATAMANAGEMENT_INSTALL)
include(InstallDatamanagement)
endif()
5 changes: 0 additions & 5 deletions Config.cmake.in

This file was deleted.

Loading