mirror of
https://github.com/Z3Prover/z3
synced 2025-06-06 22:23:22 +00:00
Merge pull request #1205 from delcypher/cmake_openmp_better_default
[CMake] Change how the default value of `USE_OPENMP` is set.
This commit is contained in:
commit
df18c3496a
1 changed files with 27 additions and 23 deletions
|
@ -281,18 +281,24 @@ endif()
|
||||||
################################################################################
|
################################################################################
|
||||||
# OpenMP support
|
# OpenMP support
|
||||||
################################################################################
|
################################################################################
|
||||||
option(USE_OPENMP "Use OpenMP" ON)
|
|
||||||
set(OPENMP_FOUND FALSE)
|
|
||||||
if (USE_OPENMP)
|
|
||||||
# Because this is on by default we make the configure succeed with a warning
|
|
||||||
# if OpenMP support is not detected.
|
|
||||||
find_package(OpenMP)
|
find_package(OpenMP)
|
||||||
if (NOT OPENMP_FOUND)
|
if (OPENMP_FOUND)
|
||||||
message(WARNING "OpenMP support was requested but your compiler doesn't support it")
|
set(USE_OPENMP_DEFAULT ON)
|
||||||
|
else()
|
||||||
|
set(USE_OPENMP_DEFAULT OFF)
|
||||||
endif()
|
endif()
|
||||||
|
# By setting `USE_OPENMP` this way configuration will fail during the first
|
||||||
|
# configure if the user explicitly passes `-DUSE_OPENMP=ON` and the compiler
|
||||||
|
# does not support OpenMP. However if the option is not set explicitly during
|
||||||
|
# the first configure OpenMP support will be automatically enabled/disabled
|
||||||
|
# depending on whether OpenMP is available.
|
||||||
|
option(USE_OPENMP "Use OpenMP" ${USE_OPENMP_DEFAULT})
|
||||||
|
|
||||||
|
if (USE_OPENMP)
|
||||||
|
if (NOT OPENMP_FOUND)
|
||||||
|
message(FATAL_ERROR "USE_OPENMP is ON but your compiler does not support OpenMP")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (OPENMP_FOUND)
|
|
||||||
list(APPEND Z3_COMPONENT_CXX_FLAGS ${OpenMP_CXX_FLAGS})
|
list(APPEND Z3_COMPONENT_CXX_FLAGS ${OpenMP_CXX_FLAGS})
|
||||||
# GCC and Clang need to have additional flags passed to the linker.
|
# GCC and Clang need to have additional flags passed to the linker.
|
||||||
# We can't do ``target_link_libraries(libz3 INTERFACE ${OpenMP_CXX_FLAGS})``
|
# We can't do ``target_link_libraries(libz3 INTERFACE ${OpenMP_CXX_FLAGS})``
|
||||||
|
@ -302,12 +308,10 @@ if (OPENMP_FOUND)
|
||||||
("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"))
|
("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"))
|
||||||
list(APPEND Z3_DEPENDENT_EXTRA_CXX_LINK_FLAGS ${OpenMP_CXX_FLAGS})
|
list(APPEND Z3_DEPENDENT_EXTRA_CXX_LINK_FLAGS ${OpenMP_CXX_FLAGS})
|
||||||
endif()
|
endif()
|
||||||
unset(CMAKE_REQUIRED_FLAGS)
|
|
||||||
message(STATUS "Using OpenMP")
|
message(STATUS "Using OpenMP")
|
||||||
else()
|
else()
|
||||||
list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_NO_OMP_")
|
list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_NO_OMP_")
|
||||||
message(STATUS "Not using OpenMP")
|
message(STATUS "Not using OpenMP")
|
||||||
set(USE_OPENMP OFF CACHE BOOL "Use OpenMP" FORCE)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue