Skip to content

Commit

Permalink
Merge branch 'main' into feat-python-bindings-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
asalzburger authored Aug 15, 2024
2 parents 2de8b01 + 4f61609 commit 3147683
Show file tree
Hide file tree
Showing 41 changed files with 1,554 additions and 1,461 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,26 @@ env:
CTEST_OUTPUT_ON_FAILURE: 1

jobs:
ubuntu:
runs-on: ubuntu-latest
build:
strategy:
matrix:
os:
- macos-14
- ubuntu-22.04
- ubuntu-24.04

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Install Dependencies
run: sudo apt-get install libboost-all-dev
run: |
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install boost
else
sudo apt-get install libboost-all-dev
fi
- name: Initialize Workspace
run: cd $GITHUB_WORKSPACE
Expand All @@ -29,7 +41,13 @@ jobs:
- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DACTSVG_USE_SYSTEM_BOOST=Off -DACTSVG_BUILD_TESTING=On -DACTSVG_BUILD_EXAMPLES=On
run: |
cmake $GITHUB_WORKSPACE \
-DCOMPILE_WARNING_AS_ERROR=ON \
-DACTSVG_BUILD_TESTING=ON \
-DACTSVG_BUILD_META=ON \
-DACTSVG_BUILD_WEB=ON \
-DACTSVG_BUILD_EXAMPLES=ON
- name: Build
working-directory: ${{runner.workspace}}/build
Expand Down
139 changes: 75 additions & 64 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,100 +1,111 @@
cmake_minimum_required(VERSION 3.11)

project (actsvg VERSION 0.4.41 LANGUAGES CXX )
project(actsvg VERSION 0.4.41 LANGUAGES CXX)

# Set up the used C++ standard(s).
set( CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to use" )
set( CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "Disable C++ extensions" )

set(ACTSVG_CXX_FLAGS "-Wall -Wextra -Wpedantic -Wshadow -Wno-unused-local-typedefs")
# This adds some useful conversion checks like float-to-bool, float-to-int, etc.
# However, at the moment this is only added to clang builds, since GCC's -Wfloat-conversion
# is much more aggressive and also triggers on e.g., double-to-float
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
set(ACTSVG_CXX_FLAGS "${ACTSVG_CXX_FLAGS} -Wfloat-conversion")
endif()
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to use")
set(CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "Disable C++ extensions")

set(ACTSVG_CXX_FLAGS
"-Wall -Wextra -Wpedantic -Wshadow -Wzero-as-null-pointer-constant -Wold-style-cast -Wnull-dereference -Wfloat-conversion"
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ACTSVG_CXX_FLAGS}")
# Controls behavior of DOWNLOAD_EXTRACT_TIMESTAMP
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()

# CMake include(s).
include( CMakeDependentOption )
include( GNUInstallDirs )
include(CMakeDependentOption)
include(GNUInstallDirs)

# Flags controlling the meta-build system.
option( ACTSVG_USE_SYSTEM_LIBS "Use system libraries be default" FALSE )
option(ACTSVG_USE_SYSTEM_LIBS "Use system libraries be default" FALSE)

# Explicitly set the output directory for the binaries. Such that if this
# project is included by another project, the main project's configuration would
# win out.
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}" CACHE PATH
"Directory for the built binaries" )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}" CACHE PATH
"Directory for the built libraries" )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}" CACHE PATH
"Directory for the built static libraries" )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}"
CACHE PATH
"Directory for the built binaries"
)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
CACHE PATH
"Directory for the built libraries"
)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
CACHE PATH
"Directory for the built static libraries"
)

# Include the Detray CMake code.
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
include( actsvg-functions )
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(actsvg-functions)

# Core library component
add_subdirectory(core)

option(ACTSVG_BUILD_META "Build the meta level interface of ACTSVG" ON )
if ( ACTSVG_BUILD_META )
add_subdirectory(meta)
option(ACTSVG_BUILD_META "Build the meta level interface of ACTSVG" ON)
if(ACTSVG_BUILD_META)
add_subdirectory(meta)
endif()

option(ACTSVG_BUILD_WEB "Build the webpage builder interface of ACTSVG" ON )
if ( ACTSVG_BUILD_WEB )
add_subdirectory(web)
option(ACTSVG_BUILD_WEB "Build the webpage builder interface of ACTSVG" ON)
if(ACTSVG_BUILD_WEB)
add_subdirectory(web)
endif()

option(ACTSVG_BUILD_TESTING "Build the (unit) tests of ACTSVG" OFF)

