<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style='font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif;'>Petr,<div><br></div><div>Thanks for the info. I'm working on getting the builds to work exactly like I want for both native *nix and cross-compile Windows builds, so it's a learning process. I do appreciate your info.<br><br><div id=""><hr><font size="3">Vadtec</font><div><font size="2">vadtec@vadtec.net</font></div></div><br><div class="zmail_extra"><div id="1"><br>---- On Thu, 04 Feb 2016 01:49:12 -0600 <b>Petr Kmoch <petr.kmoch@gmail.com></b> wrote ---- <br></div><blockquote style="border-left: 1px solid #0000FF;padding-left: 6px; margin: 0 0 0 5px"><div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>Hi Vadtec.<br><br></div>*The* standard CMake way of dealing with building your dependencies is the ExternalProject module ( <a href="https://cmake.org/cmake/help/latest/module/ExternalProject.html" target="_blank">https://cmake.org/cmake/help/latest/module/ExternalProject.html</a> ). It's a huge beast, but I belive there are some examples and tutorials available out there.<br><br></div>The gist is: you create a top-level, "superbuild" CMakeLists.txt file which will contain only the uses of ExternalProject_Add, one for each dependency, and *one for you own project as well.* The dependencies can be downloaded, patched, builtt, installed, etc., depending on the parameters you pass to ExternalProject_Add. They do not have to be CMake-based; when they are not, simply provide an empty (or otherwise project-specific) CONFIGURE_COMMAND argument.<br><br></div>When CMake is run on the superbuild, it generates a buildsystem such that building it downloads, builds, installs, etc. the external projects. All of this happens at build time, not at CMake time.<br><br></div>This way, you have full control over which dependencies you build in what order, where they get installed etc. Of course, in your case with dependency sources shipped, you don't need a download step (or perhaps maybe just to unpack them).<br><br></div>Once you've successfully built the superbuild once, all the dependencies are ready, and your own project (which you've set up as just another external project) is configured and all its dependencies are in locations which you've specified. Now you switch into the binary directory corresponding to your project and no longer need to work in the superbuild - each external project is self-contained in that it can be used directly as well, without having to go through the superbuild.<br><br></div>On a very symbolic level, an external project setup can look something like this:<br><br></div>root/CMakeLists.txt:<br></div>project(SuperBuild)<br></div>include(ExternalProject)<br><br></div>ExternalProject_Add(<br>  LibraryWeNeed<br>  PREFIX deps/LibraryWeNeed<br></div>  DOWNLOAD_COMMAND somehow_unpack ${CMAKE_CURRENT_SOURCE_DIR}/deps/LibraryWeNeed.tgz --into ${CMAKE_CURRENT_BINARY_DIR}/deps/LibraryWeNeed<br></div>  BUILD_COMMAND make whatever<br>  ...<br>)<br><br></div>ExternalProject_Add(<br></div>  MyProjectItself<br></div>  PREFIX mybuild<br></div><div>  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src<br></div><div>  DEPENDS LibraryWeNeed<br></div>  CMAKE_GENERATOR ${CMAKE_GENERATOR}  # use the same generator as the superbuild<br></div>  CMAKE_CACHE_ARGS -DLibraryWeNeed_ROOT:PATH=${CMAKE_CURRENT_BINARY_DIR}/deps/LibraryWeNeed<br>  ...<br><div><div><div>)<br><br></div><div><br>src/CMakeLists.txt:<br></div><div>project(MyProject)<br></div><div>find_package(LibraryWeNeed PATHS ${LibraryWeNeed_ROOT})  # the root path was passed in by the superbuild<br></div>...<br><br><br></div><div>To work with this, you would then do:<br><br></div><div>cd build<br></div><div>cmake ../root  # generates superbuild<br></div><div>make  # builds superbuild<br></div><div>cd mybuild  # go into MyProject's binary dir<br></div><div>make  # builds MyProject<br><br><br></div><div>Once more, this is all very symbolic. Please refer to documentation, tutorials etc. to achieve the behaviour you need.<br><br></div><div>Petr<br></div><div><div><br><br></div></div></div></div><div><br><div>On Sun, Jan 31, 2016 at 3:42 AM, vadtec <span dir="ltr"><<a href="mailto:vadtec@vadtec.net" target="_blank">vadtec@vadtec.net</a>></span> wrote:<br><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u><div><div style="font-size:10pt;font-family:verdana,arial,helvetica,sans-serif"><div>Let me start by saying I consider my self a cmake newbie. I've made simple makefiles and simple cmake files, but anything more complicated has to this point eluded me. Not for a lack of trying, searching, researching, trail, and a great deal of error: I simply have not been able to achieve the things I'm after. If the sort of questions I'm asking have been answered elsewhere (as I'm sure they have), I apologize for asking them again. That being said, I realize I'm going to be asking some questions that my Google-Fu has failed me in answering. Forgive me my failings, but I'm at my witts end.</div><div><br></div><div><br></div><div>I have a project that I'm building on Linux that has a server component and a client component that also needs to run on Windows. It uses several libraries that I want to version lock so I run into fewer issues with cross compiling and feature creep.</div><div><br></div><div>The project is laid out like this:</div><div><br></div><div>/home</div><div>    mydir/</div><div>        project/</div><div>            build/</div><div>            bundle/</div><div>            deps/</div><div>                curl-7.43.0/</div><div>                libiconv-1.14/</div><div>                libpng-1.6.18/</div><div>                libssh2-1.6.0/</div><div>                openssl-1.0.2d/</div><div>                sqlite/</div><div>                tinycthread/</div><div>                zlib-1.2.8/</div><div>            include/</div><div>                client/</div><div>                    client.h</div><div>                common/</div><div>                    config.h</div><div>                    common_funcs.h</div><div>                server/</div><div>                    server.h</div><div>            src/</div><div>                client/</div><div>                    client.c</div><div>                common/</div><div>                    common_funcs.c</div><div>                server/</div><div>                    server.c</div><div><br></div><div>curl, libiconv, libpng, libssh2, and zlib are the libs I want to build and use both on Linux and Windows. I know all of those are available on Linux and I could use the system installed versions, but I want to use the same vesions on Windows as well. The server is only built on Linux, while the client needs to be built for Linux and Windows. All the libs, headers, etc go into the build directory, and the final "make install" puts everything into the bundle directory, so it can be packaged for distribution.</div><div><br></div><div>The client needs the curl, libiconv, libpng, libssh2, openssl, and zlib libraries. tinycthread is compiled directly into the client, so that's not an issue.</div><div><br></div><div>The server needs the curl, libiconv, libssh2, openssl, and zlib libraries. tinycthread and sqlie are compiled directly into the server, so that's not an issue.</div><div><br></div><div>Ideally, I'd like my cmake file to build the deps that need to be built, build the server and client for Linux, and finally build the client for Windows. Yes, all from the same cmake file. I realize this will probably have to be done with multiple cmake files or a bash script, but that's ok.</div><div><br></div><div>I think building the libs can be done with custom commands or targets, but I haven't been able to figure out how. I haven't been able to get cmake to use only my versions of the libs I've compiled. Some of the libs are being found from the system wide versions, some are coming from my directory.</div><div><br></div><div>My main problem is getting cmake to use only my locally installed/compiled copies of the libs. I need those libs to live along side the binaries, and using the versions I compile is important.</div><div><br></div><div>Rather than provide the CMakeLists.txt I've been using, I'd like it if someone could provide an example file that would compile the above libraries (all of which use autoconf or custom compile scripts) and the client and server for Linux and Windows. I'm 100% certain I am not doing things correctly when it comes to the layout of the CMakeLists.txt, so I'd like to see something fresh from someone with much more experience in build script creation.</div><div><br></div><div>Any help is greatly appreciated.</div><br><div><hr><font size="3">Vadtec</font><div><font size="2"><a href="mailto:vadtec@vadtec.net" target="_blank">vadtec@vadtec.net</a></font></div></div></div></div><br>--<br> <br> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br> <br> Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br> <br> Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br> <br> CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br> CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br> CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br> <br> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br> <br> Follow this link to subscribe/unsubscribe:<br> <a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div> </blockquote><br></div><br></div></div></body></html>