Skip to content

Commit

Permalink
Merge pull request #2 from CodeWithKyrian/main
Browse files Browse the repository at this point in the history
Fix Compilation of Separate Libraries for OpenMP and Serial Modes on macOS
  • Loading branch information
yuichiis authored Apr 29, 2024
2 parents 5495d6f + 5ef7542 commit a340693
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Download source code from release and extract

### Build and Install on MacOS

Build with cmake.
Install openmp library with brew before build with cmake.

```shell
$ cd \path\to\here
Expand Down
21 changes: 4 additions & 17 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,18 @@ add_library(rindowmatlib SHARED ${srcfiles})
target_compile_options(rindowmatlib PRIVATE -DRINDOW_COMPILING_DLL)
if (MSVC)
target_compile_options(rindowmatlib PRIVATE /openmp:experimental)

elseif(APPLE)
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(OpenMP_C "${CMAKE_C_COMPILER}" CACHE STRING "" FORCE)
set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument" CACHE STRING "" FORCE)
set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5" CACHE STRING "" FORCE)
set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES} CACHE STRING "" FORCE)
set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES} CACHE STRING "" FORCE)
set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES} CACHE STRING "" FORCE)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(OpenMP_CXX "${CMAKE_CXX_COMPILER}" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument" CACHE STRING "" FORCE)
set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp5" CACHE STRING "" FORCE)
set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES} CACHE STRING "" FORCE)
set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES} CACHE STRING "" FORCE)
set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES} CACHE STRING "" FORCE)
find_package(OpenMP REQUIRED)
if(OpenMP_FOUND)
target_link_libraries(rindowmatlib PRIVATE OpenMP::OpenMP_C)
endif()

elseif(UNIX)
find_package(OpenMP REQUIRED)
if(OpenMP_FOUND)
target_link_libraries(rindowmatlib PRIVATE OpenMP::OpenMP_C)
endif()
endif()

target_include_directories(rindowmatlib PUBLIC "${PROJECT_SOURCE_DIR}/include")
target_include_directories(rindowmatlib PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")

Expand Down

0 comments on commit a340693

Please sign in to comment.