Bug 156901 - [patch] devel/cmake breaks with CC containing spaces
Summary: [patch] devel/cmake breaks with CC containing spaces
Status: Closed Works As Intended
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Some People
Assignee: kde
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-09 10:00 UTC by kamikaze
Modified: 2018-01-01 21:31 UTC (History)
5 users (show)

See Also:


Attachments
file.diff (671 bytes, patch)
2011-05-09 10:00 UTC, kamikaze
no flags Details | Diff
patch-ports-games-opensonic.txt (662 bytes, patch)
2011-07-13 09:38 UTC, kamikaze
no flags Details | Diff
patch-ports-graphics-rawtherapee.txt (547 bytes, patch)
2011-07-13 09:38 UTC, kamikaze
no flags Details | Diff
CMAKE.results (50.08 KB, text/plain)
2011-07-15 11:30 UTC, kamikaze
no flags Details
CMAKE.results (47.58 KB, text/plain)
2011-09-11 12:35 UTC, kamikaze
no flags Details
patch-ports-Mk-bsd.cmake.mk.txt (776 bytes, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-Mk-bsd.port.mk.txt (527 bytes, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-audio-musescore.txt (3.24 KB, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-audio-nas.txt (406 bytes, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-devel-boost.txt (2.49 KB, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-devel-gobject-introspection.txt (404 bytes, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-games-opensonic.txt (686 bytes, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-graphics-luxrender.txt (1.69 KB, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-graphics-opencv.txt (2.65 KB, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-graphics-rawtherapee.txt (670 bytes, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-math-plplot.txt (411 bytes, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-multimedia-mplayer.txt (1.64 KB, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-net-crtmpserver.txt (1.90 KB, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-science-kst2.txt (1.00 KB, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-textproc-sigil.txt (1.08 KB, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-textproc-xerces.txt (2.39 KB, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-x11-qimageblitz.txt (1.43 KB, patch)
2011-09-11 12:35 UTC, kamikaze
no flags Details | Diff
patch-ports-Mk-bsd.cmake.mk.txt (980 bytes, patch)
2011-09-23 17:19 UTC, kamikaze
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description kamikaze 2011-05-09 10:00:18 UTC
This should be assigned to kde@.

cmake is not able to deal with spaces in CMAKE_C_COMPILER and CMAKE_CXX_COMPILER.

Example print/scribus:
===>  Configuring for scribus-1.3.3.14_1
/bin/mkdir -p /usr/obj/mobileKamikaze.norad/amd64/usr/ports/print/scribus/work/scribus-1.3.3.14
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: env CCACHE_PREFIX=/usr/local/bin/distcc /usr/local/bin/ccache cc
CMake Error: your C compiler: "env CCACHE_PREFIX=/usr/local/bin/distcc /usr/local/bin/ccache cc" was not found.   Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Check for working C compiler: env CCACHE_PREFIX=/usr/local/bin/distcc /usr/local/bin/ccache cc -- broken
CMake Error at /usr/local/share/cmake/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
  The C compiler "env CCACHE_PREFIX=/usr/local/bin/distcc
  /usr/local/bin/ccache cc" is not able to compile a simple test program.

  It fails with the following output:
..


This is from the CMakeCache.txt file:
//CXX compiler.
CMAKE_CXX_COMPILER:FILEPATH=env CCACHE_PREFIX=/usr/local/bin/distcc /usr/local/bin/ccache c++
..
//C compiler.
CMAKE_C_COMPILER:FILEPATH=env CCACHE_PREFIX=/usr/local/bin/distcc /usr/local/bin/ccache cc

Fix: cmake is able to handle CC with spaces if it's passed on through the environment instead of using parameters.

From the CMakeCache.txt file in that case:
//C compiler.
CMAKE_C_COMPILER:FILEPATH=/usr/bin/env

//First argument to C compiler
CMAKE_C_COMPILER_ARG1:STRING= CCACHE_PREFIX=/usr/local/bin/distcc /usr/local/bin/ccache cc



Give me a list of ports to test it on and I'll provide you with tinderbox logs.

Patch attached with submission follows:
How-To-Repeat: Just define CC containing spaces and try to build a port with cmake (e.g. print/scribus or devel/qmake4).
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2011-05-10 20:19:59 UTC
Responsible Changed
From-To: freebsd-ports-bugs->kde

Fix synopsis and assign.
Comment 2 kamikaze 2011-07-05 16:54:34 UTC
Just a warning in advance, I have created 4 tinderbuilds to each
of which I have queued all 315 ports with USE_CMAKE in the
Makefile.

The builds have the following configurations:
1. Regular ports tree, CC=cc \ Check for
2. Patched ports tree, CC=cc / regressions

3. Regular ports tree, CC="env cc" \ Check for patch
4. Patched ports tree, CC="env cc" / effectiveness

I expect this will take a couple of days, it's a couple of thousand
packages to build.

I will present the results in a 4*n matrix, once the builds have
completed.

Regards

-- 
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Comment 3 kamikaze 2011-07-13 09:38:48 UTC
After running into some issues with tinderd I added MP safe locking,
applied the patch in ports/158722 to the ports trees, because
gobject-introspection was such a PITA and started over.

Currently 848 of 1260 queue entries have been processed. So far two
regressions manifested:
	games/opensonic
	graphics/rawtherapee

I have attached patches for both.

So far exactly 100 cases have improved due to the cmake patch.

-- 
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? 
Comment 4 kamikaze 2011-07-15 11:30:47 UTC
I think the results speak for themselves. I dedicated my box to
this for more than 9 days, 1260 queue entries were processed.
I hope there'll be some kind of reaction.

Will take care of devel/kdebindings4-ruby after I get some sleep.
I've been up for > 30 hours.

I've got a patch for OpenCV, too. I'll handle it directly with
Martin if this gets a commit.

-- 
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? 
Comment 5 kamikaze 2011-09-11 12:35:37 UTC
This is my second go, this time a complete patch set, nothing stale,
no regressions. Tinderbox results are attached as well.

-- 
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? 
Comment 6 kamikaze 2011-09-23 17:19:13 UTC
The longer this is delayed, the more patches I will have to change.

Regards,
Kami
Comment 7 Martin Wilke freebsd_committer 2014-02-27 15:08:14 UTC
State Changed
From-To: open->closed

this is fixed since ages.
Comment 8 Dominic Fandrey freebsd_committer 2016-05-03 09:40:10 UTC
This has never been fixed:

===>  Configuring for llvm37-3.7.1_2
===>  Performing out-of-source build
/bin/mkdir -p /wrkdirs/usr/ports/devel/llvm37/work/.build
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:29 (project):
  The CMAKE_C_COMPILER:

    /usr/bin/env cc

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.
Comment 9 Dominic Fandrey freebsd_committer 2016-05-03 09:43:37 UTC
I'm taking this, expect a differential within the week.
Comment 10 Tobias C. Berner freebsd_committer 2017-09-16 16:44:31 UTC
If this really is an issue it should be  a bug report for cmake upstream and not fixed in the ports tree for each cmake using port, no?

So, given that this has existed since 2011...
Comment 11 groot 2017-09-17 15:58:27 UTC
Works when specifying the compiler through the environment. In a sample project, both of these build lines work:

    CC=cc cmake .. && make VERBOSE=1
    CC="/usr/bin/env THIS=THAT /usr/bin/cc" cmake .. && make VERBOSE=1

The CMake output for the latter is a little weird,

    -- Check for working C compiler: /usr/bin/env -- works

but not wrong. The OP notes this, as well. Current CMake even tells you, if you try to use the command-line-definition approach, what is wrong:

cmake .. "-DCMAKE_C_COMPILER=/usr/bin/env THIS=THAT /usr/bin/cc"
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
  The CMAKE_C_COMPILER:

    /usr/bin/env THIS=THAT /usr/bin/cc

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.

This should be, as tcberner@ points out, picked up upstream, or filed under "Don't Do That Then".
Comment 12 Adriaan de Groot freebsd_committer 2017-10-11 15:02:13 UTC
Discussed upstream in
  https://gitlab.kitware.com/cmake/cmake/issues/17346

Most of these patches are not for kde@ ports. They could be (re-)filed against the applicable ports. As tcberner@ points out, they have been sitting for a long time, and many no longer apply.

From the kde@ side, the patch to move setting-CC to the environment instead of in the command-line arguments makes some sense. Both science/.kst2 and x11/qimageblitz have "bad" CMakeLists.txt that assume the C++ compiler is a single word. Those patches could apply, too.
Comment 13 Adriaan de Groot freebsd_committer 2018-01-01 21:31:34 UTC
The discussion upstream comes down to:

 - use the environment
 - use the applicable wrapper for distcc and similar

See https://gitlab.kitware.com/cmake/cmake/issues/17346