Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add OS build matrix #81

Merged
merged 4 commits into from
Aug 14, 2024
Merged
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
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
42 changes: 23 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ project (actsvg VERSION 0.4.41 LANGUAGES CXX )
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")
set(ACTSVG_CXX_FLAGS "-Wall -Wextra -Wpedantic -Wshadow -Wzero-as-null-pointer-constant -Wold-style-cast -Wnull-dereference")

# 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
# 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")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
set(ACTSVG_CXX_FLAGS "${ACTSVG_CXX_FLAGS} -Wfloat-conversion")
endif()

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 )
Expand Down Expand Up @@ -45,19 +49,19 @@ add_subdirectory(core)

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

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


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

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

# Set up the test(s).
Expand All @@ -67,26 +71,26 @@ if( ACTSVG_BUILD_TESTING )
endif()

if (ACTSVG_BUILD_TESTING OR ACTSVG_BUILD_EXAMPLES)
# Set up GoogleTest.
option( ACTSVG_SETUP_GOOGLETEST
# Set up GoogleTest.
option( ACTSVG_SETUP_GOOGLETEST
"Set up the GoogleTest target(s) explicitly" TRUE )
option( ACTSVG_USE_SYSTEM_GOOGLETEST
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_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)
if(ACTSVG_USE_SYSTEM_PYBIND11)
find_package(pybind11 CONFIG REQUIRED)
else()
add_subdirectory(extern/pybind11)
Expand Down
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 )
2 changes: 1 addition & 1 deletion core/include/actsvg/core/views.hpp
Original file line number Diff line number Diff line change
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
9 changes: 3 additions & 6 deletions extern/googletest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required( VERSION 3.11 )
include( FetchContent )

# Tell the user what's happening.
Expand All @@ -9,23 +8,21 @@ set( ACTSVG_GOOGLETEST_SOURCE
"URL;https://github.com/google/googletest/archive/release-1.11.0.tar.gz;URL_MD5;e8a8df240b6938bb6384155d4c37d937"
CACHE STRING "Source for GoogleTest, when built as part of this project" )
mark_as_advanced( ACTSVG_GOOGLETEST_SOURCE )
FetchContent_Declare( GoogleTest ${ACTSVG_GOOGLETEST_SOURCE} )
FetchContent_Declare( GoogleTest "${ACTSVG_GOOGLETEST_SOURCE};EXCLUDE_FROM_ALL" )

# Options used in the build of GoogleTest.
set( BUILD_GMOCK TRUE CACHE BOOL "Turn off the build of GMock" )
set( INSTALL_GTEST FALSE CACHE BOOL "Turn off the installation of GoogleTest" )
if( WIN32 )
set( gtest_force_shared_crt TRUE CACHE BOOL
set( gtest_force_shared_crt TRUE CACHE BOOL
"Use shared (DLL) run-time library, even with static libraries" )
endif()

# Silence some warnings with modern versions of CMake on macOS.
set( CMAKE_MACOSX_RPATH TRUE )

# Get it into the current directory.
FetchContent_Populate( GoogleTest )
add_subdirectory( "${googletest_SOURCE_DIR}" "${googletest_BINARY_DIR}"
EXCLUDE_FROM_ALL )
FetchContent_MakeAvailable( GoogleTest )

# Set up aliases for the GTest targets with the same name that they have
# when we find GTest pre-installed.
Expand Down
Loading