0% found this document useful (0 votes)
120 views6 pages

C Make Lists

This document contains CMake configuration code for building the Dakota software package. It sets compiler and linker options, finds dependencies like MPI, Boost and LAPACK, and configures optional packages. Graphics support is enabled if X11, Motif and threads are found. Source files are added to the build. Configuration files are generated.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views6 pages

C Make Lists

This document contains CMake configuration code for building the Dakota software package. It sets compiler and linker options, finds dependencies like MPI, Boost and LAPACK, and configures optional packages. Graphics support is enabled if X11, Motif and threads are found. Source files are added to the build. Configuration files are generated.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

cmake_minimum_required(VERSION 2.

8) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/config ${CMAKE_CURRENT_SOURCE_DIR}/config/share ${CMAKE_CURRENT_SOURCE_DIR}/config/share/utils ${CMAKE_CURRENT_SOURCE_DIR}/config/share/package_arch ${CMAKE_CURRENT_SOURCE_DIR}/config/share/config_tests ${CMAKE_MODULE_PATH} ) # Check for compilers after initializing MPI project("Dakota" C CXX Fortran) # Attempt to detect MPI if not specified option(DAKOTA_HAVE_MPI "Enable MPI in DAKOTA" OFF) include(DakotaHaveMPI) DakotaHaveMPI() # Now check lanauges after MPI compilers are processed enable_language(C) enable_language(CXX) enable_language(Fortran) include(FortranCInterface) include(CheckFunctionExists) include(CheckIncludeFile) include(FindCURL) option(BUILD_STATIC "build static libraries" OFF) option(BUILD_SCILAB_INTERFACE "build the Scilab interface" OFF) option(CUSTOM_SCILAB_PATH "path for a custom scilab install" OFF) if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) message(FATAL_ERROR "In-source builds are not allowed. Please create a directory and run cmake from there, passing the path to this source directory as the last argument. This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. Please delete them.") endif() add_definitions("-DHAVE_CONFIG_H") # Add CMAKE_BUILD_TYPE for DISTRIBUTION to match historical tests / releases set(CMAKE_C_FLAGS_DISTRIBUTION "-O2") set(CMAKE_CXX_FLAGS_DISTRIBUTION "-O2") set(CMAKE_Fortran_FLAGS_DISTRIBUTION "-O2") option(BUILD_SHARED_LIBS "Build shared libraries?" ON) if(CMAKE_SYSTEM_NAME MATCHES Darwin) set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup") endif() # first check for a system blas and lapack find_library(BLAS_LIBS blas) find_library(LAPACK_LIBS lapack) if(NOT BLAS_LIBS OR NOT LAPACK_LIBS) # if not a system blas and lapack, then look for a cmake built LAPACK

# with find_package find_package(LAPACK REQUIRED NO_MODULE) set(BLAS_LIBS blas) set(LAPACK_LIBS lapack) endif() # hack to be fixed when CMake does it automatically if(${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel") set(FIXED_FLAG "-fixed") elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU") set(FIXED_FLAG "-ffixed-form") elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI") set(FIXED_FLAG "-Mfixed") endif() if(CMAKE_SYSTEM_NAME MATCHES Darwin) set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup") endif() find_package(Boost 1.40 REQUIRED) # check for a MPI-enabled build if(CMAKE_CXX_COMPILER MATCHES mpicxx) find_program(mpicxx mpicxx) if(${mpicxx} MATCHES "mpicxx-NOTFOUND") message(FATAL_ERROR "Cannot build parallel configuration without mpicxx") endif() message(" **** dakota build **** MPIHOME is: " $ENV{MPIHOME}) set(MPI_INCLUDE_PATH "$ENV{MPIHOME}/include" CACHE PATH "Always use $MPIHOME to find MessagePassing header files" FORCE ) find_package(MPI REQUIRED) if(MPI_FOUND) #message("MPI found - path to include is: ${MPI_INCLUDE_PATH}") set(HAVE_MPI "ON") add_definitions(-DHAVE_MPI) include_directories(${MPI_INCLUDE_PATH}) # Some TPLs have manage the setting with USE_MPI rather than HAVE_MPI set(USE_MPI "ON") else() message(FATAL_ERROR "Cannot find MPI. Please build a serial configuration instead") endif(MPI_FOUND) endif() # Mandate a system or user-provided Boost, including some libraries # DAKOTA requires Boost 1.37 or newer; PGI may demand 1.40 or newer if(HAVE_ACRO) # Acro requires the signals library in addition find_package(Boost 1.37 REQUIRED COMPONENTS regex signals) else() find_package(Boost 1.37 REQUIRED COMPONENTS regex) endif()

