Difference between revisions of "PHASTA/Compiling PHASTA With CMake"

From PHASTA Wiki
Jump to: navigation, search
(Created page with "There is an unofficial, but popular version of the PHASTA solver which uses a http://cmake.org CMake based build system. Generally, an out-of-source build is used, meaning th...")
 
Line 24: Line 24:
  
 
You may want to set the "CMAKE_BUILD_TYPE" field to either "Release" or "Debug" to get an optimized build or a debugable build respectively.
 
You may want to set the "CMAKE_BUILD_TYPE" field to either "Release" or "Debug" to get an optimized build or a debugable build respectively.
 +
 +
Once you've completed this process, you can simply run "make" to build the code. The executable will be in the "bin" sub-directory of your build directory.
 +
  make
 +
 +
== Tips ==
 +
 +
If you run into trouble, it may be useful to see how the compiler is being invoked. You can do this by running:
 +
 +
  make VERBOSE=1
 +
 +
(after having already run cmake)
 +
 +
To add additional compiler flags, use the CMAKE_C_FLAGS, CMAKE_CXX_FLAGS and CMAKE_Fortran_FLAGS fields when you configure

Revision as of 17:33, 20 June 2013

There is an unofficial, but popular version of the PHASTA solver which uses a [CMake] based build system. Generally, an out-of-source build is used, meaning that you have a separate directory for your executables and intermediate files.

Assuming you have your desired compiler and a current version of CMake (2.8.5 or newer) in your path, you must first create and change into an empty directory to store your build

 mkdir build
 cd build

You can then run cmake to create your makefile

If you're using the Intel compiler suite:

 CC=icc CXX=icpc FC=ifort ccmake ../phasta

If you're using the PGI compiler suite:

 CC=pgcc CXX=pgCC FC=pgfortran ccmake ../phasta

IF you're using the GNU toolchain:

 CC=gcc CXX=g++ FC=gfortran ccmake ../phasta


This will open a "GUI" of sorts. You can use the arrow keys to navigate. Press enter to edit the highlighted field, and then enter again to save your change. Press the "c" key to compute the options. Press "g" to write out the makefile and quit. You'll need to press "c" several times, and fill in any desired options before you can generate your makefile.

You may want to set the "CMAKE_BUILD_TYPE" field to either "Release" or "Debug" to get an optimized build or a debugable build respectively.

Once you've completed this process, you can simply run "make" to build the code. The executable will be in the "bin" sub-directory of your build directory.

 make

Tips

If you run into trouble, it may be useful to see how the compiler is being invoked. You can do this by running:

 make VERBOSE=1

(after having already run cmake)

To add additional compiler flags, use the CMAKE_C_FLAGS, CMAKE_CXX_FLAGS and CMAKE_Fortran_FLAGS fields when you configure