This is an archive of the discontinued LLVM Phabricator instance.

[libcxxabi] Add a cmake build system.
ClosedPublic

Authored by danalbert on Jul 1 2014, 4:09 PM.

Details

Summary

For those of us that don't like rebuilding the whole damn thing every
time.

Will add support for tests with lit in a later patch.

This does not yet support building the unwinder in src/Unwind.

Diff Detail

Event Timeline

danalbert updated this revision to Diff 11013.Jul 1 2014, 4:09 PM
danalbert retitled this revision from to [libcxxabi] Add a cmake build system..
danalbert updated this object.
danalbert edited the test plan for this revision. (Show Details)
danalbert added a subscriber: Unknown Object (MLST).

If anyone could test this on msvc I'd appreciate it. My install appears no longer be sane. I'll hack at it more on later...

CMakeLists.txt
128

Eric, forgot to address your comment. Will fix that in a moment.

src/CMakeLists.txt
27

Now using include_directories() instead of target_include_directories() so we don't require cmake 2.8.11.

28

thakis, you had asked about auto-detecting libc++ if building in tree. It was actually already done, just in src/CMakeLists.txt, not the root one.

I don't really understand why (most of) compiler flags are set up in the root CMakeLists.txt, while the link flags are set up in src/CMakeLists.txt, but probably that's not a big deal.

Thanks for working on this!

src/CMakeLists.txt
39

Why not use "set" here?

57

Do you need to do the same for compile_flags?

jroelofs added inline comments.Jul 1 2014, 4:35 PM
CMakeLists.txt
60

BUG_REPORT_URL is used elsewhere in the llvm family... will that work here, rather than the hardcoded string?

samsonov: I used libc++ as an example while setting this up, so some of the structural oddities may have originated there :) I believe the idea is that all the flags that get set up in the root are ones that would be true of anything built in the project (including tests), whereas the flags configured in src/ are specific to libc++abi.(so|a).

CMakeLists.txt
60

This block is specifically for out of tree builds, and BUG_REPORT_URL doesn't seem to be specified in the cmake files that get installed (whereas LLVM_PACKAGE_VERSION is).

src/CMakeLists.txt
57

I actually have no idea why this is here. I copied most of this from the libc++ cmake files and tuned as necessary.

It's done for the compile flags in the main CMakeLists.txt (applied to LIBCXXABI_CXX_*_FLAGS, as these can contain parts specified from the command line using ; as a delimiter). I don't see anything about the ldflags that would need replacement though... I'll remove it.

danalbert updated this revision to Diff 11015.Jul 1 2014, 5:17 PM

Addresses Eric's request to be able to use the system includes.

samsonov added inline comments.Jul 1 2014, 5:18 PM
src/CMakeLists.txt
57

Well, link_flags is a CMake list type, its elements will be semicolon-separated if you add them with list(APPEND link_flags foo).

danalbert added inline comments.Jul 1 2014, 5:19 PM
src/CMakeLists.txt
27

Changed this to point directly to the include directory in case the headers aren't in a directory named "include".

danalbert added inline comments.Jul 1 2014, 5:23 PM
src/CMakeLists.txt
57

Ah, didn't know that (not very familiar with cmake). So is it necessary, or is cmake smart enough to do the replacement itself?

compnerd added inline comments.Jul 1 2014, 6:18 PM
src/CMakeLists.txt
3

Im not a big fan of GLOB. I think that the number of files is tractable enough that we could enumerate them explicitly.

danalbert updated this revision to Diff 11016.Jul 1 2014, 8:48 PM

Fixed the issues with semicolon delimited lists for link_flags/compile_flags.
Moved away from glob.

logan edited edge metadata.Jul 2 2014, 10:43 AM

Also, I feel that it will be good to detect for <stdexcept> and <typeinfo> headers to ensure that libcxx include path has been correctly specified.

CMakeLists.txt
11

Is there any reason that we have to rely on llvm-config when we are building a standalone version? I thought libcxxabi does not rely on LLVM (or clang) headers and libraries (except the libcxx headers which should be specified by -DLIBCXXABI_LIBCXX_INCLUDES.)

www/index.html
95

One typo here:

-DLIBCXXABI_LIBCXX_INCLUDES=path/to/libcxx/include

Also, maybe we can suggest to use:

-DCMAKE_CXX_COMPILER=clang++

instead of setting the environment variable here?

It also depends on llvm-config to find lit.py and the standard llvm cmake includes.

www/index.html
95

Oops, forgot to update the first part when I made that change. Good catch.

For the second part, is there any benefit to doing it that way?

samsonov added inline comments.Jul 2 2014, 1:30 PM
www/index.html
95

FWIW I agree with CMAKE_CXX_COMPILER note - it looks a bit more cmake-ish.

danalbert updated this revision to Diff 11036.Jul 2 2014, 2:34 PM
danalbert edited edge metadata.

Address some documentation errors.

compnerd accepted this revision.Jul 2 2014, 7:12 PM
compnerd edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Jul 2 2014, 7:12 PM
logan accepted this revision.Jul 3 2014, 11:55 AM
logan edited edge metadata.

LGTM.

danalbert closed this revision.Jul 3 2014, 12:44 PM

Submitted as r212286.