option(ACTSVG_BUILD_TESTING "Build the (unit) tests of ACTSVG" OFF )

if (ACTSVG_BUILD_TESTING OR ACTSVG_BUILD_EXAMPLES)
add_subdirectory(data)
if(ACTSVG_BUILD_TESTING OR ACTSVG_BUILD_EXAMPLES)
add_subdirectory(data)
endif()

# Set up the test(s).
include( CTest )
if( ACTSVG_BUILD_TESTING )
add_subdirectory( tests )
include(CTest)
if(ACTSVG_BUILD_TESTING)
add_subdirectory(tests)
endif()

if (ACTSVG_BUILD_TESTING OR ACTSVG_BUILD_EXAMPLES)
# Set up GoogleTest.
option( ACTSVG_SETUP_GOOGLETEST
"Set up the GoogleTest target(s) explicitly" TRUE )
option( ACTSVG_USE_SYSTEM_GOOGLETEST
"Pick up an existing installation of GoogleTest from the build environment"
${ACTSVG_USE_SYSTEM_LIBS} )
if( ACTSVG_SETUP_GOOGLETEST )
if( ACTSVG_USE_SYSTEM_GOOGLETEST )
find_package( GTest REQUIRED )
else()
add_subdirectory( extern/googletest )
endif()
endif()
if(ACTSVG_BUILD_TESTING OR ACTSVG_BUILD_EXAMPLES)
# Set up GoogleTest.
option(
ACTSVG_SETUP_GOOGLETEST
"Set up the GoogleTest target(s) explicitly"
TRUE
)
option(
ACTSVG_USE_SYSTEM_GOOGLETEST
"Pick up an existing installation of GoogleTest from the build environment"
${ACTSVG_USE_SYSTEM_LIBS}
)
if(ACTSVG_SETUP_GOOGLETEST)
if(ACTSVG_USE_SYSTEM_GOOGLETEST)
find_package(GTest REQUIRED)
else()
add_subdirectory(extern/googletest)
endif()
endif()
endif()

option(ACTSVG_BUILD_PYTHON_BINDINGS "Build the python bindings of ACTSVG" OFF)
if(ACTSVG_BUILD_PYTHON_BINDINGS)
find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development)
option(ACTSVG_USE_SYSTEM_PYBIND11 "Pick up an existing installation of pybind11")
if(ACTSVG_USE_SYSTEM_PYBIND11)
find_package(pybind11 CONFIG REQUIRED)
else()
add_subdirectory(extern/pybind11)
endif()
# Add the python sub directory
add_subdirectory(python)
find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development)
option(
ACTSVG_USE_SYSTEM_PYBIND11
"Pick up an existing installation of pybind11"
)
if(ACTSVG_USE_SYSTEM_PYBIND11)
find_package(pybind11 CONFIG REQUIRED)
else()
add_subdirectory(extern/pybind11)
endif()
# Add the python sub directory
add_subdirectory(python)
endif()


# Set up the packaging of the project.
include( actsvg-packaging )
include(actsvg-packaging)
69 changes: 37 additions & 32 deletions cmake/actsvg-functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,33 @@ include( CMakeParseArguments )
# Usage: actsvg_add_library( actsvg_core core "header1.cpp"... )
#
function( actsvg_add_library fullname basename )
cmake_parse_arguments( ARG "" "" "" ${ARGN} )
cmake_parse_arguments( ARG "" "" "" ${ARGN} )

# Create the library.
add_library( ${fullname} SHARED ${ARG_UNPARSED_ARGUMENTS} )
# Create the library.
add_library( ${fullname} SHARED ${ARG_UNPARSED_ARGUMENTS} )

