Skip to content

Commit

Permalink
Add support for CMake builds
Browse files Browse the repository at this point in the history
  • Loading branch information
drummerdoc committed Sep 8, 2011
1 parent 5f65fa2 commit 35073eb
Show file tree
Hide file tree
Showing 17 changed files with 1,349 additions and 0 deletions.
71 changes: 71 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- mode: cmake -*-

# Require cmake 2.8 or higher
cmake_minimum_required(VERSION 2.8.2)

if ("${CMAKE_PATCH_VERSION}" GREATER 3)
set(ADJUST_POLICY "True")
endif()

if (${ADJUST_POLICY})
cmake_policy(SET CMP0017 NEW)
endif()

# Enable testing, ctest needs this
# all add_test commands are ignored unless this is called!
enable_testing()

# must be set prior to any project definition
if (ENABLE_MPI)
set(CMAKE_C_COMPILER "${MPI_PREFIX}/bin/mpicc")
set(CMAKE_CXX_COMPILER "${MPI_PREFIX}/bin/mpic++")
set(CMAKE_Fortran_COMPILER "${MPI_PREFIX}/bin/mpif90")
endif()


# Useful variables pointing to directories in the source tree
set(CCSE_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(CCSE_TOOLS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Tools")
set(CCSE_PERL_DIR "${CCSE_TOOLS_DIR}/C_scripts")
set(CCSE_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/install")

# Set the module search path so find_package and include commands
# can locate files in <root source tree>/tools/cmake
set(CCSE_MODULE_PATH "${CCSE_TOOLS_DIR}/CMake")
set(CMAKE_MODULE_PATH ${CCSE_MODULE_PATH})

# Addtional build options
include(CCSEOptions)

# Define the project name
# This command will define
# CCSE_SOURCE_DIR
# CCSE_BINARY_DIR
project(CCSE)

# Source files for all binaries and libraries found under src
add_subdirectory(Src)

if (${CCSE_INSTALL_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
else ()
install(FILES ${CCSE_PERL_DIR}/strip72
DESTINATION ${CCSE_INSTALL_DIR}/perl)
endif ()

option(ENABLE_Config_Report "Print out detailed information at the end of a configuration")
set(CCSE_CONFIG_LOG "${CCSE_BINARY_DIR}/amanzi-config.log"
CACHE string "CCSE configuration log file")
include(CCSEConfigReport)
if (ENABLE_Config_Report)
set(cat_exec "cat")
if (WIN32)
if( NOT UNIX)
set(cat_exec "type")
endif(NOT UNIX)
endif(WIN32)

execute_process(COMMAND "${cat_exec}" "${CCSE_CONFIG_LOG}" OUTPUT_VARIABLE config_output)
message(STATUS "contents of: ${CCSE_CONFIG_LOG}")
message(STATUS "${config_output}")
endif()

32 changes: 32 additions & 0 deletions Src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

set(CBOXDIR C_BaseLib)
set(FBOXDIR F_BaseLib)
set(CBNDRYDIR C_BoundaryLib)
set(CAMRDIR C_AMRLib)
set(CMGDIR LinearSolvers/C_CellMG)
set(CFMGDIR LinearSolvers/C_to_F_MG)
set(FMGDIR LinearSolvers/F_MG)
set(CAMRDATADIR Extern/amrdata)

# Pick one place to put modules so everyone can see them
set(CMAKE_FORTRAN_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${FBOXDIR} CACHE PATH "Folder for fortran module files")

set(CBOXLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${CBOXDIR} ${CMAKE_CURRENT_SOURCE_DIR}/${CBNDRYDIR} ${CMAKE_CURRENT_SOURCE_DIR}/${CAMRDIR} ${CMAKE_CURRENT_SOURCE_DIR}/${CMGDIR} ${CMAKE_CURRENT_SOURCE_DIR}/${CFMGDIR} ${CMAKE_CURRENT_SOURCE_DIR}/${CAMRDATADIR} ${BOXLIB_EXTRA_INCLUDE_PATH})

include(PreprocessBoxLibFortran)

add_subdirectory(${CBOXDIR})
add_subdirectory(${CBNDRYDIR})
add_subdirectory(${CAMRDIR})
add_subdirectory(${CMGDIR})

set(FBOXLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${FBOXDIR} ${CMAKE_CURRENT_SOURCE_DIR}/${FMGDIR})

add_subdirectory(${FBOXDIR})
add_subdirectory(${FMGDIR})

add_subdirectory(${CFMGDIR})
add_subdirectory(${CAMRDATADIR})

add_subdirectory(Extern/gslib)

58 changes: 58 additions & 0 deletions Src/C_AMRLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -*- mode: cmake -*-

include(TestManager)

#
# Define a project name
# After this command the following varaibles are defined
# CAMRLIB_SOURCE_DIR
# CAMRLIB_BINARY_DIR
# Other projects (subdirectories) can reference this directory
# through these variables.
project(CAMRLIB)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CBOXLIB_INCLUDE_DIRS})

set(CXX_source_files Amr.cpp AmrLevel.cpp AuxBoundaryData.cpp BCRec.cpp Cluster.cpp DatasetClient.cpp Derive.cpp ErrorList.cpp FluxRegister.cpp Interpolater.cpp SlabStat.cpp StateData.cpp StateDescriptor.cpp StationData.cpp TagBox.cpp)
set(FPP_source_files ARRAYLIM_${BL_SPACEDIM}D.F FILCC_${BL_SPACEDIM}D.F FLUXREG_${BL_SPACEDIM}D.F INTERP_${BL_SPACEDIM}D.F SLABSTAT_${BL_SPACEDIM}D.F)
if(BL_SPACEDIM EQUAL 3)
set(FPP_source_files ${FPP_source_files} MAKESLICE_${BL_SPACEDIM}D.F)
endif()
if(BL_USE_PARTICLES EQUAL TRUE)
list(APPEND CXX_source_files Particles.cpp)
list(APPEND FPP_source_files Particles_${BL_SPACEDIM}D.F)
list(APPEND FPP_header_files Particles_F.H)
endif()
set(F77_source_files)
set(F90_source_files)

set(CXX_header_files Amr.H AmrLevel.H AuxBoundaryData.H BCRec.H BC_TYPES.H Cluster.H DatasetClient.H Derive.H ErrorList.H FluxRegister.H INTERP_F.H Interpolater.H LevelBld.H PROB_AMR_F.H SLABSTAT_F.H SlabStat.H StateData.H StateDescriptor.H StationData.H TagBox.H)
set(FPP_header_files FLUSH_F.H FLUXREG_F.H Particles_F.H )
if(BL_SPACEDIM EQUAL 3)
list(APPEND FPP_header_files MAKESLICE_F.H)
endif()
set(F77_header_files bc_types.fi)
set(F90_header_files)

preprocess_boxlib_fortran(FPP_out_files ${FPP_source_files})

set(local_source_files ${FPP_out_files} ${F77_source_files} ${F90_source_files} ${CXX_source_files})
set(local_header_files ${CXX_header_files} ${F77_header_files} ${FPP_header_files} ${F90_header_files})
add_library(box_camr ${local_source_files})

install(TARGETS box_camr
LIBRARY DESTINATION ${CCSE_INSTALL_DIR}/lib${MPI_SUFFIX}${OMP_SUFFIX}
ARCHIVE DESTINATION ${CCSE_INSTALL_DIR}/lib${MPI_SUFFIX}${OMP_SUFFIX}
CONFIGURATIONS ${CMAKE_BUILD_TYPE}
)

if (${CCSE_INSTALL_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
else ()
install(FILES ${local_header_files}
DESTINATION ${CCSE_INSTALL_DIR}/include)
endif ()

if (BUILD_TESTS)

endif()
73 changes: 73 additions & 0 deletions Src/C_BaseLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# -*- mode: cmake -*-

include(TestManager)

#
# Define a project name
# After this command the following variables are defined
# CBOXLIB_SOURCE_DIR
# CBOXLIB_BINARY_DIR
# Other projects (subdirectories) can reference this directory
# through these variables.
project(CBOXLIB)

include_directories(${CBOXLIB_INCLUDE_DIRS})

set(CXX_source_files Arena.cpp BArena.cpp BaseFab.cpp BoxArray.cpp Box.cpp BoxDomain.cpp BoxLib.cpp BoxList.cpp CArena.cpp CoordSys.cpp DistributionMapping.cpp FabArray.cpp FabConv.cpp FArrayBox.cpp FPC.cpp Geometry.cpp IndexType.cpp IntVect.cpp MultiFab.cpp Orientation.cpp ParallelDescriptor.cpp ParmParse.cpp RealBox.cpp UseCount.cpp Utility.cpp VisMF.cpp)
set(F77_source_files BLBoxLib_F.f bl_flush.f BLParmParse_F.f BLutil_F.f)
set(FPP_source_files COORDSYS_${BL_SPACEDIM}D.F SPECIALIZE_${BL_SPACEDIM}D.F)
set(F90_source_files)

set(CXX_header_files Arena.H Array.H ArrayLim.H BArena.H BaseFab.H BLassert.H BLFort.H BoxArray.H BoxDomain.H Box.H BoxLib.H BoxList.H CArena.H ccse-mpi.H CONSTANTS.H CoordSys.H DistributionMapping.H FabArray.H FabConv.H FArrayBox.H FPC.H Geometry.H IndexType.H IntVect.H Looping.H MultiFab.H Orientation.H ParallelDescriptor.H ParmParse.H PArray.H Pointers.H Profiler.H RealBox.H REAL.H SPACE.H Tuple.H UseCount.H Utility.H VisMF.H winstd.H)
set(F77_header_files)
set(FPP_header_files COORDSYS_F.H SPACE_F.H SPECIALIZE_F.H)
set(F90_header_files)


preprocess_boxlib_fortran(FPP_out_files ${FPP_source_files})
set(local_source_files ${CXX_source_files} ${F77_source_files} ${FPP_out_files} ${F90_source_files})
set(local_header_files ${CXX_header_files} ${F77_header_files} ${FPP_header_files} ${F90_header_files})
add_library(box_c ${local_source_files})

install(TARGETS box_c
LIBRARY DESTINATION ${CCSE_INSTALL_DIR}/lib${MPI_SUFFIX}${OMP_SUFFIX}
ARCHIVE DESTINATION ${CCSE_INSTALL_DIR}/lib${MPI_SUFFIX}${OMP_SUFFIX}
CONFIGURATIONS ${CMAKE_BUILD_TYPE}
)

if (${CCSE_INSTALL_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
else ()
install(FILES ${local_header_files}
DESTINATION ${CCSE_INSTALL_DIR}/include)
endif ()


#if (BUILD_TESTS AND BL_SPACEDIM EQUAL 3)
# # Add UnitTest include directories
# include_directories(${UnitTest_INCLUDE_DIRS})

# set(BOXLIB_FILE_DIR "${BOXLIB_SOURCE_DIR}/test")

# set(tBA_args ${BOXLIB_FILE_DIR}/ba.213 ${BOXLIB_FILE_DIR}/ba.60)
# add_executable(boxlib_tBA test/tBA.cpp)
# target_link_libraries(boxlib_tBA boxlib ${BOXLIB_EXTRA_LIBRARIES} ${UnitTest_LIBRARIES})
# add_ccse_test("boxlib_1_tBA" "boxlib_tBA" KIND unit "${tBA_args}")

# set(tDir_args "Testing/Temporary/dir_created_by_tDir_remove_me")
# add_executable(boxlib_tDir test/tDir.cpp)
# target_link_libraries(boxlib_tDir boxlib ${BOXLIB_EXTRA_LIBRARIES} ${UnitTest_LIBRARIES})
# add_ccse_test("boxlib_2_tDir" "boxlib_tDir" KIND unit "${tDir_args}")

# set(tDM_args ${BOXLIB_FILE_DIR}/ba.213 ${BOXLIB_FILE_DIR}/ba.60)
# add_executable(boxlib_tDM test/tDM.cpp)
# target_link_libraries(boxlib_tDM boxlib ${BOXLIB_EXTRA_LIBRARIES} ${UnitTest_LIBRARIES})
# add_ccse_test("boxlib_3_tDM" "boxlib_tDM" KIND unit "${tDM_args}")

# if(BOXLIB_IS_PARALLEL)
# set(tPD_args)
# add_executable(boxlib_tPD test/tPD.cpp)
# target_link_libraries(boxlib_tPD boxlib ${BOXLIB_EXTRA_LIBRARIES} ${UnitTest_LIBRARIES})
# add_ccse_test("boxlib_4_tPD" "boxlib_tPD" KIND unit NPROCS 8 "${tPD_args}")
# endif()
#endif()

47 changes: 47 additions & 0 deletions Src/C_BoundaryLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- mode: cmake -*-

include(TestManager)

#
# Define a project name
# After this command the following varaibles are defined
# CBNDRYLIB_SOURCE_DIR
# CBNDRYLIB_BINARY_DIR
# Other projects (subdirectories) can reference this directory
# through these variables.
project(CBNDRYLIB)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CBOXLIB_INCLUDE_DIRS})

set(CXX_source_files BndryData.cpp BndryRegister.cpp FabSet.cpp InterpBndryData.cpp MacBndry.cpp Mask.cpp)
set(FPP_source_files INTERPBNDRYDATA_${BL_SPACEDIM}D.F LO_UTIL.F )
set(F77_source_files)
set(F90_source_files)

set(CXX_header_files BndryData.H BndryRegister.H BoundCond.H FabSet.H InterpBndryData.H LO_BCTYPES.H MacBndry.H Mask.H)
set(FPP_header_files INTERPBNDRYDATA_F.H)
set(F77_header_files)
set(F90_header_files)

preprocess_boxlib_fortran(FPP_out_files ${FPP_source_files})
set(local_source_files ${CXX_source_files} ${F77_source_files} ${FPP_out_files} ${F90_source_files})
set(local_header_files ${CXX_header_files} ${F77_header_files} ${FPP_header_files} ${F90_header_files})
add_library(box_cbndry ${local_source_files})

install(TARGETS box_cbndry
LIBRARY DESTINATION ${CCSE_INSTALL_DIR}/lib${MPI_SUFFIX}${OMP_SUFFIX}
ARCHIVE DESTINATION ${CCSE_INSTALL_DIR}/lib${MPI_SUFFIX}${OMP_SUFFIX}
CONFIGURATIONS ${CMAKE_BUILD_TYPE}
)

if (${CCSE_INSTALL_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
else ()
install(FILES ${local_header_files}
DESTINATION ${CCSE_INSTALL_DIR}/include)
endif ()

if (BUILD_TESTS)

endif()

53 changes: 53 additions & 0 deletions Src/F_BaseLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# -*- mode: cmake -*-

include(TestManager)

#
# Define a project name
# After this command the following variables are defined
# FBOXLIB_SOURCE_DIR
# FBOXLIB_BINARY_DIR
# Other projects (subdirectories) can reference this directory
# through these variables.
project(FBOXLIB)

include_directories(${FBOXLIB_INCLUDE_DIRS})

set(CXX_source_files)
set(C_source_files fabio_c.c timer_c.c)
set(F77_source_files)
set(FPP_source_files)
set(F90_source_files bc.f90 bl_constants.f90 bl_error.f90 bl_IO.f90 bl_stream.f90 bl_string.f90 bl_timer.f90 bl_types.f90 bl_mem_stat.f90 bl_space.f90 bl_prof_stubs.f90 bndry_reg.f90 box_f.f90 boxarray_f.f90 fab.f90 fabio.f90 knapsack.f90 layout.f90 list_box.f90 ml_boxarray.f90 ml_layout.f90 ml_multifab.f90 multifab_f.f90 sort_box.f90 sort_d.f90 sort_i.f90 vector_i.f90)

if (ENABLE_MPI)
list(APPEND F90_source_files parallel.f90)
else()
list(APPEND F90_source_files parallel_stubs.f90)
endif()

set(CXX_header_files)
set(F77_header_files)
set(FPP_header_files)
set(F90_header_files)

preprocess_boxlib_fortran(FPP_out_files ${FPP_source_files})

set(local_source_files ${C_source_files} ${CXX_source_files} ${F77_source_files} ${FPP_out_files} ${F90_source_files})
set(local_header_files ${CXX_header_files} ${F77_header_files} ${FPP_header_files} ${F90_header_files})
add_library(box_f ${local_source_files})

install(TARGETS box_f
LIBRARY DESTINATION ${CCSE_INSTALL_DIR}/lib${MPI_SUFFIX}${OMP_SUFFIX}
ARCHIVE DESTINATION ${CCSE_INSTALL_DIR}/lib${MPI_SUFFIX}${OMP_SUFFIX}
CONFIGURATIONS ${CMAKE_BUILD_TYPE}
)

if (${CCSE_INSTALL_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
else ()
install(FILES ${local_header_files}
DESTINATION ${CCSE_INSTALL_DIR}/include)
endif ()

if (BUILD_TESTS AND BL_SPACEDIM EQUAL 3)
endif()

50 changes: 50 additions & 0 deletions Src/LinearSolvers/C_CellMG/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- mode: cmake -*-

include(TestManager)

#
# Define a project name
# After this command the following varaibles are defined
# CMGLIB_SOURCE_DIR
# CMGLIB_BINARY_DIR
# Other projects (subdirectories) can reference this directory
# through these variables.
project(CMGLIB)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CBOXLIB_INCLUDE_DIRS})

set(CXX_source_files ABecLaplacian.cpp CGSolver.cpp Laplacian.cpp LinOp.cpp MultiGrid.cpp)
set(FPP_source_files ABec_${BL_SPACEDIM}D.F ABec_UTIL.F CG_${BL_SPACEDIM}D.F LO_${BL_SPACEDIM}D.F LP_${BL_SPACEDIM}D.F MG_${BL_SPACEDIM}D.F)
set(F77_source_files)
set(F90_source_files)

set(CXX_header_files ABecLaplacian.H CGSolver.H Laplacian.H LinOp.H MG_F.H MultiGrid.H)
set(FPP_header_files ABec_F.H CG_F.H LO_F.H LP_F.H MG_F.H)
set(F77_header_files lo_bctypes.fi)
set(F90_header_files)



preprocess_boxlib_fortran(FPP_out_files ${FPP_source_files})

set(local_source_files ${FPP_out_files} ${F77_source_files} ${F90_source_files} ${CXX_source_files})
set(local_header_files ${FPP_header_files} ${F77_header_files} ${F90_header_files} ${CXX_header_files})
add_library(box_cmg ${local_source_files})

install(TARGETS box_cmg
LIBRARY DESTINATION ${CCSE_INSTALL_DIR}/lib${MPI_SUFFIX}${OMP_SUFFIX}
ARCHIVE DESTINATION ${CCSE_INSTALL_DIR}/lib${MPI_SUFFIX}${OMP_SUFFIX}
CONFIGURATIONS ${CMAKE_BUILD_TYPE}
)

if (${CCSE_INSTALL_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
else ()
install(FILES ${local_header_files}
DESTINATION ${CCSE_INSTALL_DIR}/include)
endif ()

if (BUILD_TESTS)

endif()

Loading

0 comments on commit 35073eb

Please sign in to comment.