[CMake] CMake incorrectly passes linker flags to ar

Alan Burlison Alan.Burlison at oracle.com
Mon Jan 11 16:21:28 EST 2016


On 11/01/2016 17:48, Brad King wrote:

> That is not representative of CMake in general.  If there is a better
> way for FindJNI to get the information it needs then it would be great
> to have needed changes contributed.

The Hadoop CMake infrastructure contains pretty much a complete rewrite 
of the JNI detection code for Linux, on other platforms it seems to be 
possible to get away with just tweaking things slightly before calling 
the standard CMake JNI module. The problem of course is all the 
cross-platform testing any wholesale rewrite would entail...

>> The Hadoop CMakeLists.txt files don't use a PROJECT() command. The CMake
>> docs say if you don't do so then an implicit PROJECT() is added that
>> selects the C & C++ languages, is that done before processing any other
>> commands in CMakeLists.txt?
>
> Yes, the implicit project() call is inserted on line zero of the top-level
> CMakeLists.txt file.  This feature is meant to help people get started
> with hello-world projects and is not meant for use by mature projects.
> The top-level CMakeLists.txt file of a "real" project should start with
>
>   cmake_minimum_required(VERSION ...)
>   project(MyProject)
>
> Flags affecting the target architecture are typically expected to be
> provided by the user calling CMake, not by project code, and so will
> be set before languages are enabled by this project() command.

That's not the way CMake is used for building Hadoop, CMake is called by 
Ant and/or Maven, users don't call CMake directly. I suspect that's not 
too uncommon, when CMake is used to build just the native components of 
a larger platform-independent system.

-- 
Alan Burlison
--


More information about the CMake mailing list