# Set up how clients should find its headers.
target_include_directories( ${fullname} PUBLIC
# Set up how clients should find its headers.
target_include_directories( ${fullname} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> )

# Make sure that the library is available as "actsvg::${basename}" in every
# situation.
set_target_properties( ${fullname} PROPERTIES EXPORT_NAME ${basename} )
add_library( actsvg::${basename} ALIAS ${fullname} )
set_target_properties(${fullname}
PROPERTIES
COMPILE_FLAGS ${ACTSVG_CXX_FLAGS})

# Set up the installation of the library and its headers.
install( TARGETS ${fullname}
# Make sure that the library is available as "actsvg::${basename}" in every
# situation.
set_target_properties( ${fullname} PROPERTIES EXPORT_NAME ${basename} )
add_library( actsvg::${basename} ALIAS ${fullname} )


# Set up the installation of the library and its headers.
install( TARGETS ${fullname}
EXPORT actsvg-exports
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" OPTIONAL )

endfunction( actsvg_add_library )
Expand All @@ -44,15 +49,15 @@ endfunction( actsvg_add_library )
#
function( actsvg_add_executable name )

# Parse the function's options.
cmake_parse_arguments( ARG "" "" "LINK_LIBRARIES" ${ARGN} )
# Parse the function's options.
cmake_parse_arguments( ARG "" "" "LINK_LIBRARIES" ${ARGN} )

# Create the executable.
set( exe_name "actsvg_${name}" )
add_executable( ${exe_name} ${ARG_UNPARSED_ARGUMENTS} )
if( ARG_LINK_LIBRARIES )
target_link_libraries( ${exe_name} PRIVATE ${ARG_LINK_LIBRARIES} )
endif()
# Create the executable.
set( exe_name "actsvg_${name}" )
add_executable( ${exe_name} ${ARG_UNPARSED_ARGUMENTS} )
if( ARG_LINK_LIBRARIES )
target_link_libraries( ${exe_name} PRIVATE ${ARG_LINK_LIBRARIES} )
endif()

endfunction( actsvg_add_executable )

Expand All @@ -64,22 +69,22 @@ endfunction( actsvg_add_executable )
#
function( actsvg_add_test name )

# Parse the function's options.
cmake_parse_arguments( ARG "" "" "LINK_LIBRARIES" ${ARGN} )
# Parse the function's options.
cmake_parse_arguments( ARG "" "" "LINK_LIBRARIES" ${ARGN} )

# Create the test executable.
set( test_exe_name "actsvg_test_${name}" )
add_executable( ${test_exe_name} ${ARG_UNPARSED_ARGUMENTS} )
if( ARG_LINK_LIBRARIES )
target_link_libraries( ${test_exe_name} PRIVATE ${ARG_LINK_LIBRARIES} )
endif()
# Create the test executable.
set( test_exe_name "actsvg_test_${name}" )
add_executable( ${test_exe_name} ${ARG_UNPARSED_ARGUMENTS} )
if( ARG_LINK_LIBRARIES )
target_link_libraries( ${test_exe_name} PRIVATE ${ARG_LINK_LIBRARIES} )
endif()

# Run the executable as the test.
add_test( NAME ${test_exe_name}
# Run the executable as the test.
add_test( NAME ${test_exe_name}
COMMAND ${test_exe_name} )

# Set all properties for the test.
set_tests_properties( ${test_exe_name} PROPERTIES
# Set all properties for the test.
set_tests_properties( ${test_exe_name} PROPERTIES
ENVIRONMENT actsvg_TEST_DATA_DIR=${PROJECT_SOURCE_DIR}/data/ )

endfunction( actsvg_add_test )
10 changes: 10 additions & 0 deletions core/include/actsvg/core/defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include <array>
#include <cmath>
#include <string>

namespace actsvg {
Expand All @@ -26,6 +27,15 @@ const std::string __d = ".";
/// @todo make configurable via compile time
using scalar = float;

scalar constexpr operator""_scalar(long double v) {
return static_cast<scalar>(v);
}
scalar constexpr operator""_scalar(unsigned long long v) {
return static_cast<scalar>(v);
}

static constexpr scalar pi = static_cast<scalar>(M_PI);

using point2 = std::array<scalar, 2>;

} // namespace actsvg
2 changes: 1 addition & 1 deletion core/include/actsvg/core/style.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ struct font {

unsigned int _size = 12;

scalar _line_spacing = 1.4;
scalar _line_spacing = 1.4f;

std::string _style = "";

Expand Down
4 changes: 2 additions & 2 deletions core/include/actsvg/core/views.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ struct z_phi {
((*max_phi) - (*min_phi)) > M_PI) {
for (auto &cv : c) {
if (cv[1] < 0.) {
cv[1] += 2 * M_PI;
cv[1] += 2_scalar * pi;
}
}
}
Expand Down Expand Up @@ -276,7 +276,7 @@ struct z_rphi {
r = std::sqrt(point_[0] * point_[0] + point_[1] * point_[1]);
}
scalar phi = std::atan2(point_[1], point_[0]);
return point2{point_[2], r * phi};
return point2{static_cast<float>(point_[2]), r * phi};
}

/** A z-rphi view operator
Expand Down
Loading

0 comments on commit 3147683

Please sign in to comment.