Exporting cmake-gui options - c++

I have a library with a bunch of different configuration options. We usually configure the build with cmake-gui and ticking a few checkboxes.
I want to automate this into a .sh script using just cmake.
e.g.
In GUI -> selects a bunch of different options
equivalent cmake command -> cmake -D CMAKE_XXX=X -D CMAKE_XXY=XXY [a bunch of options here] ..
How can I find the "equivalent" cmake command-line command to any arbitrary configuration I choose from the GUI?

The equivalent cmake command to cache a variable is explained here (-D option). Note that previous documentation was ambiguous, so take care of always checking the latest one.
Basically:
-D<var>:<type>=<value>
You have to specify also the type to have the variable cached in the same way as through your cmake-gui procedure. Note that variable definition is necessary only the first time: if not specified anymore, the cached value will be used.

cmake-gui generates CMakeVars.txt and CMakeCache.txt files in the build directory once you click "Configure" button. They cache all variables you configured through the GUI.

Had the same question ... and as you asked I looking up some of the options in the menu and found it. Menu Tools -> Show My Changes
Bringing up an Dialog with an edit field with content for command line options or cache file options.
yeah
p.s. I used cmake 3.11.1

just read file named like CMakeCache.txt (iirc) in the root of build directory and see variable names there

You can write a file containing all variables you want to set with set(<var_name> <value>) and pass this file to the CMake call via -C:
cmake -C <fileWithInitialValues> <pathToSrcDir>
Documentation:
https://cmake.org/cmake/help/v3.3/manual/cmake.1.html
This should would similar with cmake-gui and ccmake, but it is not a pure solution with the graphic interface.

Related

How to disable ocamlformat in the vendor folder?

I have OCaml project and in vendor folder I have some libraries that are not of my own, I don't want to run ocamlformat on them I tried this
# .ocamlformat
profile = default
version = 0.24.1
# .ocamlformat-ignore
vendor/*
But when I run dune build #fmt I see a lot of errors regarding the vendor folder
(cd _build/default && /home/geckos/.opam/coq-of-solidity/bin/ocamlformat --intf vendor/ocaml-solidity/src/solidity-typechecker/solidity_typechecker.mli) > _build/default/vendor/ocaml-solidity/src/solidity-typechecker/.formatted/solidity_typechecker.mli
ocamlformat: Error while parsing /home/geckos/code/coq-of-solidity/_build/default/vendor/ocaml-solidity/.ocamlformat:
Project should be formatted using ocamlformat version "0.15.0", but the installed version is "0.24.1"
For option "align-cases": This option has been removed in version 0.22.
For option "align-constructors-decl": This option has been removed in version 0.22.
For option "align-variants-decl": This option has been removed in version 0.22.
For option "let-open": This option has been removed in version 0.17. Concrete syntax will now always be preserved.
Having vendor/** in your .ocamlformat-ignore file should fix your issue. No need to have a line for each sublevel of your vendor directory.
There's an FAQ entry explaining this in the documentation:
It is possible to disable OCamlFormat for the files of a directory by
having an .ocamlformat file containing disable in this directory, or
listing the files to ignore in an .ocamlformat-ignore file.
For now it is not possible to recursively ignore all subdirectories
and files from a parent directory, you need to list all the
descendants of the directory to ignore them, e.g.:
dir/*
dir/*/*
dir/*/*/*
It is also possible to add an .ocamlformat-ignore file containing * in
every directory that needs to be ignored.
Edit: This FAQ entry is apparently outdated. It should also be possible to use vendor/"", as #gpetiot points out in the other answer. As the current maintainer he should know. (I've also submitted a PR to update the documentation)

Compile and execute cpp in xcode, and add additional execution instructions, Such as iconv command

