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

Fix Build #36

Merged
merged 5 commits into from
Nov 19, 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
112 changes: 47 additions & 65 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,69 @@ env:
CTEST_PARALLEL_LEVEL: 2

jobs:
####################
# Linux / macOS
####################

Unix:
Build:
name: ${{ matrix.name }} (${{ matrix.config }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
config: [Debug, Release]
include:
- os: macos-latest
name: macOS
- os: ubuntu-latest
name: Linux
- os: windows-latest
name: Windows
steps:
- name: Checkout repository
uses: actions/checkout@v2.5.0
uses: actions/checkout@v4.0.0
with:
fetch-depth: 10

- name: Dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install \
ccache \
xorg-dev \
libglu1-mesa-dev
sudo apt-get install ccache xorg-dev libglu1-mesa-dev
echo 'CACHE_PATH=~/.cache/ccache' >> "$GITHUB_ENV"

- name: Dependencies (macOS)
if: runner.os == 'macOS'
run: brew install ccache
run: |
brew install ccache
echo 'CACHE_PATH=~/Library/Caches/ccache' >> "$GITHUB_ENV"

- name: Dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install ccache
"CACHE_PATH=${env:LOCALAPPDATA}\ccache" | Out-File -FilePath $env:GITHUB_ENV -Append

# Install Ninja (only needed on Windows)
- name: Install Ninja
if: runner.os == 'Windows'
uses: seanmiddleditch/gha-setup-ninja@master

- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2.0.0
id: cpu-cores

- name: Cache Build
id: cache-build
uses: actions/cache@v1
uses: actions/cache@v4.0.2
with:
path: ~/.ccache
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-${{ matrix.config }}-cache

- name: Prepare ccache
run: |
ccache --max-size=1.0G
ccache -V && ccache --show-stats && ccache --zero-stats
ccache -V && ccache --show-config
ccache --show-stats && ccache --zero-stats

- name: Configure
- name: Configure (Linux/macOS)
if: runner.os != 'Windows'
run: |
mkdir -p build
cd build
Expand All @@ -70,61 +84,29 @@ jobs:
-DRIGID_IPC_WITH_UNIT_TESTS=ON \
-DCMAKE_BUILD_TYPE=${{ matrix.config }}

- name: Build
run: cd build; make -j2; ccache --show-stats

- name: Tests
run: cd build; ctest --verbose

####################
# Windows
####################

Windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
config: [Debug, Release]
steps:
- name: Checkout repository
uses: actions/checkout@v2.5.0
with:
fetch-depth: 10

- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master

- name: Set env variable for sccache
run: |
echo "appdata=$env:LOCALAPPDATA" >> ${env:GITHUB_ENV}

- name: Cache build
id: cache-build
uses: actions/cache@v3.0.11
with:
path: ${{ env.appdata }}\Mozilla\sccache
key: ${{ runner.os }}-${{ matrix.config }}-cache

- name: Prepare sccache
run: |
iwr -useb 'https://raw.githubusercontent.com/scoopinstaller/install/master/install.ps1' -outfile 'install.ps1'
.\install.ps1 -RunAsAdmin
scoop install sccache --global
# Scoop modifies the PATH so we make it available for the next steps of the job
echo "${env:PATH}" >> ${env:GITHUB_PATH}

- name: Configure and build
- name: Configure (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64
cmake -G Ninja ^
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache ^
-DCMAKE_BUILD_TYPE=${{ matrix.config }} ^
-DRIGID_IPC_WITH_UNIT_TESTS=ON ^
-B build ^
-S .
cmake --build build -j1

- name: Build (Linux/macOS)
if: runner.os != 'Windows'
run: |
cmake --build build -j ${{ steps.cpu-cores.outputs.count }}
ccache --show-stats

- name: Build (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64
cmake --build build -j ${{ steps.cpu-cores.outputs.count }} && ccache --show-stats

- name: Tests
run: cd build; ctest --verbose -j2
run: cd build; ctest --verbose -j ${{ steps.cpu-cores.outputs.count }}
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/rigid_ipc/")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/recipes/")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/find/")

include(rigid_ipc_cpm_cache)

# Color output
include(rigid_ipc_use_colors)

Expand Down
33 changes: 33 additions & 0 deletions cmake/recipes/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
set(CPM_DOWNLOAD_VERSION 0.40.2)

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

function(download_cpm)
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
/~https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endfunction()

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
download_cpm()
else()
# resume download if it previously failed
file(READ ${CPM_DOWNLOAD_LOCATION} check)
if("${check}" STREQUAL "")
download_cpm()
endif()
unset(check)
endif()

include(${CPM_DOWNLOAD_LOCATION})
67 changes: 52 additions & 15 deletions cmake/recipes/boost.cmake
Original file line number Diff line number Diff line change
@@ -1,29 +1,66 @@
#
# Copyright 2021 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
if(TARGET Boost::boost)
return()
endif()

message(STATUS "Third-party: creating targets 'Boost::boost'")

include(FetchContent)
FetchContent_Declare(
boost-cmake
GIT_REPOSITORY /~https://github.com/Orphis/boost-cmake.git
GIT_TAG 7f97a08b64bd5d2e53e932ddf80c40544cf45edf
)

set(PREVIOUS_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(OLD_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# This guy will download boost using FetchContent
FetchContent_GetProperties(boost-cmake)
if(NOT boost-cmake_POPULATED)
FetchContent_Populate(boost-cmake)
# File lcid.cpp from Boost_locale.cpp doesn't compile on MSVC, so we exclude them from the default
# targets being built by the project (only targets explicitly used by other targets will be built).
add_subdirectory(${boost-cmake_SOURCE_DIR} ${boost-cmake_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
set(BOOST_URL "https://boostorg.jfrog.io/artifactory/main/release/1.86.0/source/boost_1_86_0.tar.bz2" CACHE STRING "Boost download URL")
set(BOOST_URL_SHA256 "1bed88e40401b2cb7a1f76d4bab499e352fa4d0c5f31c0dbae64e24d34d7513b" CACHE STRING "Boost download URL SHA256 checksum")

include(CPM)
CPMAddPackage(
NAME boost
URL ${BOOST_URL}
URL_HASH SHA256=${BOOST_URL_SHA256}
DOWNLOAD_ONLY ON
)
set(BOOST_SOURCE ${boost_SOURCE_DIR})
set(Boost_POPULATED ON)

# Only build the following Boost libs
set(BOOST_LIBS_OPTIONAL "" CACHE STRING "Boost libs to be compiled" FORCE)

# File lcid.cpp from Boost_locale.cpp doesn't compile on MSVC, so we exclude them from the default
# targets being built by the project (only targets explicitly used by other targets will be built).
CPMAddPackage(
NAME boost-cmake
GITHUB_REPOSITORY Orphis/boost-cmake
GIT_TAG 7f97a08b64bd5d2e53e932ddf80c40544cf45edf
EXCLUDE_FROM_ALL
)

set(CMAKE_POSITION_INDEPENDENT_CODE ${OLD_CMAKE_POSITION_INDEPENDENT_CODE})
set(CMAKE_CXX_FLAGS "${PREVIOUS_CMAKE_CXX_FLAGS}")

foreach(name IN ITEMS
atomic
chrono
container
date_time
filesystem
iostreams
log
system
thread
timer
)
if(TARGET Boost_${name})
set_target_properties(Boost_${name} PROPERTIES FOLDER third_party/boost)
endif()
endforeach()
26 changes: 5 additions & 21 deletions cmake/recipes/pybind11.cmake
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
#
# Copyright 2020 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
# pybind11 (/~https://github.com/pybind/pybind11)
# License: BSD-style
if(TARGET pybind11::pybind11)
return()
endif()

message(STATUS "Third-party: creating target 'pybind11::pybind11'")

include(FetchContent)
FetchContent_Declare(
pybind11
GIT_REPOSITORY /~https://github.com/pybind/pybind11.git
GIT_TAG v2.7.0
GIT_SHALLOW TRUE
)

if (POLICY CMP0094) # https://cmake.org/cmake/help/latest/policy/CMP0094.html
cmake_policy(SET CMP0094 NEW) # FindPython should return the first matching Python
endif ()
Expand All @@ -39,7 +22,8 @@ endif ()
# Pybind11 still uses the deprecated FindPythonInterp. So let's call CMake's
# new FindPython module and set PYTHON_EXECUTABLE for Pybind11 to pick up.
# This works well with conda environments.
find_package(Python REQUIRED COMPONENTS Interpreter Development)
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})

FetchContent_MakeAvailable(pybind11)
include(CPM)
CPMAddPackage("gh:pybind/pybind11@2.13.1")
24 changes: 24 additions & 0 deletions cmake/rigid_ipc/rigid_ipc_cpm_cache.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2021 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#

if(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_SOURCE_CACHE_DEFAULT $ENV{CPM_SOURCE_CACHE})
else()
# Set CPM cache folder if unset
file(REAL_PATH "~/.cache/CPM" CPM_SOURCE_CACHE_DEFAULT EXPAND_TILDE)
endif()

set(CPM_SOURCE_CACHE
${CPM_SOURCE_CACHE_DEFAULT}
CACHE PATH "Directory to download CPM dependencies"
)
message(STATUS "Using CPM cache folder: ${CPM_SOURCE_CACHE}")
21 changes: 3 additions & 18 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
cmake_minimum_required(VERSION 3.8)

###############################################################################
# Download pybind11
function(rigid_ipc_download_pybind11)
rigid_ipc_download_project(pybind11
GIT_REPOSITORY /~https://github.com/pybind/pybind11.git
GIT_TAG v2.6.2
)
endfunction()
# pybind11
include(pybind11)

if(NOT TARGET pybind11::module)
rigid_ipc_download_pybind11()
add_subdirectory(
${RIGID_IPC_EXTERNAL}/pybind11
${CMAKE_CURRENT_BINARY_DIR}/pybind11)
endif()

###############################################################################
# Create Python module for Rigid IPC

pybind11_add_module(rigidipc src/bindings.cpp)
target_link_libraries(rigidipc PRIVATE ${PROJECT_NAME})
target_link_libraries(rigidipc PRIVATE ipc_rigid)
# set_target_properties(rigidipc PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
Loading