include(CTest) set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/config/share ${CMAKE_CURRENT_SOURCE_DIR}/config/share/utils ${CMAKE_CURRENT_SOURCE_DIR}/config/share/package_arch ${CMAKE_CURRENT_SOURCE_DIR}/config/share/config_tests ${CMAKE_MODULE_PATH} ) option(HAVE_PECOS "Build the Pecos package." ON) # WJB - ToDo with Zack - ASAP: option(HAVE_ACRO "Build the ACRO package." ON) option(HAVE_AMPL "Build the AMPL package." ON) option(HAVE_DDACE "Build the DDACE package." ON) option(HAVE_DOT "Build the DOT package." OFF) option(HAVE_CONMIN "Build the CONMIN package." ON) option(HAVE_FSUDACE "Build the FSUDACE package." ON) option(HAVE_HOPSPACK "Build the hopspack package." OFF) option(HAVE_JEGA "Build the JEGA package." ON) option(HAVE_NCSUOPT "Build the NCSUOPT package." ON) option(HAVE_NL2SOL "Build the NL2SOL package." ON) option(HAVE_NPSOL "Build the NPSOL package." ON) option(HAVE_NLPQL "Build the NLPQL package." ON) option(HAVE_OPTPP "Build the OPTPP package." ON) option(HAVE_PSUADE "Build the PSUADE package." ON) option(HAVE_SURFPACK "Build the Surfpack package." ON) option(HAVE_TRACKING "Build the DAKOTA usage tracker module." ON) option(HAVE_XDR "Build the XDR interface module." ON) option(HAVE_SCILAB "Build Scilab module, if Scilab is detected." ON) option(USE_SYSTEM_TEUCHOS "If false, DAKOTA will use the included version of Teuchos." OFF) #if(USE_SYSTEM_TEUCHOS) # # WJB: suspect SYSTEM_TEUCHOS settings specify incorrect paths -- try to get # # a review from someone interested in this case being enabled # find_package(Trilinos REQUIRED) # ## Kitware version -- include(${Trilinos_DIR}/TrilinosConfig.cmake) # include(${Trilinos_DIR}/TeuchosConfig.cmake) # ##set(Teuchos_INCLUDE_DIRS ${Trilinos_INCLUDE_DIRS} CACHE FILEPATH "include d ir for Teuchos" FORCE) # ##set(Teuchos_LIBRARY_DIRS ${Trilinos_LIBRARY_DIRS} CACHE FILEPATH "library d ir for Teuchos" FORCE) #else() # set(Teuchos_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/packages/teuchos/src # ${CMAKE_CURRENT_BINARY_DIR}/packages/teuchos/src) # set(Teuchos_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR}/packages/teuchos/src) #endif() # Set the export name for install targets; parent packages likely want # to override this to the name of their target set(ExportTarget ${CMAKE_PROJECT_NAME}-targets CACHE STRING "Name for the export target for ${CMAKE_PROJECT_NAME}") # TODO: Have etphipp remove Trilinos-specific code and instead set in TriKota if (BUILD_IN_TRILINOS) set(ExportTarget Trilinos)

endif() # when building inside Trilinos, the path to Teuchos will already be set if (NOT BUILD_IN_TRILINOS) # first probe for system-installed Trilinos # this will respect Trilinos_DIR if already set find_package(Trilinos QUIET) if ( NOT Trilinos_DIR ) # if no one has configured a local src Teuchos, do so # this will respect Teuchos_DIR if already set if( NOT Teuchos_DIR ) set( Teuchos_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/teuchos ) message( "Setting Teuchos_DIR to ${Teuchos_DIR}" ) add_subdirectory(packages/teuchos) else() message( "in ${CMAKE_CURRENT_BINARY_DIR} Teuchos_DIR already set to ${Teucho s_DIR}" ) endif() find_package( Teuchos NO_MODULE REQUIRED ) else() message( "Using system trilinos in ${Trilinos_DIR}" ) endif() endif() if(HAVE_CONMIN) if ( NOT CONMIN_DIR ) set( CONMIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/CONMIN ) message( "Setting CONMIN_DIR to ${CONMIN_DIR}" ) add_subdirectory(packages/CONMIN) else() message( "in ${CMAKE_CURRENT_BINARY_DIR} CONMIN_DIR already set to ${CONMIN_ DIR}" ) endif() find_package( CONMIN NO_MODULE REQUIRED ) endif(HAVE_CONMIN) if (BUILD_SCILAB_INTERFACE) find_package(Scilab) if (HAVE_SCILAB) ##set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ## ${CMAKE_SOURCE_DIR}) if ( SCILAB_ROOT ) add_definitions("-DDAKOTA_SCILAB") include_directories(${SCILAB_INCLUDE}) set(LINK_OPT set(LINK_OPT set(LINK_OPT set(LINK_OPT "-Wl,-rpath,${SCILAB_ROOT}/lib/scilab") "${LINK_OPT} -Wl,-rpath-link,${SCILAB_ROOT}/lib/scilab") "${LINK_OPT} -Wl,-rpath,${SCILAB_ROOT}/lib/thirdparty") "${LINK_OPT} -Wl,-rpath-link,${SCILAB_ROOT}/lib/thirdparty")

