MantisBT - CMake | ||||||||||
View Issue Details | ||||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | |||||
0015392 | CMake | CMake | public | 2015-02-09 10:58 | 2016-06-10 14:31 | |||||
Reporter | Mathieu Malaterre | |||||||||
Assigned To | Kitware Robot | |||||||||
Priority | normal | Severity | minor | Reproducibility | have not tried | |||||
Status | closed | Resolution | moved | |||||||
Platform | OS | OS Version | ||||||||
Product Version | CMake 3.0.2 | |||||||||
Target Version | Fixed in Version | |||||||||
Summary | 0015392: Unclear documentation for module: FindOpenMP.cmake | |||||||||
Description | The FindOpenMP module states: [...] The following variables are set: OpenMP_C_FLAGS - flags to add to the C compiler for OpenMP support [...] Instead is should be stated that the OpenMP flags should be passed both to the C compiler and the linker. Eg, the following will not work (linker step will fail) cmake_minimum_required(VERSION 2.8) project(omp C) find_package(OpenMP REQUIRED) # OPENMP_FOUND # Not OK # pass OpenMP flag to C compiler (only) set_property(SOURCE tomp.c PROPERTY COMPILE_FLAGS ${OpenMP_C_FLAGS} ) # OK # pass OpenMP CFLAGS to C compiler and linker: # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") add_executable(tomp tomp.c) | |||||||||
Steps To Reproduce | $ cat CMakeLists.txt cmake_minimum_required(VERSION 2.8) project(omp C) find_package(OpenMP REQUIRED) # OPENMP_FOUND # Not OK # pass OpenMP flag to C compiler (only) set_property(SOURCE tomp.c PROPERTY COMPILE_FLAGS ${OpenMP_C_FLAGS} ) # OK # pass OpenMP CFLAGS to C compiler and linker: # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") add_executable(tomp tomp.c) $ cat tomp.c #include <math.h> int main() { const int size = 256; double table[size]; int n; #pragma omp parallel for for(n=0; n<size; ++n) table[n] = 0; return table[size-1]; } $ cmake . && make [...] Linking C executable tomp CMakeFiles/tomp.dir/tomp.c.o: In function `main': tomp.c:(.text+0x87): undefined reference to `GOMP_parallel_start' tomp.c:(.text+0x98): undefined reference to `GOMP_parallel_end' CMakeFiles/tomp.dir/tomp.c.o: In function `main._omp_fn.0': tomp.c:(.text+0xe3): undefined reference to `omp_get_num_threads' tomp.c:(.text+0xeb): undefined reference to `omp_get_thread_num' collect2: error: ld returned 1 exit status make[2]: *** [tomp] Error 1 make[1]: *** [CMakeFiles/tomp.dir/all] Error 2 make: *** [all] Error 2 | |||||||||
Additional Information | ||||||||||
Tags | No tags attached. | |||||||||
Relationships |
| |||||||||
Attached Files | ||||||||||
Issue History | ||||||||||
Date Modified | Username | Field | Change | |||||||
2015-02-09 10:58 | Mathieu Malaterre | New Issue | ||||||||
2015-02-10 09:01 | Brad King | Relationship added | related to 0015393 | |||||||
2016-06-10 14:29 | Kitware Robot | Note Added: 0042709 | ||||||||
2016-06-10 14:29 | Kitware Robot | Status | new => resolved | |||||||
2016-06-10 14:29 | Kitware Robot | Resolution | open => moved | |||||||
2016-06-10 14:29 | Kitware Robot | Assigned To | => Kitware Robot | |||||||
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Notes | |||||
|
|||||
|
|