Skip to content

Commit

Permalink
SAIL: Build our own OpenMP flags to use -openmp:llvm with MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
HappySeaFox committed Nov 8, 2023
1 parent 82dbb6d commit 342f481
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions cmake/sail_check_openmp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ function(sail_check_openmp)
find_package(OpenMP)

if (OpenMP_FOUND)
# Try to compile a sample program as some compilers may still
# fail to use OpenMP
if (MSVC)
set(SAIL_OPENMP_FLAGS "-openmp:llvm" CACHE INTERNAL "")
else()
set(SAIL_OPENMP_FLAGS ${OpenMP_C_FLAGS} CACHE INTERNAL "")
endif()

# Try to compile a sample program to make sure the compiler
# supports at least OpenMP 3.0 with unsigned integers in for loops.
#
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_FLAGS ${OpenMP_C_FLAGS})
set(CMAKE_REQUIRED_INCLUDES ${OpenMP_C_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${OpenMP_C_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS ${SAIL_OPENMP_FLAGS})

check_c_source_compiles(
"
Expand Down
6 changes: 3 additions & 3 deletions src/sail-manip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ endif()
#
target_include_directories(sail-manip PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)

target_link_libraries(sail-manip PUBLIC sail-common)

if (SAIL_HAVE_OPENMP)
target_link_libraries(sail-manip PRIVATE OpenMP::OpenMP_C)
target_compile_options(sail-manip PRIVATE ${SAIL_OPENMP_FLAGS})
endif()

target_link_libraries(sail-manip PUBLIC sail-common)

# pkg-config integration
#
get_target_property(VERSION sail-manip VERSION)
Expand Down

0 comments on commit 342f481

Please sign in to comment.