<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hello.<br>
    <br>
    That is a good idea, Hendrik. I'll look into that.<br>
    <br>
    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.<br>
    <br>
    Thank you both for your insights.<br>
    <br>
    Mike<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 6/26/2014 11:49 AM, Angeliki
      Chrysochou wrote:<br>
    </div>
    <blockquote
cite="mid:CAPEuF9gMbd3aJZA1bsVCQ_PhQsJVwOSzZNjbJDemNtja56bQqA@mail.gmail.com"
      type="cite">
      <p dir="ltr">Hi,</p>
      <p dir="ltr">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}).</p>
      <p dir="ltr">Cheers,<br>
        Angeliki</p>
      <div class="gmail_quote">On Jun 26, 2014 8:12 PM, "Hendrik
        Sattler" <<a moz-do-not-send="true"
          href="mailto:post@hendrik-sattler.de">post@hendrik-sattler.de</a>>
        wrote:<br type="attribution">
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div>Hi,<br>
            <br>
            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.<br>
            <br>
            HS<br>
            <br>
            <br>
            <div class="gmail_quote">On 26. Juni 2014 18:14:36 MESZ,
              Michael Burns via CMake <<a moz-do-not-send="true"
                href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a>>
              wrote:
              <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt
                0.8ex;border-left:1px solid
                rgb(204,204,204);padding-left:1ex">
                <pre>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:

<blockquote class="gmail_quote" style="margin:0pt 0pt 1ex 0.8ex;border-left:1px solid #729fcf;padding-left:1ex"> 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 "<a moz-do-not-send="true" href="http://LibA.so" target="_blank">LibA.so</a>" "<a moz-do-not-send="true" href="http://LibB.so" target="_blank">LibB.so</a>")


 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
 <<a moz-do-not-send="true" href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a> <mailto:<a moz-do-not-send="true" href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a>>> 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</blockquote></pre>
              </blockquote>
            </div>
          </div>
        </blockquote>
      </div>
    </blockquote>
  </body>
</html>