View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013895CMakeDocumentationpublic2013-02-07 05:582013-07-01 09:37
ReporterSylwester Arabas 
Assigned ToRolf Eike Beer 
PrioritynormalSeverityminorReproducibilityN/A
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake 2.8.10.2 
Target VersionCMake 2.8.11Fixed in VersionCMake 2.8.11 
Summary0013895: CMake docs: suggestion for impovement in OpenMP section
DescriptionThe CMake FindOpenMP docs say that "If the compiler supports OpenMP, the flags required to compile with openmp support are set." This might be misleading as these flags are not set for any targets, but instead some variables with these flags inside are made available to the user.

Furthermore, it might be worth to mention how to use these variables, e.g.:

if (OPENMP_FOUND)
  set_target_properties(... PROPERTIES LINK_FLAGS ${OpenMP_CXX_FLAGS})
  set_target_properties(... PROPERTIES COMPILE_FLAGS ${OpenMP_CXX_FLAGS})
endif()

HTH,
Sylwester
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0032209)
Sylwester Arabas (reporter)
2013-02-07 09:11

Apparently, this would be more correct?:

if(OPENMP_FOUND)
  get_target_property(flags ... LINK_FLAGS)
  set_target_properties(... PROPERTIES LINK_FLAGS "${flags} ${OpenMP_CXX_FLAGS}")
  get_target_property(flags ... COMPILE_FLAGS)
  set_target_properties(... PROPERTIES COMPILE_FLAGS "${flags} ${OpenMP_CXX_FLAGS}")
endif()
(0032210)
Sylwester Arabas (reporter)
2013-02-07 09:19

And this would be even more correct probably (please confirm):

if(OPENMP_FOUND)
  get_target_property(flags ... LINK_FLAGS)
  if (${flags} STREQUAL "flags-NOTFOUND")
    set(flags "")
  endif()
  set_target_properties(... PROPERTIES LINK_FLAGS "${flags} ${OpenMP_CXX_FLAGS}")
  
  get_target_property(flags ... COMPILE_FLAGS)
  if (${flags} STREQUAL "flags-NOTFOUND")
    set(flags "")
  endif()
  set_target_properties(... PROPERTIES COMPILE_FLAGS "${flags} ${OpenMP_CXX_FLAGS}")
endif()

BTW, get_target_property() docs say that "If the property is not found, VAR will be set to "NOTFOUND".". Apparently the value is then "varname-NOTFOUND"?
(0032213)
Rolf Eike Beer (developer)
2013-02-07 14:56

I would change that sentence to:

"If the compiler supports OpenMP, the flags required to compile with OpenMP support are returned in variables for the different languages. The variables may be empty if the compiler does not need a special flag to support OpenMP."

I would not document there how to set these flags, this does belong in the common documentation and is nothing special to this module.
(0032215)
Sylwester Arabas (reporter)
2013-02-07 16:06

Perhaps it's then worth mentioning at least that it's not only the compiler but also the linker that might need these flags. In case of GCC -fopenmp is needed at both stages as otherwise either _OPENMP is not defined or the libgomp library is not linked.

BTW, what about OpenMP_Fortran_FLAGS?

HTH,
Sylwester
(0032216)
Rolf Eike Beer (developer)
2013-02-07 16:19

If you add it to CMAKE_*_FLAGS* it will added to the linker flags automatically.

And once you come up with a test compile file for Fortran it will get added.
(0032265)
Rolf Eike Beer (developer)
2013-02-13 13:39

Fix merged to next:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=77fd5e51ab40865df240d52862baa7212443bdd9 [^]
(0033422)
Robert Maynard (manager)
2013-07-01 09:37

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2013-02-07 05:58 Sylwester Arabas New Issue
2013-02-07 08:18 Brad King Assigned To => Rolf Eike Beer
2013-02-07 08:18 Brad King Status new => assigned
2013-02-07 09:11 Sylwester Arabas Note Added: 0032209
2013-02-07 09:19 Sylwester Arabas Note Added: 0032210
2013-02-07 14:56 Rolf Eike Beer Note Added: 0032213
2013-02-07 16:06 Sylwester Arabas Note Added: 0032215
2013-02-07 16:19 Rolf Eike Beer Note Added: 0032216
2013-02-13 13:39 Rolf Eike Beer Note Added: 0032265
2013-02-13 13:39 Rolf Eike Beer Status assigned => resolved
2013-02-13 13:39 Rolf Eike Beer Resolution open => fixed
2013-02-13 13:39 Rolf Eike Beer Fixed in Version => CMake 2.8.11
2013-02-13 13:39 Rolf Eike Beer Target Version => CMake 2.8.11
2013-02-14 09:13 Julien Finet Relationship added child of 0013873
2013-02-14 10:48 Julien Finet Relationship deleted child of 0013873
2013-07-01 09:37 Robert Maynard Note Added: 0033422
2013-07-01 09:37 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team