I am using CMake and GNU's parallel algorithms and the following code snippet in my CMakeLists.txt
:
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().
Does that make the following command redundant?
target_link_libraries(MyTarget OpenMP::OpenMP_CXX)?
I have tried to find the answer here but to no avail. Upon printing the output of the above variables using the message
command, I see that the last two are empty.
-- OpenMP_CXX_FLAGS are: -fopenmp-- OpenMP_C_FLAGS are: -Xclang -fopenmp -- CMAKE_EXE_LINKER_FLAGS are: -- OpenMP_EXE_LINKER_FLAGS are:
I tried looking up the variable definition here but did not find out anything more. A small test programme using:
__gnu_parallel::for_each
ran in parallel regardless whether I included:
target_link_libraries(MyTarget OpenMP::OpenMP_CXX)
which leads me to conclude that it is not necessary. Is that true?
My gcc
is g++-9 (Homebrew GCC 9.3.0_1) 9.3.0.
Thank you!