Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building both static and shared libs for LLVM libc++ 3.3

The latest LLVM libc++ 3.3 from SVN comes with a CMakeLists.txt. I am a CMake newbie, but yesterday I studied enough to be able to build libc++ check-out on a RHEL 6.4 x86_64 host.

In addition, I was able to add enough CPack related commands in said CMakeLists.txt to generate a libcxx-3.3.svn-0.el6.x86_64.rpm. But very likely due to being new to CMake, I can't build a static and a shared lib at the same time.

Yes. I reviewed Is it possible to get CMake to build both a static and shared version of the same library?. But, instead of using the add_library and enumerate all source files, I would like to use the approach employed by libc++'s CMakeList.txt - using APPEND.

I could generate a static lib by replacing the ON in line 40 below with OFF to build a static lib

40  option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
41 

Or I could leave it as is and build a shared lib.

I also tinkered with the following lines, eliminating the NOT or commenting out lines 232 and 233 for example. But regardless what I tried, I just couldn't seem to get the static lib to build together with a shared lib.

232  if (NOT LIBCXX_ENABLE_SHARED)
233    list(APPEND LIBCXX_CXX_FEATURE_FLAGS -D_LIBCPP_BUILD_STATIC)
234  endif()

How can I adjust the CMakeList.txt file so as to build both at the same time?

like image 208
user183394 Avatar asked Oct 21 '22 13:10

user183394


1 Answers

OK. I decided to use the "tried and true" method of using a add_library command, with all *.cpp listed. It works OOTB, so I consider it a solution.

I will re-visit this issue again once I have time to improve my proficiency with CMake.

like image 169
user183394 Avatar answered Nov 12 '22 20:11

user183394