Commit c2e031eb authored by Guillaume Pasero's avatar Guillaume Pasero

COMP: handle Shark dependency to openmp using REQUIRED_FLAGS

parent 7b360b86
......@@ -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()
......
......@@ -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