[CMake] problem with mac linker flags

Cochran, Bill cochranwk at ornl.gov
Wed Dec 22 16:21:00 EST 2010


Thanks for the help.

So, I guess the problem is cmake is incorrectly guessing my compiler?  I'm
not using intel, I'm using gnu.

I think the cmake install on the computer has issues because I have
successfully used cmake with the same compiler on the same os on another
computer.


Thanks again,
Bill

On 12/22/10 4:15 PM, "Richard Wackerbarth" <richard at NFSNet.org> wrote:

>The problem is that CMake does not call the linker. It invokes the linker
>by calling the compiler and passing flags through it.
>
>In the module, Darwin.cmake, you find:
>
>
>SET(CMAKE_C_LINK_FLAGS "-Wl,-headerpad_max_install_names")
>SET(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names")
>
>
>But in Darwin-icc.cmake, you find:
>
>SET(CMAKE_C_LINK_FLAGS "-headerpad_max_install_names")
>SET(CMAKE_CXX_LINK_FLAGS "-headerpad_max_install_names")
>
>Changing the latter to match the former should fix the issue.
>
>However, IMHO, a correct implementation would either call the linker
>directly or "escape" the flags (with the "-Wl," prefix) so that they get
>passed correctly.
>
>On Dec 22, 2010, at 2:03 PM, Cochran, Bill wrote:
>
>> I was wondering if anyone has seen a problem like this before.  It
>>appears cmake is not passing arguments to the linker correctly.
>> 
>> 
>>    ===============
>>    Configuring AMP
>>    ===============
>>    -- The C compiler identification is GNU
>>    -- The CXX compiler identification is GNU
>>    -- Checking whether C compiler has -isysroot
>>    -- Checking whether C compiler has -isysroot - yes
>>    -- Checking whether C compiler supports OSX deployment target flag
>>    -- Checking whether C compiler supports OSX deployment target flag -
>>yes
>>    -- Check for working C compiler:
>>/opt/openmpi-1.3.2-gcc-4.6-debug/bin/mpicc
>>    -- Check for working C compiler:
>>/opt/openmpi-1.3.2-gcc-4.6-debug/bin/mpicc -- broken
>>    CMake Error at /:opt:cmake/CMake
>>2.8-3.app/Contents/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52
>>(MESSAGE):
>>      The C compiler "/opt/openmpi-1.3.2-gcc-4.6-debug/bin/mpicc" is not
>>able to
>>      compile a simple test program.
>>      It fails with the following output:
>>       Change Dir:
>>/Users/zfw/repository/amp/build/debug/CMakeFiles/CMakeTmp
>>      Run Build Command:/usr/bin/make "cmTryCompileExec/fast"
>> 
>> - Ignored:
>>      /usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make
>>      CMakeFiles/cmTryCompileExec.dir/build
>> 
>>      "/:opt:cmake/CMake 2.8-3.app/Contents/bin/cmake" -E
>>cmake_progress_report
>>      
>>/Users/zfw/repository/amp/build/debug/CMakeFiles/CMakeTmp/CMakeFiles 1
>> 
>>      Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o
>> 
>>      /opt/openmpi-1.3.2-gcc-4.6-debug/bin/mpicc -o
>>      CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -c
>>      
>>/Users/zfw/repository/amp/build/debug/CMakeFiles/CMakeTmp/testCCompiler.c
>> 
>>      Linking C executable cmTryCompileExec
>> 
>>      "/:opt:cmake/CMake 2.8-3.app/Contents/bin/cmake" -E
>>cmake_link_script
>>      CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1
>> 
>>      /opt/openmpi-1.3.2-gcc-4.6-debug/bin/mpicc -Wl,-search_paths_first
>>      -headerpad_max_install_names
>>      CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -o
>>cmTryCompileExec
>> 
>>      gcc: error: unrecognized option '-h'
>> 
>>      make[1]: *** [cmTryCompileExec] Error 1
>> 
>>      make: *** [cmTryCompileExec/fast] Error 2
>> 
>> 
>> 
>> 
>> 
>>      CMake will not be able to correctly generate this project.
>>    Call Stack (most recent call first):
>>      CMakeLists.txt:17 (PROJECT)
>> 
>> 
>>    -- Configuring incomplete, errors occurred!
>> 
>> 
>>    For some reason, the linker flag ?headerpad_max_install_names is not
>>being prefixed with ?Wl,.  Any thoughts?
>> 
>>    Bill
>> _______________________________________________
>> Powered by www.kitware.com
>> 
>> Visit other Kitware open-source projects at
>>http://www.kitware.com/opensource/opensource.html
>> 
>> Please keep messages on-topic and check the CMake FAQ at:
>>http://www.cmake.org/Wiki/CMake_FAQ
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>



More information about the CMake mailing list