MantisBT - CMake | |||||
| View Issue Details | |||||
| ID | Project | Category | View Status | Date Submitted | Last Update |
| 0007590 | CMake | Modules | public | 2008-09-02 07:21 | 2016-06-10 14:30 |
| Reporter | Mahendra Ladhe | ||||
| Assigned To | Kitware Robot | ||||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | moved | ||
| Platform | OS | OS Version | |||
| Product Version | CMake-2-6 | ||||
| Target Version | Fixed in Version | ||||
| Summary | 0007590: CHECK_C_COMPILER_FLAG macro not working for gcc's -fprofile-arcs flag | ||||
| Description | Hi, shown below is part of my CMakeLists.txt file. #To build the code for use with gcov, call cmake as below #cmake -DGCOV=1 .. IF (${GCOV}) CHECK_C_COMPILER_FLAG (-fprofile-arcs FLAG_Gcov1) IF (FLAG_Gcov1) add_definitions (-fprofile-arcs) ELSE (FLAG_Gcov1) MESSAGE(FATAL_ERROR "Compiler does not support the -fprofile-arcs flag needed for using gcov") ENDIF (FLAG_Gcov1) CHECK_C_COMPILER_FLAG (-ftest-coverage FLAG_Gcov2) IF (FLAG_Gcov2) add_definitions (-ftest-coverage) ELSE (FLAG_Gcov2) MESSAGE(FATAL_ERROR "Compiler does not support the -ftest-coverage flag needed for using gcov") ENDIF (FLAG_Gcov2) ENDIF (${GCOV}) I want to give user an option to compile the code for use with GCOV: the GNU code coverage tool. For this the code needs to be compiled with -fprofile-arcs and -ftest-coverage flags. When I invoke cmake as follows cmake -DGCOV=1 .. I get the following error CMake Error: Compiler does not support the -fprofile-arcs flag needed for using gcov Well, the gcc compiler on my Linux box does support -fprofile-arcs compilation flag. The CMakeFiles/CMakeError.log shows the cause of error. ========================================================================================= Performing C SOURCE FILE Test FLAG_Gcov1 failed with the following output: /usr/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build gmake[1]: Entering directory `/proj/magnum/mladhe/p4/L7/bld_x86/CMakeFiles/CMakeTmp' /home/srgorti/freeware/usr/bin/cmake -E cmake_progress_report /proj/magnum/mladhe/p4/L7/bld_x86/CMakeFiles/CMakeTmp/CMakeFiles 1 Building C object CMakeFiles/cmTryCompileExec.dir/src.o /usr/local/bin/gcc -DFLAG_Gcov1 -fprofile-arcs -o CMakeFiles/cmTryCompileExec.dir/src.o -c /proj/magnum/mladhe/p4/L7/bld_x86/CMakeFiles/CMakeTmp/src.c Linking C executable cmTryCompileExec /home/srgorti/freeware/usr/bin/cmake -P CMakeFiles/cmTryCompileExec.dir/cmake_clean_target.cmake /usr/local/bin/gcc -DFLAG_Gcov1 -fPIC "CMakeFiles/cmTryCompileExec.dir/src.o" -o cmTryCompileExec -rdynamic CMakeFiles/cmTryCompileExec.dir/src.o(.text+0x43): In function `global constructors keyed to 0_main': : undefined reference to `__gcov_init' CMakeFiles/cmTryCompileExec.dir/src.o(.data+0x24): undefined reference to `__gcov_merge_add' collect2: ld returned 1 exit status gmake[1]: *** [cmTryCompileExec] Error 1 gmake[1]: Leaving directory `/proj/magnum/mladhe/p4/L7/bld_x86/CMakeFiles/CMakeTmp' gmake: *** [cmTryCompileExec/fast] Error 2 Source file was: int main() { return 0;} ========================================================================================= So the reason is when source file is compiled with -fprofile-arcs, the cmake does not supply the same flag while linking which the gcc needs as the object module has certain gcov related code like functions gcov_init, gcov_merge_add etc. So the working of Check_C_Compiler_Flag macro needs enhancement to detect support for such kinds of compiler flags. | ||||
| Steps To Reproduce | |||||
| Additional Information | |||||
| Tags | No tags attached. | ||||
| Relationships | |||||
| Attached Files | |||||
| Issue History | |||||
| Date Modified | Username | Field | Change | ||
| 2008-09-02 07:21 | Mahendra Ladhe | New Issue | |||
| 2008-09-03 15:00 | Bill Hoffman | Note Added: 0013280 | |||
| 2008-09-03 15:00 | Bill Hoffman | Status | new => assigned | ||
| 2008-09-03 15:00 | Bill Hoffman | Assigned To | => Bill Hoffman | ||
| 2008-09-04 00:04 | Mahendra Ladhe | Note Added: 0013292 | |||
| 2008-09-09 14:12 | Bill Hoffman | Note Added: 0013384 | |||
| 2008-09-09 14:14 | Bill Hoffman | Note Added: 0013385 | |||
| 2008-09-11 04:24 | Mahendra Ladhe | Note Added: 0013406 | |||
| 2008-09-11 08:50 | Bill Hoffman | Note Added: 0013411 | |||
| 2008-09-15 23:10 | Mahendra Ladhe | Note Added: 0013478 | |||
| 2008-10-01 10:17 | Bill Hoffman | Note Added: 0013639 | |||
| 2008-10-01 10:18 | Bill Hoffman | Assigned To | Bill Hoffman => Alex Neundorf | ||
| 2010-08-29 10:23 | Kovarththanan Rajaratnam | Category | CMake => Modules | ||
| 2012-01-04 16:12 | Alex Neundorf | Note Added: 0028177 | |||
| 2012-01-04 16:12 | Alex Neundorf | Assigned To | Alex Neundorf => | ||
| 2012-01-04 16:12 | Alex Neundorf | Status | assigned => backlog | ||
| 2016-06-10 14:27 | Kitware Robot | Note Added: 0041446 | |||
| 2016-06-10 14:27 | Kitware Robot | Status | backlog => resolved | ||
| 2016-06-10 14:27 | Kitware Robot | Resolution | open => moved | ||
| 2016-06-10 14:27 | Kitware Robot | Assigned To | => Kitware Robot | ||
| 2016-06-10 14:30 | Kitware Robot | Status | resolved => closed | ||
| Notes | |||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||