Difference between revisions of "CMake FAQ"
(initial version) |
m |
||
Line 17: | Line 17: | ||
== Using CMake == | == Using CMake == | ||
− | === Can I build GEOS-Chem Classic and GCHP in the same environment? === | + | === How do I build GEOS-Chem with CMake? === |
+ | cd <run directory> # 1. Go to your run directory | ||
+ | mkdir build # 2. Create a build directory | ||
+ | cd build # 3. cd into your build directory | ||
+ | cmake <path to GEOS-Chem's source code> # 4. Configure GEOS-Chem's build | ||
+ | make -j # 5. Compile GEOS-Chem | ||
+ | make install # 6. Install the geos executable in your run directory | ||
+ | |||
+ | Refer to [[Building GEOS-Chem with CMake]] for a detailed overview of building GEOS-Chem with CMake. | ||
+ | |||
+ | ==== Can I build GEOS-Chem Classic and GCHP in the same environment? ==== | ||
Yes. Because GEOS-Chem Classic's requirements are a subset of GCHP's. | Yes. Because GEOS-Chem Classic's requirements are a subset of GCHP's. | ||
− | === How do I build specific targets? === | + | ==== How do I build specific targets? ==== |
Pass the target's name as an argument to <code>make</code>. You can build multiple specific targets by passing multiple names. | Pass the target's name as an argument to <code>make</code>. You can build multiple specific targets by passing multiple names. | ||
− | make <name | + | make <name> |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
=== How do I <code>make clean</code>? === | === How do I <code>make clean</code>? === | ||
Line 35: | Line 39: | ||
If you want to restart the build from scratch, you can do | If you want to restart the build from scratch, you can do | ||
make clean | make clean | ||
+ | |||
+ | ==== How do I continue a build that was terminated before it finished? ==== | ||
+ | Run your <code>make</code> command again. The build system will automatically pick up where it left off. | ||
+ | |||
+ | ==== How do I recompile after I make modifications to the source code? ==== | ||
+ | The build system will automatically figure out what needs to be recompiled when you run <code>make</code>. There is no need to run "cleaning" commands. | ||
+ | |||
+ | ==== How do I clean my build's configuration (i.e. CMake's files)? ==== | ||
+ | rm -rf build | ||
+ | mkdir build | ||
+ | cd build | ||
=== How do I change GEOS-Chem's build options? === | === How do I change GEOS-Chem's build options? === | ||
Line 52: | Line 67: | ||
==== How do I build for debugging? ==== | ==== How do I build for debugging? ==== | ||
cmake . -DCMAKE_BUILD_TYPE=Debug | cmake . -DCMAKE_BUILD_TYPE=Debug | ||
− | |||
− | |||
− | |||
− | |||
− | |||
== Advanced topics == | == Advanced topics == |
Revision as of 17:21, 8 October 2019
Contents
General
What is CMake?
When will CMake support be available?
What are the benefits of CMake?
- You environment is verified before you compile.
- Incremental compiling and a simpler build procedure.
- Fewer wasted HPC jobs due to failed builds.
What is incremental compiling?
What is an "out of source" build?
Using CMake
How do I build GEOS-Chem with CMake?
cd <run directory> # 1. Go to your run directory mkdir build # 2. Create a build directory cd build # 3. cd into your build directory cmake <path to GEOS-Chem's source code> # 4. Configure GEOS-Chem's build make -j # 5. Compile GEOS-Chem make install # 6. Install the geos executable in your run directory
Refer to Building GEOS-Chem with CMake for a detailed overview of building GEOS-Chem with CMake.
Can I build GEOS-Chem Classic and GCHP in the same environment?
Yes. Because GEOS-Chem Classic's requirements are a subset of GCHP's.
How do I build specific targets?
Pass the target's name as an argument to make
. You can build multiple specific targets by passing multiple names.
make <name>
How do I make clean
?
You don't need to do this anymore. When you run a make
command, the build system automatically figures out what needs to be recompiled. A "clean
" target still exists, but it cleans everything.
If you want to restart the build from scratch, you can do
make clean
How do I continue a build that was terminated before it finished?
Run your make
command again. The build system will automatically pick up where it left off.
How do I recompile after I make modifications to the source code?
The build system will automatically figure out what needs to be recompiled when you run make
. There is no need to run "cleaning" commands.
How do I clean my build's configuration (i.e. CMake's files)?
rm -rf build mkdir build cd build
How do I change GEOS-Chem's build options?
Build options set through CMake variables. You can set CMake variables with -D<name>="<value>"
arguments. Note that "ON", "OFF", "TRUE", "FALSE", etc., are valid booleans in CMake.
cmake . -DFOO="BAR" # set's the variable FOO equal to "BAR"
How do I disable multithreading (i.e. OpenMP)?
cmake . -DOMP=OFF
How do I disable colorized output?
cmake . -DCMAKE_COLOR_MAKEFILE=FALSE
How do I increase the build's verbosity?
cmake . -DCMAKE_VERBOSE_MAKEFILE=TRUE
How do I build for debugging?
cmake . -DCMAKE_BUILD_TYPE=Debug
Advanced topics
Can I use Ninja rather than GNU Make?
Yes. You'll need CMake version 3.7 or greater and Kitware's Ninja distribution (for Fortran futures). To use the Ninja generator rather than the Makefile generator, initialize your build directory with cmake -GNinja <path to source code>
.
Are the environment variables like FC
and ESMF_ROOT
necessary?
No, these are just for convenience. You can configure the build with the standard CMAKE_C_COMPILER
, CMAKE_CXX_COMPILER
, CMAKE_Fortran_COMPILER
, and CMAKE_PREFIX_PATH
variables, rather than environment variables, if you'd prefer. This means GEOS-Chem doesn't impose environment variable requirements on superprojects.