Commit 054aeb7c authored by Guillaume Pasero's avatar Guillaume Pasero

Merge branch 'fix_openmp_activation' into 'release-6.6'

COMP: handle Shark dependency to openmp using REQUIRED_FLAGS

See merge request !135
parents 7b360b86 f903ded2
......@@ -97,11 +97,24 @@ if(SHARK_CONFIG_FILE)
"${SHARK_VERSION_MAJOR}.${SHARK_VERSION_MINOR}.${SHARK_VERSION_PATCH}")
endif()
# reset required flags
set(SHARK_REQUIRED_C_FLAGS "")
set(SHARK_REQUIRED_CXX_FLAGS "")
set(SHARK_REQUIRED_LINK_FLAGS "")
# Check if Shark was built with OpenMP, CBLAS, DYNLIB, ...
file(STRINGS "${SHARK_INCLUDE_DIR}/shark/Core/Shark.h" SHARK_H_CONTENTS)
if(SHARK_H_CONTENTS MATCHES "#define.SHARK_USE_OPENMP")
set(SHARK_USE_OPENMP 1)
find_package(OpenMP QUIET)
if(OPENMP_FOUND)
set(SHARK_REQUIRED_C_FLAGS "${SHARK_REQUIRED_C_FLAGS} ${OpenMP_C_FLAGS}")
set(SHARK_REQUIRED_CXX_FLAGS "${SHARK_REQUIRED_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
if(OpenMP_EXE_LINKER_FLAGS)
set(SHARK_REQUIRED_LINK_FLAGS "${SHARK_REQUIRED_LINK_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
endif()
else()
set(SHARK_USE_OPENMP 0)
endif()
......
......@@ -233,7 +233,14 @@ endif()
option(OTB_USE_DEPRECATED "Turn on the use and test of deprecated classes" OFF)
mark_as_advanced(OTB_USE_DEPRECATED)
# Although the OpenMP option looks like a 3rd party module, it is NOT. This option
# is handled with other compilation flags in file OTBSetStandardCompilerFlags.cmake
# before any module is parsed or enabled (see OTBModuleEnablement.cmake later on
# during configure). Trying to modify this option from any module is
# useless. Any 3rd party module dragging OpenMP should append
# the corresponding flags to CMAKE_CXX_FLAGS, CMAKE_EXE_LINKER_FLAGS, and so on.
option(OTB_USE_OPENMP "Add openmp compiler and linker flags" OFF)
option(OTB_USE_SSE_FLAGS "Enable SIMD optimizations (hardware dependent)." ON)
include(OTBSetStandardCompilerFlags)
......
......@@ -22,8 +22,13 @@ find_package ( Shark REQUIRED )
if ( SHARK_USE_OPENMP AND NOT OTB_USE_OPENMP )
message(WARNING "Shark library is built with OpenMP and you have OTB_USE_OPENMP set to OFF.\
It will be turned to ON to allow compilation.")
set( OTB_USE_OPENMP "ON" CACHE BOOL "Add openmp compiler and linker flags" FORCE )
It will be enabled anyway to allow compilation.")
endif()
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SHARK_REQUIRED_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SHARK_REQUIRED_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SHARK_REQUIRED_LINK_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SHARK_REQUIRED_LINK_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SHARK_REQUIRED_LINK_FLAGS}")
mark_as_advanced( Shark_DIR )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment