Skip to content

Commit

Permalink
Merge pull request #418 from astro-informatics/chrisg_build_tweaks
Browse files Browse the repository at this point in the history
Clean-up dependencies
  • Loading branch information
mmcleod89 authored Oct 9, 2023
2 parents dfb7a27 + 25fbb20 commit d13aa42
Show file tree
Hide file tree
Showing 49 changed files with 479 additions and 327 deletions.
63 changes: 54 additions & 9 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ env:
CONAN_REVISIONS_ENABLED: 1
OMP_NUM_THREADS: 2
CONAN_CPU_COUNT: 2
USE_CONAN: 0

jobs:
make-documentation:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Check out sopt
uses: actions/checkout@v3
Expand All @@ -42,13 +43,25 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
sudo apt install openmpi-bin libopenmpi-dev libyaml-cpp-dev doxygen graphviz
sudo apt install openmpi-bin libopenmpi-dev libyaml-cpp-dev doxygen graphviz ccache
if [[ "$USE_CONAN" = 0 ]]; then
sudo apt install libeigen3-dev libspdlog-dev libtiff-dev
git clone https://github.com/catchorg/Catch2.git -b v3.4.0
mkdir Catch2/build
cd Catch2/build
cmake .. -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=${PWD}
make -j$(nproc --ignore 1)
make -j$(nproc --ignore 1) install
cd -
fi
- name: Install Conan
id: conan
if: env.USE_CONAN != '0'
uses: turtlebrowser/get-conan@main
with:
version: 1.59.0
version: 1.60.2
#version: 2.0.9

- name: Install Tensorflow API on Ubuntu
uses: UCL/install-tensorflow-action@main
Expand All @@ -64,20 +77,52 @@ jobs:
ref: master

- name: Create cppflow package
run: conan create ./cppflow/ -pr:h=default -pr:b=default
run: |
if [[ "$USE_CONAN" = 1 ]]; then
#conan profile detect
#sed -i'' -e "s|generators|#generators|1" ./cppflow/conanfile.py
conan create ./cppflow/ -pr:h=default -pr:b=default
else
mkdir cppflow/build
cd cppflow/build
cmake .. -DCMAKE_INSTALL_PREFIX=${PWD}
make -j$(nproc --ignore 1)
make -j$(nproc --ignore 1) install
fi
- name: Configure
run: |
conan install doxygen/1.9.4@#2af713e135f12722e3536808017ba086 --update
conan install ${{github.workspace}} -if ${{github.workspace}}/build --build missing -s compiler.libcxx=libstdc++11 -o mpi=off -o openmp=off -o docs=on -o cppflow=on -pr:h=default -pr:b=default
if [[ "$USE_CONAN" = 1 ]]; then
# Doxygen currently broken in Conan v1 and v2
#conan install doxygen/1.9.4@#2af713e135f12722e3536808017ba086 --update
conan install ${{github.workspace}} -if ${{github.workspace}}/build --build missing -s compiler.libcxx=libstdc++11 -o mpi=off -o openmp=off -o docs=off -o cppflow=on -pr:h=default -pr:b=default
else
export PATH=${{github.workspace}}/cppflow/build:$PATH
export PATH=${{github.workspace}}/Catch2/build:$PATH
export CMAKE_PREFIX_PATH=${{github.workspace}}/Catch2/build/lib/cmake/Catch2:$CMAKE_PREFIX_PATH
mkdir ${{github.workspace}}/build
cd ${{github.workspace}}/build
cmake .. -DCMAKE_INSTALL_PREFIX=${PWD} -Ddompi=OFF -Dopenmp=OFF -Ddocs=ON -Dcppflow=ON
fi
- name: Build
run: conan build ${{github.workspace}} -bf ${{github.workspace}}/build
run: |
if [[ "$USE_CONAN" = 1 ]]; then
conan build ${{github.workspace}} -bf ${{github.workspace}}/build
else
export PATH=${{github.workspace}}/cppflow/build:$PATH
export PATH=${{github.workspace}}/Catch2/build:$PATH
cd ${{github.workspace}}/build
make -j$(nproc --ignore 1)
make -j$(nproc --ignore 1) install
fi
- name: Make Docweb
run: |
cd build
make docweb VERBOSE=1
if [[ "$USE_CONAN" = 0 ]]; then
cd build
make docweb VERBOSE=1
fi
- name: Deploy to GH pages
if: ${{github.event_name == 'push'}}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ python/tests/__pycache__
*~

### CMake ###
CMakeUserPresets.json
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
Expand All @@ -93,6 +94,7 @@ install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
local

# CMake External projects (created by CMake fetchcontent module)
*-prefix/
Expand Down Expand Up @@ -129,4 +131,4 @@ _deps
# Executables
*.exe
*.out
*.app
*.app
45 changes: 32 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed!\nCreate a \"build\" dir and remove:\n- ${CMAKE_SOURCE_DIR}/CMakeCache.txt\n- ${CMAKE_SOURCE_DIR}/CMakeFiles")
endif()

project(Sopt
project(sopt
DESCRIPTION "Sparse OPTimisation using state-of-the-art convex optimisation algorithms."
HOMEPAGE_URL "http://astro-informatics.github.io/sopt/"
LANGUAGES CXX)
Expand All @@ -28,14 +28,33 @@ execute_process(
# Location of extra cmake includes for the project
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_files)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/build)
# Downloads and installs GreatCMakeCookOff
# It contains a number of cmake recipes
include(LookUp-GreatCMakeCookOff)

# Version and git hash id
include(VersionAndGitRef)
set_version(3.1.0)
get_gitref()
find_package(Git)

# Set version variable
set(SOPT_VERSION 3.1.0)

# If git is found and this is a git workdir, then figure out build id
# Stores results in SOPT_VERSION and SOPT_GITREF
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
RESULT_VARIABLE HASH_RESULT
OUTPUT_VARIABLE GIT_HASH
ERROR_QUIET
)
if(HASH_RESULT EQUAL 0)
string(STRIP "${GIT_HASH}" GIT_HASH)
else()
set(GIT_HASH "NA")
endif()
else()
set(GIT_HASH "NA")
endif()

set(SOPT_GITREF ${GIT_HASH})


option(tests "Enable testing" on)
option(benchmarks "Enable benchmarking" off)
Expand All @@ -53,7 +72,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
message(STATUS "Building sopt in ${CMAKE_BUILD_TYPE} mode")

if(tests)
if(tests OR examples)
enable_testing()
endif()

Expand All @@ -75,14 +94,11 @@ if(SOPT_MPI)
DetectIntegerArchitecture(SOPT)
endif()

if(tests OR examples)
enable_testing()
endif()

if(tests)
find_package(Catch)
find_package(Catch2)
include(AddCatchTest)
endif()

if(examples)
include(AddExample)
endif()
Expand All @@ -92,6 +108,8 @@ if(benchmarks)
include(AddBenchmark)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument")

if(tests AND coverage)
# Enable code coverage.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
Expand All @@ -107,3 +125,4 @@ add_subdirectory(cpp)

# Exports all Sopt so other packages can access it
include(export_sopt)

Loading

0 comments on commit d13aa42

Please sign in to comment.