Global default settings for cmake - makefile

Is there anything similar to MAKEFLAGS environment variable for cmake, to set some global defaults like CMAKE_INSTALL_PREFIX?

No, there is no similar environment variable for CMake. Everything you can set through environment variables in CMake is documented here.
But you could use a the "preload cache" -C option and put all reoccurring settings in an appropriate script (see e.g. CMake preload script for cache).

Related

Run (install) go code when GOPATH is inferred

I just installed Go extension for Vscode and set "go.inferGopath": true, as explained here.
With autobuild on save my code builds, GOPATH is inferred correctly.
Is there a way to run my code (go install) with the inferred GOPATH from vscode? When running any Go command from vscode terminal it uses system GOPATH from go env.
go install will always use the go environment settings, unless you modify the go toolchain. On Linux, you can use the env command to change environment variables for the execution of a single command; on Windows, you can use SET to change environment variables for only the current shell session.

How to configure GOPATH?

I installed Goland as a Go IDE and it wants me to configure GOPATH. I'm new in this language so I don't know what to do. Here is the error message:
GOPATH was detected
We've detected some libraries from your GOPATH.
You may want to add extra libraries in GOPATH configuration.
Edit: Not a duplicate question, export GOROOT=""solved my problem. Thanks anyway.
You actually do not need to set the GOPATH environment variable; in Go 1.8 it's ~/go by default.
I suggest that you just update to latest stable Go (1.8) and use that convention; otherwise you'll need to set the GOPATH variable in your environment.
You need to set the GOPATH environment variable. How you do this varies depending on your operating system.
Here are examples of how to set the PATH environment variable, just modify the instructions to set GOPATH instead.
Also see How to Write Go Code for more details on setting up your workspace and setting GOPATH.
export GOROOT=""
solved the issue for some reason.

How to set GOBIN automatically

working my go project i need to
set GOPATH=D:\projects\go\my project
and then
set GOBIN=D:\projects\go\my project\bin
that is okey
then working on an other project same process a gain
so is there is away of setting only GOPATH
and automatically GOBIN becomes GOPATH\bin
GOBIN should by default be GOPATH/bin, so you don't have to do anything
See "GOPATH environment variable"
DIR is a directory listed in the GOPATH
If the GOBIN environment variable is set, commands are installed to the directory it names instead of DIR/bin

It's ok to re-iterate over the Cmake cache?

I wasn't sure how to set the title for this.
I basically have a code base that I build with cmake; now I would like to know if it's safe to invoke cmake itself on the same cache more than 1 time.
For example in the dir /path I'm building a cache with
cmake -DVAR=VALUE < more flags >
and then in a second step I invoke cmake again in the same directory /path with another set of flags
cmake -DANOTHER_VAR=ANOTHER_VALUE < more flags >
at this point there are some guarantees that what is inside /path is the result of both commands ? It depends on how the CMakeLists is written ?
My building system that I use over cmake could be simplified a little thanks to this steps, that's why I'm asking.
Yes, it's OK to do this. Actually, when you change something in your CMakeLists.txt's and then run make in build folder, CMake invokes cmake . there to regenerate the cache.
Beside that, -DVAR=VALUE is an intended way for setting vars in the generated cache, as well as -UVAR.
The only exception is changing vars like CMAKE_C_COMPILER or CMAKE_CXX_COMPILER. If you alter them with cmake -DCMAKE_C_COMPILER=newcc ., CMake would wipe your cache and generate it from scratch.

Enabling "Software collections". RedHat developer toolset

I just found out that RedHat provides this "Developer toolset" which allows me to install (and of course use) the most up-to-date gcc-4.7.2. I use it on Centos, but the process is the same.
Once installed, you can start a new bash session with this toolset enabled by issuing:
scl enable devtoolset-1.1 bash
That works all right. Now, could I somehow add this to my bashrc since this actually starts a new bash session? Or should I better place it inside my makefiles to avoid starting a new bash session. Would there be a way to issue this within a makefile?
I wrote a blog post on this subject because it started to come up a lot. If you would like to read it, you can find it here: http://developerblog.redhat.com/2014/03/19/permanently-enable-a-software-collection/
tl;dr
you can source /opt/rh/devtoolset-1.1/enable in your .bashrc or, for somewhat better solution you can include:
source /opt/rh/devtoolset-1.1/enable
export X_SCLS="`scl enable devtoolset-1.1 'echo $X_SCLS'`"
But definitely check out the post for more info.
Check the URL
http://preilly.me/2013/05/28/redhat-developer-toolset-1-1/
for more information, for example how to set the CC, CPP, CXX environment variables. Or check
http://people.centos.org/tru/devtools-1.1/
for the devtool-1.1 repository for CentOS.

Resources