diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f6866f..18409b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,3 @@ -# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. -# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml name: CMake on multiple platforms on: @@ -16,33 +14,30 @@ jobs: # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. fail-fast: false - # Set up a matrix to run the following 3 configurations: - # 1. - # 2. - # 3. - # - # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-latest, windows-latest] + + # matrix of runs + environment: [ubuntu-gcc, ubuntu-clang, macos-apple, windows-msvc] build_type: [Release, Debug] - c_compiler: [gcc, clang, cl] + + # describe os and compiler per environment include: - - os: windows-latest - c_compiler: cl - cpp_compiler: cl - - os: ubuntu-latest + - environment: ubuntu-gcc + os: ubuntu-latest c_compiler: gcc cpp_compiler: g++ - - os: ubuntu-latest + - environment: ubuntu-clang + os: ubuntu-latest c_compiler: clang cpp_compiler: clang++ - exclude: - - os: windows-latest - c_compiler: gcc - - os: windows-latest - c_compiler: clang - - os: ubuntu-latest + - environment: macos-apple + os: macos-latest + c_compiler: cc + cpp_compiler: c++ + - environment: windows-msvc + os: windows-latest c_compiler: cl + cpp_compiler: cl steps: - uses: actions/checkout@v3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 46b219a..bbaa0da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(IDE_FOLDER "") # Declare project -project(${META_PROJECT_NAME} VERSION ${META_VERSION} DESCRIPTION ${META_PROJECT_DESCRIPTION} LANGUAGES C CXX) +project(${META_PROJECT_NAME} VERSION ${META_VERSION} DESCRIPTION ${META_PROJECT_DESCRIPTION} LANGUAGES CXX) # Set output directories set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) diff --git a/source/girgs/CMakeLists.txt b/source/girgs/CMakeLists.txt index 5a021d7..045793b 100644 --- a/source/girgs/CMakeLists.txt +++ b/source/girgs/CMakeLists.txt @@ -4,7 +4,28 @@ # # find_package(THIRDPARTY REQUIRED) -find_package(OpenMP REQUIRED) +find_package(OpenMP) + +# FindOpenMP.cmake does not reliably find a user installed openmp library for clang/llvm on +# both Linux- and macOS-systems (even for CMake Version >= 3.12). The following section +# manually sets the required fields for clang-like compiler. +if(NOT OpenMP_FOUND) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + # This will find default libomp-installations for homebrew/MacPorts + find_library(LIBOMP_PATH NAMES omp PATHS "/usr/local/opt/libomp/lib" "/opt/local/lib/libomp" "/opt/homebrew/opt/libomp/lib") + find_path(LIBOMP_INCLUDE NAMES omp.h PATHS "/usr/local/opt/libomp/include" "/opt/local/include/libomp" "/opt/homebrew/opt/libomp/include") + if(LIBOMP_PATH AND LIBOMP_INCLUDE) + set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I${LIBOMP_INCLUDE}" CACHE STRING "Manually set" FORCE) + set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "Manually set" FORCE) + set(OpenMP_omp_LIBRARY "${LIBOMP_PATH}" CACHE STRING "Manually set" FORCE) + endif() + endif() + + # After setting basic OpenMP-folders, run find_package again to set everything. Also acts as a final sanity check. + find_package(OpenMP REQUIRED) + message(STATUS "OMP lib found manually after CMake module failed") +endif() + # # Library name and options diff --git a/source/tests/girgs-test/Generator_test.cpp b/source/tests/girgs-test/Generator_test.cpp index 7e789f6..52ce2b2 100644 --- a/source/tests/girgs-test/Generator_test.cpp +++ b/source/tests/girgs-test/Generator_test.cpp @@ -219,7 +219,7 @@ TEST_F(Generator_test, testEstimation) observed_avg /= runs; // test the goodness of the estimation for weight scaling - EXPECT_LT(abs(desired_avg - observed_avg)/desired_avg, 0.05) << "estimated constant does not produce desired average degree"; + EXPECT_LT(abs(desired_avg - observed_avg)/desired_avg, 0.08) << "estimated constant does not produce desired average degree"; } } }