[CMake] Fortran MinGW on Windows

Leek, Jim leek2 at llnl.gov
Wed Jun 12 18:41:24 EDT 2013


> You do know about /usr/share/cmake-2.8/Modules/CheckLanguage.cmake , right? ;-)

Me?  I don't know anything. :)  This is actually the first time I've seen this, so thanks for that.  

Your solution probably is superior.  It usually makes more sense to just build all the libraries you can, rather than building the just the ones requested by the user.  However, a list the user chooses from is what my boss asked for, so that's what I wrote.  

The only clever bit is that some of these libraries can be used internally, but can't be distributed with the source due to licensing issues.  So I have a little check to see if the library exists before allowing the user to choose it:
 
#optional libraries, see if dir exists, then see if user wants it.  If both yes, build it.
if(EXISTS "${PROJECT_SOURCE_DIR}/External/MARS")
  option (USE_MARS
        "Build and use the MARS library." OFF)
endif() 
if (USE_MARS)
  enable_language(Fortran)
  include_directories ("${PROJECT_SOURCE_DIR}/External/MARS")
  add_subdirectory (External/MARS) 
  set (EXTRA_LIBS ${EXTRA_LIBS} mars)
  add_definitions(-DHAVE_MARS)
endif (USE_MARS)


More information about the CMake mailing list