[CMake] Sourceless targets

Michael Wild themiwi at gmail.com
Tue Feb 9 14:01:53 EST 2010


On 9. Feb, 2010, at 18:11 , C. Meissa wrote:

> Hello,
> thx for your reply…
> 
> Am Dienstag, 9. Februar 2010 schrieb Michael Wild:
>> What is it exactly you are trying to achieve?
> 
> Well, you got me perfectly right…
> I like to have all symbols in my static libraries included as is… :-)
> 
>> IMHO this can't possibly work. I assume that you want to create a shared
>> library from a set of static libraries, right? Well, due to the nature of
>> static linking, you'll need a source file that pulls in all the symbols
>> that you want in your final library, otherwise nothing will happen.
> 
> Ok, so I might have to generate a right sourcefile, right?
> 
> thx again
> C.M.

Or do away with the static libraries in the first place...

I often do something like this:


lib/A/files.cmake:
------------------
set(LIB_A_SRCS)
foreach(s srcA1.c srcA2.c srcA3.c)
  list(APPEND LIB_A_SRCS "${CMAKE_SOURCE_DIR}/lib/A/${s}")
endforeach()

lib/B/files.cmake:
------------------
set(LIB_B_SRCS)
foreach(s srcB1.c srcB2.c srcB3.c)
  list(APPEND LIB_B_SRCS "${CMAKE_SOURCE_DIR}/lib/B/${s}")
endforeach()

lib/CMakeLists.txt:
--------------------
include(A/files.cmake)
include(B/files.cmake)
add_library(superduper ${LIB_A_SRCS} ${LIB_B_SRCS})


HTH

Michael


More information about the CMake mailing list