From nobody@FreeBSD.org  Fri Oct 25 11:37:48 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id 7249FADB
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 Oct 2013 11:37:48 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 60A922FA6
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 Oct 2013 11:37:48 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r9PBbmQ2077544
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 25 Oct 2013 11:37:48 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r9PBbmit077543;
	Fri, 25 Oct 2013 11:37:48 GMT
	(envelope-from nobody)
Message-Id: <201310251137.r9PBbmit077543@oldred.freebsd.org>
Date: Fri, 25 Oct 2013 11:37:48 GMT
From: Harti Brandt <harti@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: cannot pass -stdlib=libc++ to linker
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         183297
>Category:       ports
>Synopsis:       devel/cmake cannot pass -stdlib=libc++ to linker
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kde
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 25 11:40:00 UTC 2013
>Closed-Date:    Wed Nov 06 20:41:28 UTC 2013
>Last-Modified:  Wed Nov 06 20:41:28 UTC 2013
>Originator:     Harti Brandt
>Release:        10.0-current
>Organization:
DLR
>Environment:
FreeBSD FreeBSD10 10.0-CURRENT FreeBSD 10.0-CURRENT #1 r246551M: Fri Feb  8 20:56:00 CET 2013     harti@FreeBSD10:/usr/obj/usr/svn/sys/FreeBSD10  amd64
>Description:
When building a C++ program both the compiler and link are identified as /usr/bin/CC. The compiling works fine - CC seems to be able to figure out the language from the extension. When linking, however, CC refuses the -stdlib=libc++ option. Looks like it doesn't know when parsing the command line.
>How-To-Repeat:
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(test CXX)
add_executable(test test.cc)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++11")

test.cc:
int
main()
{
}

Run
cmake .
make VERBOSE=1
and observe the warning message from the linker:
CC: warning: argument unused during compilation: '-stdlib=libc++'

>Fix:
In analogy to Linux create a Platform/FreeBSD-CXX.cmake:

if(NOT CMAKE_CXX_COMPILER_NAMES)
  set(CMAKE_CXX_COMPILER_NAMES c++)
endif()

This seems to make the default c++ compiler and linker /usr/bin/c++ and the problem disappears.


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->kde 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sun Nov 3 22:18:59 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=183297 
State-Changed-From-To: open->closed 
State-Changed-By: rakuco 
State-Changed-When: Wed Nov 6 20:41:27 UTC 2013 
State-Changed-Why:  
This is actually a duplicate of bin/182442, which was fixed a few days 
ago: instead of changing CMake, it was clang's CC behavior that was not 
in line with what was expected. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=183297 
>Unformatted:
