From 7eba2d792ff9336617c229d07ef545dd0b5918b8 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Tue, 6 Feb 2018 16:52:33 +0000 Subject: compile with OpenMP works on Windows --- Core/CMakeLists.txt | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index 070b45c..263b35c 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -33,7 +33,14 @@ if (Boost_FOUND) message("Boost library dir " ${Boost_LIBRARY_DIRS}) message("Boost libraries " ${Boost_LIBRARIES}) endif() - + +find_package(OpenMP) +if (OPENMP_FOUND) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") +endif() + ## Build the regularizers package as a library message("Creating Regularizers as shared library") @@ -42,7 +49,9 @@ message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}") set(CMAKE_BUILD_TYPE "Release") if(WIN32) - set (FLAGS "/DWIN32 /EHsc /DBOOST_ALL_NO_LIB /openmp /DCCPiCore_EXPORTS") + set (FLAGS "/DWIN32 /EHsc /DBOOST_ALL_NO_LIB /DCCPiCore_EXPORTS /openmp") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}") + set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}") set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT.lib") set (EXTRA_LIBRARIES @@ -53,7 +62,10 @@ if(WIN32) message("library lib: ${LIBRARY_LIB}") elseif(UNIX) - set (FLAGS "-fopenmp -O2 -funsigned-char -Wall -Wl,--no-undefined -DCCPiReconstructionIterative_EXPORTS -std=c++0x") + set (FLAGS "-O2 -funsigned-char -Wall -Wl,--no-undefined -DCCPiReconstructionIterative_EXPORTS -std=c++0x") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}") + set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}") + set (EXTRA_LIBRARIES ${Boost_LIBRARIES} #"tiff" @@ -61,6 +73,8 @@ elseif(UNIX) ) endif() +message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}") + ## Build the regularizers package as a library message("Adding regularizers as shared library") -- cgit v1.2.3