Hello.

That is a good idea, Hendrik. I'll look into that.

Angeliki, we set the CMAKE_CXX_FLAGS... and CMAKE_C_FLAGS... values with various options. I simply added the -static and -static-libstdc++ to those. Again, I'm trying to do this without having to modify all of the existing scripts and without adding "special requirements" when new scripts are added in the future.

Thank you both for your insights.

Mike


On 6/26/2014 11:49 AM, Angeliki Chrysochou wrote:

Hi,

This is a good idea Hendrik! Mike, how are you creating your static libraries? You don't need to at the "-static" option yourself...you could tell cmake you want a static library using add_library(${YOUR_LIB} STATIC ${SOURCES}).

Cheers,
Angeliki

On Jun 26, 2014 8:12 PM, "Hendrik Sattler" <p...@hendrik-sattler.de> wrote:
Hi,

you can also override the target_link_libraries function with your own in the top-level lists file and call the original one from within that function. This way you only have to edit one file.

HS


On 26. Juni 2014 18:14:36 MESZ, Michael Burns via CMake <cmake@cmake.org> wrote:
Hello, Angeliki.

Yes, you are correct. I want to link against the static libraries (.a)
rather than the shared objects (.so). I know it "shouldn't" make a
difference, but it is. Adding the "-static" option to the gcc command

line causes the link failures to happen. Without that option, everything
builds just fine.

Ideally, I would just like to set some property that caused these common
libraries to be appended to the end of the compilation line as defined

in link.txt. Unfortunately, I haven't seen anything like that.

Your suggestion seems to be the only option. That means I will need to
update nearly 180 CMake scripts. And, we'll need to make sure any new

scripts contain this value for every instance of TARGET_LINK_LIBRARIES
statement. A painful process!

Thank you for your response, Angeliki.

Mike


On 6/26/2014 1:16 AM, Angeliki Chrysochou wrote:

Hi Michael, I think what matters is the correctly set dependencies for your build to succeed (target_link_libraries). By "statically link" you mean you link against static libraries that were before shared objects, right? This should, to my knowledge, not have any influence to how you use target_link_libraries. My assumption would be that maybe these static libraries are not set as linking dependencies to all necessary target_link_libraries. If I understood your problem correctly, if you want to have a set of libraries that are linking dependencies to all your libraries, you could use the following approach: set a variable (list or simple) in your top level CMakeLists.txt file, and then by default add it to all target_link_libraries. You could modify these "global dependencies" or even have this variable empty with no problems. For example your top level CMakeLists.txt could contain: set(GLOBAL_LIBRARIES "LibA.so" "LibB.so") and then have this in the CMakeLists.txt files of the rest of your libraries: target_link_libraries(${YOUR_LIB} ${GLOBAL_LIBRARIES} ... ) Maybe there is some better practice out there for this, if so, I would also be interested to know :) Cheers! Angeliki On Wed, Jun 25, 2014 at 7:46 PM, Michael Burns via CMake <cmake@cmake.org <mailto:cmake@cmake.org>> wrote: Hello, all. I work on a cross-platform project that has many libraries and several applications. CMake on Linux naturally adds the TARGET_LINK_LIBRARIES specified in the libraries after those specified in the TARGET_LINK_LIBRARIES for the application. However, there are several common system libraries, for example pthread, that are used by many of the libraries and most of the applications. The current scripts only have the common system libraries specified in a few scattered places. And, it works. However, we're trying to change to statically link these libraries and the links are failing with "undefined reference" errors. When I manually modify link.txt to add the various system libraries to the end of the compilation line, it works. So, rather than going through all of the scripts (of which there are many), I would like to be able to list them so they are added to the end of every link. Is there a way to identify libraries in such a way that they are added to the end of the compilation line rather than having to add those libraries to every library and application that requires them? Thanks! Mike
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to