We have a project made of python scripts and home-made tools. We use cmake with custom targets to handle the application of the tools and python sripts and install resulting binary resources.
We use this under GNU/Linux and MS Windows. It works well but we don't want to force our users to install a compiler, like Visual Studio under Windows.
So, is it possible to install and run cmake without any compiler ? We can use ninja as the build system.
Yes, its possible.
CMake's project() command takes a NONE parameter (no compiler/languages searched for or activated)
project(MyProject NONE)
CMake's -P script mode if you want to take CMake as a cross-platform scripting environment
Related
I have a scons scrip that specifies Boost libraries. This script is specific to Linux.
env.Append(LINKFLAGS=['-lboost_program_options', '-lboost_filesystem', '-lboost_system'])
env.Append(CXXFLAGS=['-std=c++17', '-lboost_program_options', '-lboost_filesystem', '-lboost_system'])
env.Append(LIBS=['-lboost_program_options', '-lboost_filesystem', '-lboost_system' ])
I want to install the application on a Windows machine and have installed Boost on the Windows machine. But how to modify the scons script to point to Boost? The -std=c++17 is easy since Visual Studio can toggle standard from C/C++ Language in the Project setting. Don't know where to set boost_program_options, boost_filesystem, and boost_system in the script.
Some of this is incorrect for any platform. Here's what would be correct for linux.
env.Append(CXXFLAGS=['-std=c++17'])
env.Append(LIBS=['boost_program_options', 'boost_filesystem', 'boost_system' ])
Here's what would be correct for windows:
env.Append(CXXFLAGS=['/std:c++17'])
env.Append(LIBS=['boost_program_options', 'boost_filesystem', 'boost_system' ])
You should not specify -lLIBRARY_NAME anywhere for SCons.
Just the LIBRARY_NAME in LIBS.
You'll need to specify LIBPATH to point to the libraries on windows. (Or perhaps env['ENV']['PATH'] as well)
Is it possible to cross-compile a program targeting a Cygwin environment from a Linux/Unix host? I'm mostly trying to avoid using a Windows WM for building a collection of programs.
From the website:
Cygwin is not:
a way to run native Linux apps on Windows. You must rebuild your application from source if you want it to run on Windows.
mingw-w64 is not enough, I need a full POSIX platform. I'm also wondering if it's possible to target MSYS2.
Perhaps I'm not understanding correctly, and one doesn't need to compile in Cygwin but only mingw-w64 is necessary.
Thanks!
It is possible to compile for Cygwin from Linux.
The cygwin1.dll itself is built in such way.
Packages/libraries are available at:
https://copr.fedorainfracloud.org/coprs/yselkowitz/cygwin/
Of course only a minimal set of tools/libraries is available
I am developing a software in C++ on windows 32-bit (using MSVC++), but since I want to be able to use my software on every platform, I have decided to use CMake as my build generator.
Therefore, I am still just a beginner in CMake. From the CMake tutorials, I understand that in order to cross compile codes, first a toolchain simulating the target platform should be installed on the host platform. Then using the appropriate target-platform C and C++ compilers provided by this toolchain, CMake would be able to generate makefiles etc.
Now, I want to build my code for Linux platform(GNU/Linux) on a Win32 platform. I tried doing the above procedure using CMake combined with Cygwin and using gcc and g++ as compilers. It built fine, created makefiles, and when I issued "make" in Cygwin terminal, the generated makefiles were "made". Now I have got an executable which I was hoping would run on Linux platform. But on Linux I get the error: bash cannot execute binary file.
Using command file executablename, I realized the executable which is made by the above procedure is of type PE32 which is only for Windows.
Now my question is: Is my understanding of cross-platform build procedure using cmake correct?Or should I just use another Linux toolchain under windows to get a Linux ELF executable? What toolchains come to your mind which would give me what I want?
Many thanks
Setareh
You will want to look here: cmake-toolchains(7) if you do cross compiling. However, I would suggest that you install a Linux VM like virtual box on your windows machine and build naively on Linux. It will compile much faster and you will not have to worry about cross compiling. You can mount the windows disk from the linux VM so you can share the same source tree. The linux VM will compile much faster than gcc running under windows.
Your understanding of CMake is correct... it will determine how to create the build system you request (or is default for the platform you are currently on) based on rules in your CMakeLists.txt file. However, this won't necessarily help you compile for linux on a windows machine if you don't have something installed that can target linux.
To compile targeting linux, you will need to use a linux compiler. The link posted by #stjin tells you how to install one on cygwin. Then, to set up your CMake build, do this in the terminal:
CC=gcc-linux CXX=g++-linux cmake . [options]
This will tell CMake to locate the special linux targeted compilers. Hopefuly, after compiling with these compilers you will be able to run on linux.
How to enable debugger in fp-ide? I read somewhere that I should compile fp-ide from sources, but I don't know how to do this. Can someone help me?
Get the generic linux tar installer (fpc-2.6.0.x86_64-linux.tar) for FPC from http://www.freepascal.org/down/x86_64/linux-hungary.var It comes with a precompiled IDE with integrated debugger support and it works fine at least on 12.04 LTS.
I wasn't able to find a PPA for fp-ide, but I can describe how the CLI IDE is compiled on Arch Linux as documented in the repository. Do note that compiling will not enable the debugger in the CLI, as it seems to be an incompatibility between gdb and fp (fp-ide) according to e.g. this bug report in Debian. On Arch Linux, the fpc package also doesn't support the debugger in fp by design (it is explicitly disabled using the NOGDB flag).
Anyhow, here goes the compilation process:
Make sure you have FreePascal installed already, as you need it to compile the IDE
Download the source tarball
Extract the tarball to a location of your convenience and cd into that directory
Execute the following code from within your shell:
pushd fpcsrc/compiler
fpcmake -Tall
popd
make build
make -j1 install
# in Arch, the switch "NOGDB=1" is present in both make lines
That should compile the IDE and install it (you can even try to integrate it in dpkg by using checkinstall instead of make install, but take a look at the Arch PKGBUILD to see an example of what might be needed).
But why do you use the command line IDE fp instead of lazarus? With lazarus you can also make console applications and it offers much more features (e.g. working debug support).
I used CMAKE to create the Visual Studios C++ project for a library that I needed to build, and then I used VC++ to build the library. However, the time has come to rebuild the same library for cygwin so that I can link to it with the GNU tool chain (g++ make gdb). I've been trying to figure out how to configure CMAKE to build for cygwin but I'm not getting very far. I've checked the CMAKE website for help (and I will continue to search around there), but I barely have a grasp on what CMAKE really is, so I am having trouble finding the answers. Can anyone point me in a better direction? (Thanks, All.)
CMake is a build system. It's designed to let you write a single cross-platform build description, then it creates platform-specific build files (such as makefiles for the GNU toolchain) from that build setup.
To make it work under Cygwin, it should suffice to install the cmake Cygwin package (using Cygwin's setup.exe) then run commands similar to the following: (Since you'll be running CMake for Cygwin, you won't need to do anything to configure it for the GNU toolchain).
mkdir my-project-build
cd my-project-build
cmake /path/to/my-project
make