Setup fortran project in Xcode 10 with external build [duplicate] - xcode

I would like to use Xcode under Mac OS X to compile and run a program written in a language that is not supported, e.g. Fortran. Assuming I have a compiler installed, e.g. gfortran or ifort, what are the steps in the Xcode project settings to make it possible to compile and run the program?
I have created an new, empty project since Fortran is not supported (only C,C++,Objective-C and Swift are selectable in a command line tool application). I created a simple Fortran file. But now I guess I have to add several things to the Builds tab in the project settings to make it compile and run (it works from the command line). What are these steps?

Add an external build system target to your project. External build system targets/projects let you build projects in languages Xcode doesn't natively support. The external build system target/project is in the Other section under OS X on the left side of the assistant. When you click the Next button, you'll be asked for the location of the build tool. Enter the path to your Fortran compiler. When you build the project, Xcode will use the Fortran compiler to do the building.

Related

Visual Studio project types Makefile and Utility

I am creating a vcxproj project to build C code (UEFI) which builds with custom build steps. I need the source C and H files to display with full IntelliSense support, then when I hit F5, I want the project to build if any source file changed, then start Debug. If nothing changed, just start the Debugger. The Build just needs to run my command line commands, I do not need Visual Studio to use its C compiler and Linker. It seems the only way to build with custom steps is to set Configuration Type to either Makefile or Utility.
One problem with Makefile project is that it always builds the NMake command line even if I did not touch any files. Is there a way to configure build so that it only builds if any of the source files changed, like with Application or Dynamic Library project types?
Another problem (only with Makefile project) is that it forces IntelliSense to some C++ mode that marks all my CHAR16* L"Strings" as errors: a value type of const wchar_t* cannot be used to initialize an entry of type "CHAR16*". There are Additional Options under NMake IntelliSense menu, but no matter what I put there makes no difference. There is no documentation about what the available switches are and their effect. Is it possible to configure a Makefile project to C mode? BTW, VS2013 does not have this problem, it is only VS2019 and VS2022.
Utility project type does not have the above-mentioned problem with IntelliSense, but it always returns "build up-to-date" even when I change source files, which should set a dirty flag and cause a build. The build only starts when I select Rebuild. Is it possible to configure a Utility project to build when a source file changed?

CMake to Qt Creator .pro file; Build specific CMake project from Qt Creator

Qt Creator does an excellent job with with parsing and building a CMake project. The problem is that when the CMake is too big and has sub-projects, it takes a long time to build.
CMake does have the ability to convert a CMake project to a Visual Studio solution. But since I am using Qt Creator, I'd also like to be able to convert a CMake project to a Qt Creator project.
Is there a straightforward way of accomplishing this task? I have googled, but haven't found anything.
P.S. Or, alternatively, I want the ability to just a build a specific CMake project from Qt Creator, and not the whole "solution". Visual Studio allows you to do it, Qt Creator does not. Unless it does and I don't know how.
Did some digging in Qt Creator and it turns out that it is indeed possible to set which particular CMake sub-project to build.
On the right hand-side where you see the column Welcome/Edit/Design/Projects/Help, go to Projects and select Build on the configuration that you're building:
Then on the right hand-side you'll see on the top a CMake dialog and right below it Build Steps dialog with all the CMake sub-projects loaded. By default all is checked. You can change that selection to whatever sub-project you want to. Obviously if you have a number of sub-projects that are libraries and you're modifying most of the time your executable project and running, then the choice would be the very first one, titled Current Executable:

What is the benefit of building with CMake?

I am working on SFML and I am curious about the option that I can compile it myself. I found it in tutorials, but from the first line I became confused:
CMake is an open-source meta build system. Instead of building SFML, it builds what builds SFML: Visual Studio solutions ...
There is a build option in visual studio too, is there any difference between that build and CMake build?
What does it mean that it builds what builds SFML? It means library files?
Visual studio solutions? What does it mean? As far as i know, when i open a new project it is within a solution and i can add new projects to this solution (I am confused about why there must be more than one project in a solution too!).
What does it mean that CMake builds a solution? And what is it for?
There is sourcecode. People want to compile it. It is difficult and annoying to type the compile commands into a terminal.
People invent build systems, to make 1.) more easy. For example make files or what Visual Studio integrates and stores in its files, called solution.
There are projects, that are cross-platform. They could provide make files, solution files, files for Xcode, Eclipse and so on. This becomes difficult and annoying.
People invent systems, that creates build system to ease 3.). From a common set of files, several different build systems can be steered.
In your actual case: CMake creates the solution file, you can open the solution file and built SFML with that.
CMake is a wonderful tool for cross-platform development without the hassle of maintaining separate build utilities. On Windows, CMake can create a Visual Studio solution file based on its CMakeLists.txt file. On Linux, generally CMake outputs a makefile. CMake is compatible with many build tools, I recommend reading more of there documentation on their website to gain more information.
Edit: Just to be more clear. CMake literally builds what builds SFML since it creates the Visual Studio solution used to build SFML.
A build in VS for a solution is building the library itself. A CMake build generates the VS solution with which you would use to build the library.
See 1.
A VS solution is the full buildable setup containing 1 or more projects. Solutions can contain multiple projects since VS has a limitation on only 1 output per project. If you want multiple outputs (e.g. 4 dlls) each output needs it's own project.

How to use GCC with Microsoft Visual Studio?