Sorry, I'm new to Xcode and not very familiar with it, I use Xcode (command line tool project with external build system) to compile cpp files and automatically execute cpp unix executable files. After the program is compiled (command+R), I set the settings as shown in the screenshot below to automatically execute. Is there any way for me to execute also add additional commands?
Such as iconv.
The following line is what I ultimately want to execute.
./myFile argument1 | iconv -f big5
But my Xcode looks like it's executing only
./myFile argument1
really thanks
On the same place where you setup the build scheme, you can also add a post-build script.
Go to the left of the panel, and expand Build
Select Post-actions
Near the bottom center, click on + -> New Run Script Action
Add script like you would run them in terminal
Note the current directory will not be where the project is built
You can use ${TARGET_BUILD_DIR} macro for the build directory
Note, you want to make sure to select your current project at the Provide build settings from so it can import the correct path macros like TARGET_BUILD_DIR
A screenshot of adding a post-build script:
*Older versions of Xcode might have different GUI, but the idea should be about the same.
Sidenote, ⌘R is really for running the program within Xcode, consider using ⌘B.

CMake 3 Bootstrapping and g++ problems

I am working on a Linux Redhat server. I am trying to Bootstrap my CMake 3 download files as per How to download, compile, and install CMake on Linux.
I changed 2 lines in the bootstrap file so that I would be using the appropriate GCC/G++ versions:
# Toolchain compiler name table.
cmake_toolchain_Clang_CC='clang'
cmake_toolchain_Clang_CXX='clang++'
# cmake_toolchain_GNU_CC='gcc'
cmake_toolchain_GNU_CC='/inf/projdig/users/{username}/gcc_install/bin/gcc'
#cmake_toolchain_GNU_CXX='g++'
cmake_toolchain_GNU_CXX='/inf/projdig/users/{username}/gcc_install/bin/g++'
cmake_toolchain_PGI_CC='pgcc'
cmake_toolchain_PGI_CXX='pgCC'
cmake_toolchain_PathScale_CC='pathcc'
cmake_toolchain_PathScale_CXX='pathCC'
cmake_toolchain_XL_CC='xlc'
cmake_toolchain_XL_CXX='xlC'
But, it seems like bootstrap is still referencing some compiler-related files in the root directories even though I want it to only reference these:
/inf/projdig/users/{username}/gcc_install/bin/gcc and
/inf/projdig/users/{username}/gcc_install/bin/g++
Please see this error:
What should I change in the Bootstrap file so that nothing in /usr/... is referenced, and only
/inf/projdig/users/{username}/gcc_install/bin/gcc and
/inf/projdig/users/{username}/gcc_install/bin/g++
are referenced?
UPDATE
Okay, I did manage to fix some problems by specifying
-L/{path to correct libstdc++} compiler option.
However, at the very end of the bootstrap script, this line doesn't work:
I can't just fix it by adding a -L compiler option because this does not invoke a compiler. It's invoking CMake. This command above produces the same error (ie. it searches /usr/lib64 for the libraries, which is the path I don't want it to look through). How can I let CMake look at a different path for libraries? What option should I specify after .../cmake ?

How to set the library suffix on CMake for SOCI?

I am trying to build SOCI on Windows with a different library suffix using the CMAKE_SHARED_LIBRARY_SUFFIX option, but the script seems to ignore it.
Here is the command I run in a batch file:
cmake^
-G "NMake Makefiles"^
-DCMAKE_BUILD_TYPE=Release^
-DCMAKE_SHARED_LIBRARY_SUFFIX="-vc140-x64-mt.dll"^
..\soci.3.2.3
The documentation does not say anything about the CMAKE_SHARED_LIBRARY_SUFFIX option, but the core/CMakeLists.txt script uses it to define the SOCI_LIB_SUFFIX option, which is reported on the screen when cmake is run. However, its value is always ".dll" instead of "-vc140-x64-mt.dll", so it must be overwritten somewhere I don't know.
Any idea why is this happening and how fix it?

Change Eclipse Dynamic Variable to build a single c++ class

I would like to change the dynamic variable ${selected_resource_loc} such that I get rid of the extension (and can add another one).
The purpose is to build the current selected file, but therefore I don't need the .cc-file in my command but the .o-file with the same name.
Detailed description:
I have a customized make command (lets say make) and would like to execute make selectedFileName.o, where the current selected file in eclipse is selectedFileName.cc. (I put the command as build command in project properties -> C/C++ Build.) With variable ${selected_resource_loc} in behaviour tab I get make selectedFileName.cc.
I solved my problem by writing a skript where I modify the ${selected_resource_loc} and included it via external tools in eclipse.