diff --git a/.github/workflows/generate_docs.yml b/.github/workflows/generate_docs.yml
index 7af53d5..0a728fe 100644
--- a/.github/workflows/generate_docs.yml
+++ b/.github/workflows/generate_docs.yml
@@ -17,6 +17,7 @@ jobs:
with:
working-directory: './doxygen'
- name: gen doc
+ if: github.repository == 'bab2min/EigenRand'
run: |
export EIGENRAND_VER=${GITHUB_REF##*/}
mkdir -p ../g
diff --git a/.github/workflows/pull_request_test.yml b/.github/workflows/pull_request_test.yml
index ff99315..9bbac2c 100644
--- a/.github/workflows/pull_request_test.yml
+++ b/.github/workflows/pull_request_test.yml
@@ -8,15 +8,21 @@ on:
jobs:
build_linux:
name: Build for linux
+ if: "!contains(github.event.head_commit.message, '[skip linux]')"
runs-on: ${{ matrix.os }}
+ continue-on-error: true
strategy:
max-parallel: 4
+ fail-fast: false
matrix:
arch: [DEIGEN_DONT_VECTORIZE, msse2, mssse3, 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-22.04]
+
steps:
- - uses: actions/checkout@v1
+ - uses: actions/checkout@v3
+ with:
+ submodules: true
- name: Install dependencies
run: |
git clone https://gitlab.com/libeigen/eigen
@@ -24,35 +30,32 @@ jobs:
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
continue-on-error: true
run: |
- export EIGEN_PATH=`pwd`/include
- mkdir build && cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DEIGENRAND_CXX_FLAGS="-${{ matrix.arch }} -I${EIGEN_PATH}" ../
- make
- - name: Test
+ cmake --preset default -DEIGENRAND_CXX_FLAGS="-${{ matrix.arch }}"
+ cmake --build --preset default
+ ctest --preset default -N
+ - name: Tests
run: |
- ./build/test/EigenRand-test
- - name: Run Accuracy
- run: |
- ./build/EigenRand-accuracy
+ ctest --preset default -R test
+ ctest --preset default -R accuracy
build_linux_avx512:
name: Build for linux AVX512
+ if: "!contains(github.event.head_commit.message, '[skip avx]')"
runs-on: ${{ matrix.os }}
+ continue-on-error: true
strategy:
max-parallel: 4
matrix:
arch: [mavx512dq]
eigenversion: [3.4.0]
- os: [ubuntu-18.04]
+ os: [ubuntu-22.04]
steps:
- - uses: actions/checkout@v1
+ - uses: actions/checkout@v3
+ with:
+ submodules: true
- name: Install dependencies
run: |
git clone https://gitlab.com/libeigen/eigen
@@ -60,128 +63,108 @@ jobs:
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
+ continue-on-error: true
run: |
- export EIGEN_PATH=`pwd`/include
- mkdir build && cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DEIGENRAND_CXX_FLAGS="-${{ matrix.arch }} -mavx512f -mfma -I${EIGEN_PATH}" ../
- make
- - name: Test
- run: |
- ./build/test/EigenRand-test
- - name: Run Accuracy
+ cmake --preset default -DEIGENRAND_CXX_FLAGS="-${{ matrix.arch }}"
+ cmake --build --preset default
+ ctest --preset default -N
+ - name: Tests
run: |
- ./build/EigenRand-accuracy
+ ctest --preset default -R test
+ ctest --preset default -R accuracy
build_macos:
name: Build for macOS
- runs-on: macOS-10.15
+ if: "!contains(github.event.head_commit.message, '[skip macos]')"
+ runs-on: macOS-latest
+ continue-on-error: true
strategy:
max-parallel: 4
matrix:
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
+ with:
+ submodules: true
- 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
continue-on-error: true
run: |
- export EIGEN_PATH=`pwd`/include
- mkdir build && cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DEIGENRAND_CXX_FLAGS="-${{ matrix.arch }} -I${EIGEN_PATH}" ../
- make
- - name: Test
- run: |
- ./build/test/EigenRand-test
- - name: Run Accuracy
+ cmake --preset default -DEIGENRAND_CXX_FLAGS="-${{ matrix.arch }}"
+ cmake --build --preset default
+ ctest --preset default -N
+ - name: Tests
run: |
- ./build/EigenRand-accuracy
+ ctest --preset default -R test
+ ctest --preset default -R accuracy
build_windows:
name: Build for Windows
- runs-on: windows-2019
+ if: "!contains(github.event.head_commit.message, '[skip windows]')"
+ runs-on: windows-latest
+ continue-on-error: true
strategy:
max-parallel: 4
matrix:
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
+ with:
+ submodules: true
- 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
continue-on-error: true
- uses: lukka/run-cmake@v3
- with:
- cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
- cmakeBuildType: Release
- buildWithCMake: true
- cmakeAppendedArgs: -G"Visual Studio 16 2019" -Ax64 -DEIGENRAND_CXX_FLAGS="${{ matrix.arch }} /I${{ env.EIGEN_PATH }}"
- buildWithCMakeArgs: --config Release
- buildDirectory: build
- - name: Test
- run: |
- .\build\test\Release\EigenRand-test.exe
- - name: Run Accuracy
- run: |
- .\build\Release\EigenRand-accuracy.exe
+ run: |
+ cmake --preset windows -DEIGENRAND_CXX_FLAGS="${{ matrix.arch }}"
+ cmake --build --preset windows
+ ctest --preset windows -N
+ - name: Tests
+ run: |
+ ctest --preset windows -R test
+ ctest --preset windows -R accuracy
build_windows_avx512:
name: Build for Windows
- runs-on: windows-2019
+ if: "!contains(github.event.head_commit.message, '[skip windows-avx]')"
+ runs-on: windows-latest
+ continue-on-error: true
strategy:
max-parallel: 4
matrix:
- arch: ['/arch:AVX512']
+ arch: ['/arch:AVX512 /bigobj']
eigenversion: [3.4.0]
steps:
- - uses: actions/checkout@v1
+ - uses: actions/checkout@v3
+ with:
+ submodules: true
- 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:
- cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
- cmakeBuildType: Release
- buildWithCMake: true
- cmakeAppendedArgs: -G"Visual Studio 16 2019" -Ax64 -DEIGENRAND_CXX_FLAGS="${{ matrix.arch }} /I${{ env.EIGEN_PATH }}"
- buildWithCMakeArgs: --config Release
- buildDirectory: build
- - name: Test
- run: |
- .\build\test\Release\EigenRand-test.exe
- - name: Run Accuracy
- run: |
- .\build\Release\EigenRand-accuracy.exe
+ continue-on-error: true
+ run: |
+ cmake --preset windows -DEIGENRAND_CXX_FLAGS="${{ matrix.arch }}"
+ cmake --build --preset windows
+ ctest --preset windows -N
+ - name: Tests
+ run: |
+ ctest --preset windows -R test
+ ctest --preset windows -R accuracy
reference:
name: Reference
@@ -189,9 +172,11 @@ jobs:
strategy:
max-parallel: 4
matrix:
- os: [ubuntu-18.04, macOS-10.15, windows-2019]
+ os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- - uses: actions/checkout@v1
+ - uses: actions/checkout@v3
+ with:
+ submodules: true
- name: Set up Python3
uses: actions/setup-python@v1
with:
diff --git a/.github/workflows/pull_request_test_non_x64.yml b/.github/workflows/pull_request_test_non_x64.yml
index b2aeea2..5014b46 100644
--- a/.github/workflows/pull_request_test_non_x64.yml
+++ b/.github/workflows/pull_request_test_non_x64.yml
@@ -8,23 +8,22 @@ on:
jobs:
build_macos_aarch64:
name: Build for macOS aarch64
- runs-on: macOS-11
+ if: "!contains(github.event.head_commit.message, '[skip macos-aarch64]')"
+ runs-on: macOS-latest
strategy:
max-parallel: 4
matrix:
arch: [DEIGEN_DONT_VECTORIZE, DDUMMY]
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
- 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
@@ -40,7 +39,9 @@ jobs:
build-arm64:
name: Build for Arm64-Centos7
- runs-on: ubuntu-18.04
+ if: "!contains(github.event.head_commit.message, '[skip arm64]')"
+ runs-on: ubuntu-22.04
+ continue-on-error: true
strategy:
max-parallel: 4
matrix:
@@ -48,7 +49,7 @@ jobs:
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
@@ -65,14 +66,10 @@ 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
cmake -DCMAKE_BUILD_TYPE=Release -DEIGENRAND_CXX_FLAGS="-${{ matrix.arch }} -I${EIGEN_PATH}" ../
make
- ./test/EigenRand-test
- ./EigenRand-accuracy 256
+ ctest -R test
+ ctest -R accuracy
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 9619b9d..09c1a18 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -15,9 +15,9 @@ 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
@@ -25,10 +25,6 @@ jobs:
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
@@ -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
@@ -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:
@@ -167,7 +155,7 @@ 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:
@@ -175,7 +163,7 @@ jobs:
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
@@ -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
diff --git a/.gitignore b/.gitignore
index 1fa28c3..30aff5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,7 +21,7 @@ bld/
[Bb]in/
[Oo]bj/
[Ll]og/
-
+[Bb]uild/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..7e38e13
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "googletest"]
+ path = googletest
+ url = https://github.com/google/googletest
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2417191..799226c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,61 +2,175 @@ cmake_minimum_required(VERSION 3.9)
project(EigenRand VERSION 0.5.0 DESCRIPTION "EigenRand, Random Number Generator for Eigen")
+include(GNUInstallDirs)
+include(FetchContent)
+
option(EIGENRAND_BUILD_TEST "Build Test sets" ON)
-set ( CMAKE_CXX_STANDARD 11 )
-set ( CMAKE_VERBOSE_MAKEFILE true )
-set ( ADDITIONAL_FLAGS "${EIGENRAND_CXX_FLAGS}" )
+option(EIGENRAND_CMAKE_VERBOSE "Define flags for cmake verbosity" OFF)
+
+if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
+ message(STATUS "Building as a standalone project")
+ option(EIGENRAND_DEFINE_FLAGS "Define flags for EigenRand" ON)
+ set(EIGEN_SUBPROJECT OFF)
+else()
+ message(STATUS "Building as a sub-project")
+ option(EIGENRAND_DEFINE_FLAGS "Define flags for EigenRand" OFF)
+ set(EIGEN_SUBPROJECT ON)
+endif()
-if(MSVC)
- set ( CMAKE_C_FLAGS_DEBUG "-DDEBUG -DC_FLAGS -Zi -Od ${ADDITIONAL_FLAGS}" )
- set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" )
+if ( NOT CMAKE_CXX_STANDARD )
+ set ( CMAKE_CXX_STANDARD 11 )
+endif()
- set ( CMAKE_C_FLAGS_RELEASE "-DNDEBUG -DRELEASE -DC_FLAGS -O2 -Oi -Gy ${ADDITIONAL_FLAGS}" )
- set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" )
+set ( CMAKE_VERBOSE_MAKEFILE ${EIGENRAND_CMAKE_VERBOSE} )
- set ( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -Zi")
- set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
- set ( CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" )
-else()
- link_libraries ( pthread )
-
- set ( CMAKE_C_FLAGS_DEBUG "-DDEBUG -DC_FLAGS -g3 -O0 ${ADDITIONAL_FLAGS}" )
- set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" )
- set ( CMAKE_EXE_LINKER_FLAGS_DEBUG "-DDEBUG -DLINKER_FLAGS" )
-
- set ( CMAKE_C_FLAGS_RELEASE "-DNDEBUG -DRELEASE -DC_FLAGS -O3 ${ADDITIONAL_FLAGS}" )
- set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" )
- set ( CMAKE_EXE_LINKER_FLAGS_RELEASE "-DRELEASE -DLINKER_FLAGS" )
-
- set ( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g3")
- set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
- set ( CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" )
+set ( ADDITIONAL_FLAGS "${EIGENRAND_CXX_FLAGS}" )
+message(STATUS "ADDITIONAL_FLAGS: ${ADDITIONAL_FLAGS}")
+
+if ( NOT TARGET Eigen3::Eigen )
+ message(STATUS "Eigen3 not available from master project")
+ if ( EXISTS ${PROJECT_SOURCE_DIR}/include/Eigen )
+ # this is for the CI
+ include_directories(${PROJECT_SOURCE_DIR}/include)
+ add_library(Eigen INTERFACE)
+ add_library(Eigen3::Eigen ALIAS Eigen)
+ target_include_directories(Eigen INTERFACE ${PROJECT_SOURCE_DIR}/include)
+ else()
+ find_package(Eigen3)
+ # try harder to find Eigen3 using pkgconfig
+ if (NOT TARGET Eigen3::Eigen )
+ message(STATUS "Eigen3 not found with find_package(Eigen3), trying to find using pkgconfig")
+ find_package(PkgConfig REQUIRED)
+ pkg_search_module(Eigen3 REQUIRED eigen3)
+ endif()
+ endif()
+
+ # Check if Eigen3 is found
+ if(TARGET Eigen3::Eigen )
+ message(STATUS "Eigen3 found")
+ else()
+ message(FATAL_ERROR "Eigen3 not found")
+ endif()
endif()
-include_directories( ./ )
+# 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)
-add_executable( "${PROJECT_NAME}-benchmark"
- benchmark/benchmark.cpp
-)
+if ( EIGENRAND_DEFINE_FLAGS )
+ if(MSVC)
+ set ( CMAKE_C_FLAGS_DEBUG "-DDEBUG -DC_FLAGS -Zi -Od ${ADDITIONAL_FLAGS}" )
+ set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" )
-add_executable( "${PROJECT_NAME}-benchmark-mv"
- benchmark/benchmark_mv.cpp
-)
+ set ( CMAKE_C_FLAGS_RELEASE "-DNDEBUG -DRELEASE -DC_FLAGS -O2 -Oi -Gy ${ADDITIONAL_FLAGS}" )
+ set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" )
-add_executable( "${PROJECT_NAME}-benchmark-disc"
- benchmark/benchmark_disc.cpp
-)
+ set ( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -Zi")
+ set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
+ set ( CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" )
+ else()
+
-add_executable( "${PROJECT_NAME}-benchmark-vop"
- benchmark/benchmark_vectorize_over_params.cpp
+ set ( CMAKE_C_FLAGS_DEBUG "-DDEBUG -DC_FLAGS -g3 -O0 ${ADDITIONAL_FLAGS}" )
+ set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" )
+ set ( CMAKE_EXE_LINKER_FLAGS_DEBUG "-DDEBUG -DLINKER_FLAGS" )
+
+ set ( CMAKE_C_FLAGS_RELEASE "-DNDEBUG -DRELEASE -DC_FLAGS -O3 ${ADDITIONAL_FLAGS}" )
+ set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" )
+ set ( CMAKE_EXE_LINKER_FLAGS_RELEASE "-DRELEASE -DLINKER_FLAGS" )
+
+ set ( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g3")
+ set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
+ set ( CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" )
+ endif()
+endif(EIGENRAND_DEFINE_FLAGS)
+
+if ( UNIX )
+ target_link_libraries(eigenrand INTERFACE pthread)
+endif()
+message(STATUS "PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}")
+target_include_directories(eigenrand INTERFACE
+ $
+ $
+ $
)
+add_library(EigenRand::EigenRand ALIAS eigenrand)
-add_executable( "${PROJECT_NAME}-accuracy"
+set(ITEMS
+ benchmark/benchmark.cpp
+ benchmark/benchmark_mv.cpp
+ benchmark/benchmark_disc.cpp
+ benchmark/benchmark_vectorize_over_params.cpp
benchmark/accuracy.cpp
)
+foreach(app ${ITEMS})
+ get_filename_component(app_name ${app} NAME_WE)
+ add_executable(${PROJECT_NAME}-${app_name} ${app})
+ target_link_libraries(${PROJECT_NAME}-${app_name} PRIVATE eigenrand)
+ install(TARGETS ${PROJECT_NAME}-${app_name} DESTINATION bin)
+ add_test(NAME ${PROJECT_NAME}-${app_name} COMMAND ${PROJECT_NAME}-${app_name})
+endforeach()
+
+
+set(FETCHCONTENT_SOURCE_DIR_GOOGLETEST ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
+message(STATUS "FETCHCONTENT_SOURCE_DIR_GOOGLETEST: ${FETCHCONTENT_SOURCE_DIR_GOOGLETEST}")
+FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest GIT_TAG v1.8.x)
if(EIGENRAND_BUILD_TEST)
- add_subdirectory( googletest )
+ FetchContent_MakeAvailable(googletest)
+ if (NOT TARGET gtest)
+ message(STATUS FATAL_ERROR "gtest target not found, is there a problem with googltest?")
+ endif()
+ enable_testing()
add_subdirectory( test )
endif()
+
+
+install(DIRECTORY EigenRand DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(TARGETS eigenrand
+ EXPORT EigenRandTargets
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ RUNTIME DESTINATION bin
+ INCLUDES DESTINATION include
+)
+
+set(CPACK_PACKAGE_NAME "EigenRand-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}${EXTRA_VERSION}")
+set(CPACK_SOURCE_PACKAGE_FILE_NAME "EigenRand-${PROJECT_VERSION}${EXTRA_VERSION}")
+set(CPACK_PACKAGE_FILE_NAME "EigenRand-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}${EXTRA_VERSION}-${CMAKE_SYSTEM_NAME}")
+set(CPACK_PACKAGE_DIRECTORY "${PROJECT_BINARY_DIR}/")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "EigenRand - The Fastest C++11-compatible random distribution generator for Eigen")
+set(CPACK_PACKAGE_DESCRIPTION "EigenRand - The Fastest C++11-compatible random distribution generator for Eigen")
+set(CPACK_PACKAGE_VENDOR "bab2min")
+set(CPACK_PACKAGE_CONTACT "bab2min@gmail.com")
+set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
+set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
+
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
+ set(CPACK_GENERATOR "TGZ;DEB")
+else()
+ set(CPACK_GENERATOR "TGZ")
+endif()
+
+set(CPACK_SOURCE_GENERATOR "TGZ")
+
+set(CPACK_DEBIAN_PACKAGE_NAME "${PROJECT_NAME}")
+set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_CONTACT}")
+
+set(CPACK_DEBIAN_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
+set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}")
+set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
+set(CPACK_DEBIAN_PACKAGE_SECTION "science")
+set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${EXTRA_VERSION}")
+set(CPACK_DEBIAN_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
+
+
+set(CPACK_PACKAGE_IGNORE_FILES
+ "/\\\\.git/"
+ "/\\\\.gitignore"
+ "/build/"
+)
+# set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/debian/postinst")
+include(CPack)
diff --git a/CMakePresets.json b/CMakePresets.json
new file mode 100644
index 0000000..fc85a4a
--- /dev/null
+++ b/CMakePresets.json
@@ -0,0 +1,113 @@
+{
+ "version": 3,
+ "cmakeMinimumRequired": {
+ "major": 3,
+ "minor": 21,
+ "patch": 0
+ },
+ "configurePresets": [
+ {
+ "name": "default",
+ "displayName": "Default Config",
+ "description": "Default config",
+ "generator": "Unix Makefiles",
+ "binaryDir": "${sourceDir}/build/default",
+ "cacheVariables": {
+ "CMAKE_CXX_COMPILER": "clang++",
+ "CMAKE_C_COMPILER": "clang",
+ "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/default/install/",
+ "CMAKE_BUILD_TYPE": "Release"
+ },
+ "vendor": {
+ "example.com/ExampleIDE/1.0": {
+ "autoFormat": true
+ }
+ }
+ },
+ {
+ "name": "windows",
+ "displayName": "Windows 2022 Config",
+ "description": "Windows 2022 config",
+ "generator": "Visual Studio 17 2022",
+ "architecture": "x64",
+ "binaryDir": "${sourceDir}/build/windows",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Release"
+ },
+ "vendor": {
+ "example.com/ExampleIDE/1.0": {
+ "autoFormat": true
+ }
+ }
+ },
+ {
+ "name": "install-local",
+ "inherits": "default",
+ "displayName": "Build and Install system",
+ "description": "Build and Install in /usr/local",
+ "generator": "Unix Makefiles",
+ "binaryDir": "${sourceDir}/build/install-local",
+ "cacheVariables": {
+ "CMAKE_INSTALL_PREFIX": "/usr/local"
+ },
+ "vendor": {
+ "example.com/ExampleIDE/1.0": {
+ "autoFormat": true
+ }
+ }
+ }
+ ],
+ "buildPresets": [
+ {
+ "name": "default",
+ "configurePreset": "default",
+ "configuration": "Release",
+ "jobs": 2
+ },
+ {
+ "name": "windows",
+ "configurePreset": "windows",
+ "configuration": "Release",
+ "jobs": 2
+ },
+ {
+ "name": "install-local",
+ "configurePreset": "install-local",
+ "inherits": "default",
+ "targets": [
+ "all",
+ "install",
+ "package"
+ ]
+ }
+ ],
+ "testPresets": [
+ {
+ "name": "default",
+ "configurePreset": "default",
+ "configuration": "Release",
+ "output": {
+ "outputOnFailure": true
+ },
+ "execution": {
+ "jobs": 2,
+ "noTestsAction": "error",
+ "stopOnFailure": false,
+ "repeat": {
+ "mode": "until-pass",
+ "count": 3
+ }
+ }
+ },
+ {
+ "name": "windows",
+ "configurePreset": "windows",
+ "inherits": "default"
+ }
+ ],
+ "vendor": {
+ "example.com/ExampleIDE/1.0": {
+ "autoFormat": false
+ }
+ }
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index 660ac3a..a900d8d 100644
--- a/README.md
+++ b/README.md
@@ -46,6 +46,13 @@ You can specify additional compiler arguments including target machine options (
$ cmake -DCMAKE_BUILD_TYPE=Release -DEIGENRAND_CXX_FLAGS="-march=native" ..
```
+Alternatively cmake preset with cmake 3.21 or later can be used to compile EigenRand which also integrates nicely in VSCode
+```console
+cmake --preset default
+cmake --build --preset default
+ctest --preset default
+```
+
## Documentation
https://bab2min.github.io/eigenrand/
diff --git a/googletest b/googletest
new file mode 160000
index 0000000..dea0216
--- /dev/null
+++ b/googletest
@@ -0,0 +1 @@
+Subproject commit dea0216d0c6bc5e63cf5f6c8651cd268668032ec
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 6a39748..93c3b8b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -11,8 +11,7 @@ add_executable(EigenRand-test ${TEST_SRC})
# If used often, could be made a macro.
add_dependencies(EigenRand-test gtest)
-include_directories(googletest/include)
-target_link_libraries(EigenRand-test gtest_main gtest)
+target_link_libraries(EigenRand-test gtest_main gtest eigenrand)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_libraries(EigenRand-test -Wl,--whole-archive -lpthread -Wl,--no-whole-archive)
endif()
@@ -20,5 +19,6 @@ endif()
# Just make the test runnable with
# $ make test
-enable_testing()
+
add_test(EigenRand-test EigenRand-test)
+