I am creating a very large project (a few thousand lines) and so would rather not use Notepad++. An IDE would make it so much easier. I have experience with Microsoft Visual Studio and love it. Is there some easy way to use Cygwin's GCC from within Microsoft Visual Studio?
Alternately, are there any other good Windows IDEs for GCC besides NetBeans and Eclipse? (I hate both of them with a passion.)
There are several ways to go here:
Option 1: Create a Custom Build Tool
Visual Studio 2005 and newer will let you register custom build tools. They tell the IDE how to transform files of one form (e.g. a .cpp file) into another form (e.g. an .obj file).
So far as I know, no one has done this yet for GCC. And, doing it yourself requires writing COM code, which is probably too deep a pool to dive into just for a single project. You'd have to have a compelling reason to take this project on.
You then have to manually adjust each project to tell it to use the custom build tool instead of the default, since you're using a file name extension (.cpp, probably) that Visual C++ already knows about. You'll run into trouble if you try to mix the VC++ and g++ compilers for a single executable built from multiple modules.
On the plus side, if you were looking to start an open source project, this sounds like a good one to me. I expect you'd quickly gather a big user base.
Option 2: Makefile Project
Start Visual Studio and say File > New Project.
In the Visual C++ section, select Makefile Project
Fill out the Makefile Project Wizard:
Build command line: make
Clean commands: make clean
Rebuild command line: make clean all
You can leave the Output (for debugging) field alone if you've named your executable after the project name and it lands where Visual Studio expects to find it.
Leave the rest of the fields alone unless you know what they are and why you want to change them. As an example, you might choose to pass a -D flag on the Preprocessor definitions line to get separate debug and release outputs. If you know you want this, you know how to set it up, so I'm not going to make this long answer even longer in order to explain it.
You'll be asked the same set of questions for the Release build. If you want to bother with separate debug and release builds, you'd make any changes here.
Having done all this, you still have to create the Makefile, and add a make.exe to your PATH. As with the debug vs. release question, going into that level of detail would push this answer off topic.
As ugly as this looks, it's still easier than creating custom build tools. Plus, you say you need to port to Unix eventually, so you're going to need that Makefile anyway.
Option 3: Cross-Platform Development
You say you want to port this program to Unix at some point, but that doesn't mean you must use GCC on Windows now. It is quite possible to write your program so that it builds under Visual C++ on Windows and GCC/Makefiles on *ix systems.
There are several tools that make this easier. One very popular option is CMake, which is available as an installation time option in newer versions of Visual Studio. There are many alternatives such as SCons and Bakefile.
Clang
You can use the Clang compiler with Visual Studio to target Android, iOS, and Windows.
If you are targeting Android, you can use the Clang/LLVM compiler that ships with the Android NDK and toolchain to build your project. Likewise, Visual Studio can use Clang running on a Mac to build projects targeting iOS. Support for Android and iOS is included in the “Mobile Development with C++” workload. For more information about targeting Android or iOS check out our posts tagged with the keywords “Android” and “iOS”.
If you are targeting Windows, you have a few options:
Use Clang/LLVM; “Clang for Windows” includes instructions to install Clang/LLVM as a platform toolset in Visual Studio.
Use Clang to target Windows with Clang/C2 (Clang frontend with Microsoft Code Generation).
GCC
If your project targets Linux or Android, you can consider using GCC. Visual Studio’s C++ Android development natively supports building your projects with the GCC that ships with the Android NDK, just like it does for Clang. You can also target Linux – either remotely or locally with the Windows Subsystem for Linux – with GCC.
Check out our post on Visual C++ for Linux Development for much more info about how to use Visual Studio to target Linux with GCC. If you are specifically interested in targeting WSL locally, check out Targeting WSL from Visual Studio.
Source: https://devblogs.microsoft.com/cppblog/use-any-c-compiler-with-visual-studio/
I'm from the future.
I keep (poking at) a C/C++ toolchain using Visual Code on Win/Lin/Mac and MinGW installed from Choclatey.
(This was done for my sanity - install GDB and GCC however you want)
I've run it with GCC and GDB with IntelliSense using MS's own weird JSON makefiles.
Someday, someone (you?) will write a Gradle or Python script to generate these; for now the examples online in the docs seem to work.
It seems to require three types of JSON thing;
a single IntelliSense configuration for the whole workspace
a Debugging Configuration entry for each binary you want to debug
these can invoke the build tasks
a Build Task per-artifact
I don't think that there's a "require" or "dependency" thingie-mah-bob; sorry

Generate Makefile from Xcode Project for port of project to other UNIX systems

(This was asked before but the answers were not conclusive)
While I love development using Xcode (3.2.1), I have the need to port some projects to other UNIX systems, and even Windows. The code is all C++ but fairly complex. I'm looking for a way to automated / semi-automated generation of equivalent Makefiles out of my Xcode projects, after getting tired to do this by manual trial-and-error.
Thanks for any hints.
Manfred
You should probably switch to CMake for all your platforms. CMake, in turn, can generate Makefile, Xcode, Visual Studio, and KDevelop projects/builds using the CMake project description. You will, at first, need to create a CMake description for your project, but then if you only update the CMake project, going from CMake to Xcode is very easy. Or you can use the Makefile generator and create a Makefile-based Xcode project. To get started using CMake, you should read the the CMake wiki, look at the CMake Manual, and -- if you like -- you can look at my C++ Application Project Template and C++ Library Project Template which use CMake (although I have tested them only with the Makefile generator and not with the Xcode generator).
If you need to go cross-platform then it's probably better to use a makefile for all platforms. Xcode supports makefile builds as "legacy projects" - you lose some functionality/flexibility when you do this, but you still get the same code browsing, source level debugging, etc.
Have you tried Pbxbuild?
Pbxbuild is used to take Xcode project files and build the code. It does this by creating GNUmakefiles, and using Make to build those.

Resources