View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006267ITKpublic2008-01-23 09:512008-03-02 12:17
ReporterSean McBride 
Assigned ToBill Lorensen 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformMac OS XOSMac OS XOS Version10.5
Product Version 
Target VersionFixed in Version 
Summary0006267: ITK should not force -no-cpp-precomp compiler flag on Mac OS X
DescriptionIn ITK's main CMakeLists.txt there is the following:

 IF(APPLE)
   SET(ITK_REQUIRED_C_FLAGS "${ITK_REQUIRED_C_FLAGS} -no-cpp-precomp")
   SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -no-cpp-precomp")
   SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -Wno-long-double")
 ENDIF(APPLE)

I would like to request that the "-no-cpp-precomp" be removed. Basically, it is an obsolete flag that is only in Apple's gcc and not the FSF gcc. It's not even in the man page.

The reason I make this request is that in beta versions of Apple's gcc 4.2 the flag is gone, and so ITK cannot be built the way it is now. If I remove the flag, ITK builds fine.

This link has more info:
http://gcc.gnu.org/ml/gcc-prs/2003-05/msg01546.html [^]

The only reason I see to keep it is if it is absolutely needed for some really old Apple gcc, like 2.95. And even then it would need to be conditionalised.

The flag was added to ITK at this point:
http://www.itk.org/cgi-bin/viewcvs.cgi/CMakeLists.txt?root=Insight&r1=1.132&r2=1.133 [^]

TagsNo tags attached.
Resolution Date
Sprint
Sprint Status
Attached Files

 Relationships
related to 0011336closedBrad King itkCheckCXXAcceptsFlags only works in English 

  Notes
(0010442)
Bill Hoffman (developer)
2008-02-09 23:56

I am guessing that what ever version of gcc/Mac OS that shipped in 2003 when I made that change did not compile ITK without it. I am sure if it is removed it will break ITK for that version of Mac OS/gcc, and most likely some other versions. So, I would suggest a try_compile that detects if gcc accepts the flag or not, and then it should work for both old and new gcc/Mac Os versions.
(0010444)
Bill Lorensen (developer)
2008-02-10 08:43

We could use CheckCXXCompilerFlag.cmake
IF(APPLE)
  INCLUDE(${CMAKE_ROOT}/Modules/CheckCXXCompilerFlag.cmake)
  CHECK_CXX_COMPILER_FLAG("-no-cpp-precomp" CXX_HAS_PRECOMP_FLAG)
  IF(CXX_HAS_PRECOMP_FLAG)
    SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -no-cpp-precomp")
  ENDIF(CXX_HAS_PRECOMP_FLAG)

  INCLUDE(${CMAKE_ROOT}/Modules/CheckCCompilerFlag.cmake)
  CHECK_C_COMPILER_FLAG("-no-cpp-precomp" C_HAS_PRECOMP_FLAG)
  IF(C_HAS_PRECOMP_FLAG)
    SET(ITK_REQUIRED_C_FLAGS "${ITK_REQUIRED_C_FLAGS} -no-cpp-precomp")
  ENDIF(C_HAS_PRECOMP_FLAG)
ENDIF(APPLE)
(0010445)
Bill Lorensen (developer)
2008-02-10 08:44

Sean,

Can you try out the cmake code I added to the note?

Bill
(0010447)
Sean McBride (developer)
2008-02-11 09:56

Bill & Bill,

This looks like it should work, but for some reason with gcc 4.2 I'm still getting into the IF that uses the flag (confirmed by commenting out the SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -no-cpp-precomp") line).

Here is how 4.2 reacts to the flag:

sean$ /usr/bin/g++-4.2 -no-cpp-precomp
i686-apple-darwin9-g++-4.2.1: unrecognized option '-no-cpp-precomp'
i686-apple-darwin9-g++-4.2.1: no input files

BTW, gcc 4.0 (current in Xcode 3) builds ITK fine with or without -no-cpp-precomp. For older gccs I have no idea.
(0010448)
Bill Hoffman (developer)
2008-02-11 10:27

OK, well, we have to get the try compile to work. Can you look at CMakeOutput.log and CMakeError.log and try to figure out why the try compile did not work? What is the value of CXX_HAS_PRECOMP_FLAG in your cache? Can you try a very simple CMakeLists.txt file, one with something like this:

