CMake: detect OpenMP and use if available.

This is a missing part of commit b4e1ce44.
pull/598/head^2
whitequark 2020-05-09 19:46:16 +00:00
parent b4e1ce44e8
commit 47e82798da
2 changed files with 9 additions and 0 deletions

View File

@ -96,6 +96,14 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "X8
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLOAT_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLOAT_FLAGS}")
endif() endif()
# We use OpenMP to speed up some geometric operations, but it's optional.
include(FindOpenMP)
if(OpenMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
else()
message(WARNING "OpenMP not found, geometric operations will be single-threaded")
endif()
if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif() endif()

View File

@ -224,6 +224,7 @@ add_dependencies(solvespace-core
q3d_header) q3d_header)
target_link_libraries(solvespace-core target_link_libraries(solvespace-core
${OpenMP_CXX_LIBRARIES}
dxfrw dxfrw
${util_LIBRARIES} ${util_LIBRARIES}
${ZLIB_LIBRARY} ${ZLIB_LIBRARY}