Thanks for the very complete answer, Brad.

I will implement your final suggestion since we have no control over the 
compiler scripts and already have some platform dependent variables set.

Lucas Pettey, PhD
HPCMP PETTT EQM CTA Lead
ERDC-DSRC OnSite
Vicksburg, MS
512-297-9833 Mobile (preferred)
601-634-2980 Office
lucas.pet...@engilitycorp.com

________________________________________
From: Brad King [brad.k...@kitware.com]
Sent: Thursday, May 28, 2015 12:49 PM
To: Pettey, Lucas @ EngilityCorp
Cc: cmake@cmake.org; Dan Liew
Subject: Re: [CMake] Linking C program to external C++ library

On 05/28/2015 01:32 PM, lucas.pet...@engilitycorp.com wrote:
> It is interesting to note that the stdc++ library is in
> CMAKE_C_IMPLICIT_LINK_LIBRARIES and CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES
> but not in CMAKE_CXX_IMPLICIT_LINK_LIBRARIES.

A similar case was discussed here:

 http://www.cmake.org/Bug/view.php?id=14207#c33256

and deemed to be local misconfiguration of the compilers.
There is no reason a C or Fortran compiler should link to
the C++ runtime library.

> when the LINKER_LANGUAGE variable is not set, CMake
> links with the C compiler but does not add the stdc++ library.

That's because it sees stdc++ in the "C" implicit library list
so it knows the compiler front-end will add it.

> Is there any way to tell CMake not to add these other
> IMPLICIT_LINK_LIBRARIES when doing  a mixed language build?

Once could add

 set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "")
 set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
 set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "")

to the project after the respective languages are enabled
(by the project() or enable_language() commands).

-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to