INCLUDE(CheckCXXCompilerFlag)
  CHECK_CXX_COMPILER_FLAG("-no-cpp-precomp" CXX_HAS_PRECOMP_FLAG)
  IF(CXX_HAS_PRECOMP_FLAG)
    SET(ITK_REQUIRED_CXX_FLAGS "${ITK_REQUIRED_CXX_FLAGS} -no-cpp-precomp")
  ENDIF(CXX_HAS_PRECOMP_FLAG)

  INCLUDE(CheckCCompilerFlag)
  CHECK_C_COMPILER_FLAG("-no-cpp-precomp" C_HAS_PRECOMP_FLAG)
  IF(C_HAS_PRECOMP_FLAG)
    SET(ITK_REQUIRED_C_FLAGS "${ITK_REQUIRED_C_FLAGS} -no-cpp-precomp")
  ENDIF(C_HAS_PRECOMP_FLAG)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ITK_REQUIRED_CXX_FLAGS}")
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ITK_REQUIRED_C_FLAGS}")
add_library(foo foo.cxx bar.c)
(foo.cxx and foo.c can be empty files.
(0010452)
Bill Lorensen (developer)
2008-02-11 13:32

Just tried Bill's suggested test. The value of CXX_HAS_PRECOMP_FLAG) is 1.
Here is CMakeOutput.log

Performing C++ SOURCE FILE Test CXX_HAS_PRECOMP_FLAG succeded with the following output:
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build
gmake[1]: Entering directory `/home/lorensen/Projects/CommandLineAPI/foo-linux/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/lorensen/Projects/CommandLineAPI/foo-linux/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec.dir/src.o
/usr/bin/c++ -DCXX_HAS_PRECOMP_FLAG -no-cpp-precomp -o CMakeFiles/cmTryCompileExec.dir/src.o -c /home/lorensen/Projects/CommandLineAPI/foo-linux/CMakeFiles/CMakeTmp/src.cxx
c++: unrecognized option '-no-cpp-precomp'
Linking CXX executable cmTryCompileExec
/usr/bin/cmake -P CMakeFiles/cmTryCompileExec.dir/cmake_clean_target.cmake
/usr/bin/c++ -DCXX_HAS_PRECOMP_FLAG -fPIC "CMakeFiles/cmTryCompileExec.dir/src.o" -o cmTryCompileExec -rdynamic
gmake[1]: Leaving directory `/home/lorensen/Projects/CommandLineAPI/foo-linux/CMakeFiles/CMakeTmp'

Source file was:
int main() { return 0;}
Performing C SOURCE FILE Test C_HAS_PRECOMP_FLAG succeded with the following output:
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build
gmake[1]: Entering directory `/home/lorensen/Projects/CommandLineAPI/foo-linux/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/lorensen/Projects/CommandLineAPI/foo-linux/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec.dir/src.o
/usr/bin/gcc -DC_HAS_PRECOMP_FLAG -no-cpp-precomp -o CMakeFiles/cmTryCompileExec.dir/src.o -c /home/lorensen/Projects/CommandLineAPI/foo-linux/CMakeFiles/CMakeTmp/src.c
gcc: unrecognized option '-no-cpp-precomp'
Linking C executable cmTryCompileExec
/usr/bin/cmake -P CMakeFiles/cmTryCompileExec.dir/cmake_clean_target.cmake
/usr/bin/gcc -DC_HAS_PRECOMP_FLAG -fPIC "CMakeFiles/cmTryCompileExec.dir/src.o" -o cmTryCompileExec -rdynamic
gmake[1]: Leaving directory `/home/lorensen/Projects/CommandLineAPI/foo-linux/CMakeFiles/CMakeTmp'
(0010454)
Sean McBride (developer)
2008-02-11 13:47

With gcc 4.0 I get:

Performing C++ SOURCE FILE Test CXX_HAS_PRECOMP_FLAG succeded with the following output:
/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build
/usr/local/bin/cmake -E cmake_progress_report /Users/sean/Desktop/Test/bin4.0/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec.dir/src.o
/usr/bin/c++ -DCXX_HAS_PRECOMP_FLAG -no-cpp-precomp -o CMakeFiles/cmTryCompileExec.dir/src.o -c /Users/sean/Desktop/Test/bin4.0/CMakeFiles/CMakeTmp/src.cxx
Linking CXX executable cmTryCompileExec
/usr/local/bin/cmake -P CMakeFiles/cmTryCompileExec.dir/cmake_clean_target.cmake
/usr/bin/c++ -DCXX_HAS_PRECOMP_FLAG -headerpad_max_install_names -fPIC "CMakeFiles/cmTryCompileExec.dir/src.o" -o cmTryCompileExec

With gcc 4.2 I get:

Performing C++ SOURCE FILE Test CXX_HAS_PRECOMP_FLAG succeded with the following output:
/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build
/usr/local/bin/cmake -E cmake_progress_report /Users/sean/Desktop/Test/bin4.2/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec.dir/src.o
/usr/bin/g++-4.2 -DCXX_HAS_PRECOMP_FLAG -no-cpp-precomp -o CMakeFiles/cmTryCompileExec.dir/src.o -c /Users/sean/Desktop/Test/bin4.2/CMakeFiles/CMakeTmp/src.cxx
i686-apple-darwin9-g++-4.2.1: unrecognized option '-no-cpp-precomp'
Linking CXX executable cmTryCompileExec
/usr/local/bin/cmake -P CMakeFiles/cmTryCompileExec.dir/cmake_clean_target.cmake
/usr/bin/g++-4.2 -DCXX_HAS_PRECOMP_FLAG -headerpad_max_install_names -fPIC "CMakeFiles/cmTryCompileExec.dir/src.o" -o cmTryCompileExec

The "unrecognized option '-no-cpp-precomp'" is only in the latter, as expected. But should the latter say "succeded with the following output"? Is it not detecting the failing compilation?
(0010472)
Bill Lorensen (developer)
2008-02-13 10:23

Created a new macro: itkCheckCXXAcceptsFlags.
http://www.itk.org/cgi-bin/viewcvs.cgi/CMake/itkCheckCXXAcceptsFlags.cmake?rev=1.1&root=Insight&sortby=date&view=log [^]

This macro scans the output of the compiler to look for warnings about unrecognized flags.

Also updated CMakeLists.txt to use the macro to check the -no-cpp-precomp flag on the MAC OS X compiler.
http://www.itk.org/cgi-bin/viewcvs.cgi/CMakeLists.txt?rev=1.281&root=Insight&view=log [^]
(0010480)
Sean McBride (developer)
2008-02-13 13:17

Turns out -Wno-long-double is also removed. So I've done the analogous fix. All is well now.

Please review this:

/cvsroot/Insight/Insight/CMakeLists.txt,v <-- CMakeLists.txt
new revision: 1.282; previous revision: 1.281
(0010681)
Bill Lorensen (developer)
2008-03-02 12:16

Sean's additional changes to handle -Wno-long-double are working.
(0010682)
Bill Lorensen (developer)
2008-03-02 12:17

All platforms seem to be handled OK.

 Issue History
Date Modified Username Field Change
2008-01-23 09:51 Sean McBride New Issue
2008-02-07 13:37 Sean McBride Description Updated
2008-02-09 23:56 Bill Hoffman Note Added: 0010442
2008-02-10 08:43 Bill Lorensen Note Added: 0010444
2008-02-10 08:44 Bill Lorensen Note Added: 0010445
2008-02-10 08:44 Bill Lorensen Status new => feedback
2008-02-11 09:56 Sean McBride Note Added: 0010447
2008-02-11 10:27 Bill Hoffman Note Added: 0010448
2008-02-11 13:32 Bill Lorensen Note Added: 0010452
2008-02-11 13:47 Sean McBride Note Added: 0010454
2008-02-13 10:19 Bill Lorensen Status feedback => assigned
2008-02-13 10:19 Bill Lorensen Assigned To => Bill Lorensen
2008-02-13 10:23 Bill Lorensen Status assigned => resolved
2008-02-13 10:23 Bill Lorensen Resolution open => fixed
2008-02-13 10:23 Bill Lorensen Note Added: 0010472
2008-02-13 13:17 Sean McBride Status resolved => feedback
2008-02-13 13:17 Sean McBride Resolution fixed => reopened
2008-02-13 13:17 Sean McBride Note Added: 0010480
2008-02-13 13:30 Sean McBride Status feedback => confirmed
2008-02-14 14:42 Bill Lorensen Status confirmed => closed
2008-02-14 14:42 Bill Lorensen Resolution reopened => fixed
2008-03-02 12:16 Bill Lorensen Status closed => resolved
2008-03-02 12:16 Bill Lorensen Note Added: 0010681
2008-03-02 12:17 Bill Lorensen Status resolved => closed
2008-03-02 12:17 Bill Lorensen Note Added: 0010682
2010-11-03 09:46 Brad King Relationship added related to 0011336


Copyright © 2000 - 2018 MantisBT Team