if (EXISTS ${SCILAB_ROOT}/thirdparty/java/lib/amd64) set(LINK_OPT_ARCH "amd64") else (EXISTS ${SCILAB_ROOT}/thirdparty/java/lib/amd64) set(LINK_OPT_ARCH "i386")

endif (EXISTS ${SCILAB_ROOT}/thirdparty/java/lib/amd64) set(LINK_OPT "${LINK_OPT} -Wl,-rpath,${SCILAB_ROOT}/thirdparty/java/lib/${ LINK_OPT_ARCH}") set(LINK_OPT "${LINK_OPT} -Wl,-rpath-link,${SCILAB_ROOT}/thirdparty/java/l ib/${LINK_OPT_ARCH}") set(LINK_OPT "${LINK_OPT} -Wl,-rpath,${SCILAB_ROOT}/thirdparty/java/lib/${ LINK_OPT_ARCH}/server") set(LINK_OPT "${LINK_OPT} -Wl,-rpath-link,${SCILAB_ROOT}/thirdparty/java/l ib/${LINK_OPT_ARCH}/") else ( SCILAB_ROOT ) message( "Scilab not found" ) endif ( SCILAB_ROOT ) endif (HAVE_SCILAB) endif (BUILD_SCILAB_INTERFACE) #Keep track of what libraries should be included in libdakota ## WJB - ToDo: determine whether this is needed at the top-level set(SUBLIBS dakota_src) # Manage option for graphics (default ON if possible) option(HAVE_X_GRAPHICS "Build the DAKOTA/Motif Graphics package." ON) if (HAVE_X_GRAPHICS) find_package(X11) if (X11_FOUND) find_package(Motif) if (MOTIF_FOUND) include(FindThreads) if (Threads_FOUND) message(" All X_GRAPHICS dependencies have been found; 2D graphics will be ENABLED in dakota as requested.") else() message(WARNING "HAVE_X_GRAPHICS requested, but threads not found; disabling.") set(HAVE_X_GRAPHICS OFF CACHE BOOL "X graphics OFF on MOST PLATFORMS" FORCE) endif(Threads_FOUND) else() message(WARNING "HAVE_X_GRAPHICS requested, but Motif not found; disabling.") set(HAVE_X_GRAPHICS OFF CACHE BOOL "X graphics OFF on MOST PLATFORMS" FORCE) endif(MOTIF_FOUND) else() message(WARNING "HAVE_X_GRAPHICS requested, but X11 not found; disabling.") set(HAVE_X_GRAPHICS OFF CACHE BOOL "X graphics OFF on MOST PLATFORMS" FORCE) endif(X11_FOUND) endif(HAVE_X_GRAPHICS) add_subdirectory(packages) add_subdirectory(src) #add_subdirectory(examples) #add_subdirectory(test) # Package-specific configuration options include_directories(${Dakota_BINARY_DIR})

configure_file("${Dakota_SOURCE_DIR}/config/dakota_config.h.in" "${Dakota_BINARY_DIR}/dakota_config.h" @ONLY ) add_definitions("-DHAVE_CONFIG_H") file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs) set(docs_files Ref_Interface.dox Ref_Method.dox Ref_Model.dox Ref_Responses.dox Ref_Strategy.dox Ref_Variables.dox ) foreach(doc ${docs_files}) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/docs/${doc} ${CMAKE_CURRENT_BINARY_DIR}/docs/${doc} COPYONLY) endforeach() #generate dakota.input.desc find_package(Perl REQUIRED) ADD_CUSTOM_COMMAND( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dakota.input.desc" COMMAND ${PERL_EXECUTABLE} generate_desc.pl WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) #clean up binary dir #file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/docs) option(ENABLE_DAKOTA_TESTS "Enable Dakota tests." ON) if(ENABLE_DAKOTA_TESTS) add_subdirectory(test) endif() option(ENABLE_SPEC_MAINT "Enable DAKOTA specification maintenance mode." OFF) if(ENABLE_SPEC_MAINT AND NOT UNIX) message(FATAL_ERROR "DAKOTA specification maintenance mode only available on U NIX platforms") endif() option(ENABLE_DAKOTA_DOCS "Enable DAKOTA documentation build." OFF) if(ENABLE_DAKOTA_DOCS) if(UNIX) add_subdirectory(docs) else() message(FATAL_ERROR "DAKOTA documentation build only available on UNIX platf orms") endif() endif()

You might also like