Skip to content

Commit

Permalink
modernize cmake #1
Browse files Browse the repository at this point in the history
- enable testing at toplevel
- remove googletest clone from workflow( simplification)
- detect eigen3 locally

/cc @bab2min
  • Loading branch information
prudhomm committed Jul 8, 2023
1 parent c41d8c1 commit 23de6ba
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/pull_request_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
eigenversion: [3.3.4, 3.3.5, 3.3.6, 3.3.7, 3.3.8, 3.3.9, 3.4.0]
os: [ubuntu-18.04]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install dependencies
run: |
git clone https://gitlab.com/libeigen/eigen
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
eigenversion: [3.4.0]
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install dependencies
run: |
git clone https://gitlab.com/libeigen/eigen
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
arch: [DEIGEN_DONT_VECTORIZE, msse2, mssse3, mavx]
eigenversion: [3.3.4, 3.3.5, 3.3.6, 3.3.7, 3.3.8, 3.3.9, 3.4.0]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install dependencies
run: |
wget https://gitlab.com/libeigen/eigen/-/archive/${{ matrix.eigenversion }}/eigen-${{ matrix.eigenversion }}.tar.gz
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
arch: ['/D EIGEN_DONT_VECTORIZE', '/arch:SSE2', '/arch:AVX', '/arch:AVX2']
eigenversion: [3.3.4, 3.3.5, 3.3.6, 3.3.7, 3.3.8, 3.3.9, 3.4.0]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install dependencies
run: |
Invoke-WebRequest -OutFile eigen.tar.gz https://gitlab.com/libeigen/eigen/-/archive/${{ matrix.eigenversion }}/eigen-${{ matrix.eigenversion }}.tar.gz
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
arch: ['/arch:AVX512']
eigenversion: [3.4.0]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install dependencies
run: |
Invoke-WebRequest -OutFile eigen.tar.gz https://gitlab.com/libeigen/eigen/-/archive/${{ matrix.eigenversion }}/eigen-${{ matrix.eigenversion }}.tar.gz
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
matrix:
os: [ubuntu-18.04, macOS-10.15, windows-2019]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Set up Python3
uses: actions/setup-python@v1
with:
Expand Down
28 changes: 6 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@ jobs:
matrix:
arch: [DEIGEN_DONT_VECTORIZE, msse2, mavx, mavx2]
eigenversion: [3.3.4, 3.3.5, 3.3.6, 3.3.7, 3.3.8, 3.3.9, 3.4.0]
os: [ubuntu-18.04]
os: [ubuntu-18.04,ubuntu-20.04,ubuntu-22.04]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install dependencies
run: |
git clone https://gitlab.com/libeigen/eigen
pushd eigen
git checkout tags/${{ matrix.eigenversion }}
popd
mv eigen include
git clone https://github.com/google/googletest
pushd googletest
git checkout v1.8.x
popd
- name: Build
run: |
export EIGEN_PATH=`pwd`/include
Expand Down Expand Up @@ -68,16 +64,12 @@ jobs:
arch: [DEIGEN_DONT_VECTORIZE, msse2, mavx]
eigenversion: [3.3.4, 3.3.5, 3.3.6, 3.3.7, 3.3.8, 3.3.9, 3.4.0]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install dependencies
run: |
wget https://gitlab.com/libeigen/eigen/-/archive/${{ matrix.eigenversion }}/eigen-${{ matrix.eigenversion }}.tar.gz
tar -zxvf eigen-${{ matrix.eigenversion }}.tar.gz
mv eigen-${{ matrix.eigenversion }} include
git clone https://github.com/google/googletest
pushd googletest
git checkout v1.8.x
popd
- name: Build
run: |
export EIGEN_PATH=`pwd`/include
Expand Down Expand Up @@ -120,17 +112,13 @@ jobs:
arch: ['/D EIGEN_DONT_VECTORIZE', '/arch:SSE2', '/arch:AVX', '/arch:AVX2']
eigenversion: [3.3.4, 3.3.5, 3.3.6, 3.3.7, 3.3.8, 3.3.9, 3.4.0]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install dependencies
run: |
Invoke-WebRequest -OutFile eigen.tar.gz https://gitlab.com/libeigen/eigen/-/archive/${{ matrix.eigenversion }}/eigen-${{ matrix.eigenversion }}.tar.gz
tar -zxvf eigen.tar.gz
mv eigen-${{ matrix.eigenversion }} include
echo "EIGEN_PATH=$(Get-Location)\include" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
git clone https://github.com/google/googletest
pushd googletest
git checkout v1.8.x
popd
- name: Build
uses: lukka/run-cmake@v3
with:
Expand Down Expand Up @@ -167,15 +155,15 @@ jobs:
build-arm64:
name: Build for Arm64-Centos7
runs-on: ubuntu-18.04
runs-on: [ubuntu-18.04,ubuntu-20.04,ubuntu-22.04]
strategy:
max-parallel: 4
matrix:
arch: [DEIGEN_DONT_VECTORIZE, march=native]
eigenversion: [3.3.4, 3.3.5, 3.3.6, 3.3.7, 3.3.8, 3.3.9, 3.4.0]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
with:
submodules: true
- uses: bab2min/run-on-arch-action@use-custom-image
Expand All @@ -192,10 +180,6 @@ jobs:
pushd eigen
git checkout tags/${{ matrix.eigenversion }}
popd
git clone https://github.com/google/googletest
pushd googletest
git checkout v1.8.x
popd
mv eigen include
export EIGEN_PATH=`pwd`/include
mkdir build && cd build
Expand Down
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,22 @@ set ( CMAKE_VERBOSE_MAKEFILE ${EIGENRAND_CMAKE_VERBOSE} )
set ( ADDITIONAL_FLAGS "${EIGENRAND_CXX_FLAGS}" )

if ( NOT TARGET Eigen3::Eigen )
message(STATUS "Eigen3 not available")
message(STATUS "Eigen3 not available from master project")
if ( EXISTS ${PROJECT_SOURCE_DIR}/include/Eigen )
# Set the path to the directory containing Eigen3
list(APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/include/Eigen")
message(STATUS "Eigen3 directory found locally in ${PROJECT_SOURCE_DIR}/include/Eigen")
endif()
find_package(Eigen3 REQUIRED)
# Check if Eigen3 is found
if(TARGET Eigen3::Eigen )
message(STATUS "Eigen3 found")
else()
message(FATAL_ERROR "Eigen3 not found")
endif()
endif()

# create interface lib for EigenRand to create the programming interface and propagating it simply using target_link_libraries
add_library(eigenrand INTERFACE)
target_link_libraries(eigenrand INTERFACE Eigen3::Eigen)

Expand Down Expand Up @@ -94,7 +107,8 @@ message(STATUS "FETCHCONTENT_SOURCE_DIR_GOOGLETEST: ${FETCHCONTENT_SOURCE_DIR_GO
FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest GIT_TAG v1.8.x)

if(EIGENRAND_BUILD_TEST)
FetchContent_MakeAvailable(googletest)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_subdirectory( test )
endif()

Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ endif()
# Just make the test runnable with
# $ make test

enable_testing()

add_test(EigenRand-test EigenRand-test)

0 comments on commit 23de6ba

Please sign in to comment.