Notes |
|
(0010442)
|
Bill Hoffman
|
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
|
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
|
2008-02-10 08:44
|
|
Sean,
Can you try out the cmake code I added to the note?
Bill |
|
|
(0010447)
|
Sean McBride
|
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
|
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
|
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
|
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
|
2008-02-13 10:23
|
|
|
|
(0010480)
|
Sean McBride
|
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
|
2008-03-02 12:16
|
|
Sean's additional changes to handle -Wno-long-double are working. |
|
|
(0010682)
|
Bill Lorensen
|
2008-03-02 12:17
|
|
All platforms seem to be handled OK. |
|