Cmake to generate solution file machine independent - cmake

I tried to generate a solution file of GSL library for visual studio 2012 using cmake gui. I did that successfully and I build the library for my own computer. But when I tried to build the same solution file in my different computer, it gives me errors saying "C:/my other computer directory/xxx.vcxproj does not exist" . Is there any way that I can generate sln file which is machine independent.

CMake is not designed to be used in this way, and it is highly unlikely you will be able to use it in this way. CMake performs system introspection, storing this in the CMake cache, and uses full paths to most things. I would advise you to run CMake on each system, and prefer offering simple instructions to run CMake/cmake-gui on each machine.

Related

Provide multiple toolchain options in CMake

I have an embedded project for ARM platform, specifically aarch64.
Up until now I was using Make. I recently set up CMake with no particular issues.
I moved to CMake because I was under the impression it was a more modern build tool that would have allowed a smarter configuration.
For example, I can compile my project using different toolchains (aarch64-elf-gcc-linaro, aarch64-linux-gnu-gcc,...) and I would like CMake to try if any of those are installed on the system and use whichever is found first by default.
Is this possible (or meant to)? I'd expect it to be an easy feat for the tool, but after searching for a while I can't seem to find the right track.
Yes, you can make your CMake project to search for available tool-chains installed in your OS, choose one and compile your project. I also write a CMake program for ARM embedded project, because now it is universal transferable between different OS system Windows and Unix. On Linux there is ARM ToolChain installed and on Windows there is Keil-MDK. If you have different tool-chains to choose between, you can write CMake script which will find paths with command like find_path() and then call correct "toolchianxx.cmake" script with right compiler flags for chosen compiler.
In your particular problem just use find_path commands and use hits to find installed compilers in "pre-set" known paths.

Cmake: Cross generate build systems from Linux possible?

Is it possible generate build systems on one platform for another using cmake? For example, and the case I'm most interested in, is it possible to generate a set of Visual Studio solution files, or mingw32-make Makefiles, or nmake files, for a project from Linux?
The intention is to make something analogous to what the make dist target produces in automake. However, I don't need it to do as much as make dist does, i.e. I just want to generate the solution files as though I'd run cmake in Windows.
Users can then build the package using the created build system on their own machines.
If it is possible, how do I do it? Cmake doesn’t report the Windows based generators as being available on Linux.
After further research I believe the answer to my question is no. The reason is that the makefiles and solution files etc. produced by cmake depend on cmake itself, the path to which is hard-coded into the files.
One solution for windows might be to bundle the cmake executable with your files and replace the definition of CMAKE_COMMAND (for instance) added to makefiles with the path to your bundled version of cmake somehow. This is just a suggestion though, I haven't tried or even researched it much. If you do, please post the process as a comment or answer here.

Is there a way for cmake to automatically extend the system PATH variable to compiled executables?

Can cmake configuration files also be used to automatically extend the system PATH variable to include the directory paths to all the installed executable applications and if it is possible (and a standard practice), how can I do this?
This way, as soon as I configure all the CMakeLists.txt files and everything compiles (and hopefully runs) nicely, I can start using the applications, and the path configuration would be packaged together with the build process. I am working with Linux and my code is written in C++, but since cmake is cross-platform, the question extends to other systems as well.
I'm unaware of any capability in CMake to do this. However, we based what we do what Cantera does. They upgraded to SCONS recently instead of their old build system, but the idea still applies.
Anyway, there's a script that CMake configures with the paths during the configure step and then installs somewhere. So once built on Linux, one would run make install then source ~/setup_cantera and it sets up all the variables needed.
We do the same thing for our libraries built with CMake. It's possible to detect which shell the user is running and configure an appropriate template script.

How to automate building of third party library using cmake

What I am looking for:
Download library
Extract It
Apply custom patch
Run configure
Run build command
What library I am trying to build are:
Openssl
Boost
Thrift
C-ares
Curl
Pcre
Nginx
ICU
JsonCPP
I think I can do these things using external module: http://cmake.org/cmake/help/v2.8.8/cmake.html#module:ExternalProject
But I have following question?
I have different type of build and with different directory. Is it
going to build all these library for every different target? If yes
it will be painful as all these library take one hour to build. Is
there a way I can control it and it only build it once. As library
remains same for all these targets.
On switching directory to different name. Cmake force everything to
be rebuild-ed. Will it be same for external library. If yes? How to
solve this problem. I don't want to rebuild the library if I am not
changing them and want to use them while switching to different
branches without building them.
Yes, you can use CMake's ExternalProject feature to accomplish what you want to do.
When using cross-compilation in combination with external projects, the source code will be built once for each toolchain. You could avoid rebuilds if you checked in the results of the build into a source-control system, and re-checked it out on each new person's machine, but I do not recommend this. Instead, have one of your "set up new computer" tasks actually be allowing the compilation to run overnight, which will also act as a test that the machine is actually usable. That set-up task can be launched by a system administrator prior to a new hire's arrival, or you can leave it to the new hire, as circumstances require.
I'm not completely certain what you are asking in your second question, but if the library is unchanged, CMake will detect that it is unchanged and not recompile it. Typically, the source code would be in a single directory tree: each compiled version would be built in a distinct location. Thus, developers can access any compiled version at any time just by switching directories. This is particularly helpful because it allows you to mount these directories over NFS to embedded hardware, et cetera.

build google breakpad stackwalk

I can build the google breakpad client, the stackwalker can convert the dump to human readable txt file. But there is no gyp file to make vs2008 solution. Does anyone know how to build the stackwalker on windows. Thanks
The stackwalker tool doesn't build using Visual C++ currently. You can build it with Cygwin if you install that whole toolchain. If you'd find it useful there's a prebuilt Cygwin minidump_stackwalk binary that Mozilla uses on our build machines.
Along with the matching Cygwin support DLLs:
cygwin1.dll,
cygstdc++-6.dll,
cyggcc_s-1.dll.
It's slightly out-of-date but should work fine.
Also note that you should be able to load Windows minidump files directly into a debugger on Windows, like Visual C++ or WinDBG.