OpenMP
OpenMP support was drastically improved in CMake 3.9+. The Modern(TM) way to add OpenMP to a target is:
This not only is cleaner than the old method, it will also correctly set the library link line differently from the compile line if needed. In CMake 3.12+, this will even support OpenMP on macOS (if the library is available, such as with brew install libomp
). However, if you need to support older CMake, the following works on CMake 3.1+:
Warning: CMake < 3.4 has a bug in the Threads package that requires you to have the C
language enabled.
Last updated