Skip to content
Snippets Groups Projects
Commit fe8a08ad authored by Markus Blatt's avatar Markus Blatt
Browse files

First version DUNE cmake support.

Configure stage runs through, the rest is still untested.
parent 947438a9
No related branches found
No related tags found
No related merge requests found
Showing
with 312 additions and 0 deletions
# set up project
project("dune-uggrid" C CXX)
#circumvent not building docs
set(BUILD_DOCS 1)
# general stuff
cmake_minimum_required(VERSION 2.8.12)
#find dune-common and set the module path
find_package(dune-common)
list(APPEND CMAKE_MODULE_PATH ${dune-common_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake/modules")# make sure our own modules are found
#include the dune macros
include(DuneMacros)
# start a dune project with information from dune.module
dune_project()
find_package(FLEX)
find_package(BISON)
# set defines that are only used internally.
# The rest is in cmake/modules/DuneUggrid.cmake
set(UG_ENABLE_DEBUGGING False CACHE BOOL "Enable UG debugging (default is Off)")
set(UG_ENABLE_2D True CACHE BOOL "Build library for 2d (default is On)")
set(UG_ENABLE_3D True CACHE BOOL "Build library for 3d (default is On)")
set(UG_DDD_MACROBITS "24" CACHE STRING
"Set number of bits of an unsigned int used to store the process number,
the remaining bits are used to store the local entity id")
#set the include headers
include_directories(${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/low
${PROJECT_SOURCE_DIR}/gm ${PROJECT_SOURCE_DIR}/dev ${PROJECT_SOURCE_DIR}/dom
${PROJECT_SOURCE_DIR}/np ${PROJECT_SOURCE_DIR}/ui
${PROJECT_SOURCE_DIR}/graphics/uggraph ${PROJECT_SOURCE_DIR}/np/algebra
${PROJECT_SOURCE_DIR}/np/udm ${PROJECT_SOURCE_DIR}/np/procs
${PROJECT_SOURCE_DIR}/parallel ${PROJECT_SOURCE_DIR}/parallel/ddd
${PROJECT_SOURCE_DIR}/parallel/ppif ${PROJECT_SOURCE_DIR}/ddd/include
${PROJECT_SOURCE_DIR}/parallel/dddif ${PROJECT_SOURCE_DIR}/parallel/util)
add_definitions("UGLIB")
set(UG_ENABLED_DIMENSIONS)
if(UG_ENABLE_2D)
list(APPEND UG_ENABLED_DIMENSIONS "2")
endif()
if(UG_ENABLE_3D)
list(APPEND UG_ENABLED_DIMENSIONS "3")
endif()
macro(ug_expand_object_libs var dim)
set(${var})
foreach(_lib ${ARGN})
#message("_lib=${_lib}")
set(${var} ${${var}} "\$<TARGET_OBJECTS:${_lib}${dim}>")
endforeach()
#message("expanded ${ARGN} with var=${var} dim=${dim} to ${${var}}")
endmacro()
# a macro that creates the libraries for all dimensions.
#
macro(ug_add_dim_libs LIB_NAME)
#message("create ${LIB_NAME} ${ARGN}")
cmake_parse_arguments(ADD_LIB "OBJECT" ""
"SOURCES;SOURCES_2D;SOURCES_3D;OBJECT_LIBS;OBJECT_DIM_LIBS" ${ARGN})
if(ADD_LIB_OBJECT)
set(OBJECT "OBJECT")
# set_property(GLOBAL PROPERTY ${LIB_NAME}_OBJECT_LIBS ${ADD_LIB_OBJECT_LIBS})
# set(ADD_LIB_OBJECT_LIBS "")
# else()
# foreach(lib ${ADD_LIB_OBJECT_LIBS})
# get_property(_saved_libs GLOBAL PROPERTY ${lib}_OBJECT_LIBS)
# set(ADD_LIB_OBJECT_LIBS ${ADD_LIB_OBJECT_LIBS} ${saved_libs})
# endforeach()
# ug_expand_object_libs(OBJECT_LIBS "" ${ADD_LIB_OBJECT_LIBS}
# ${_saved_libs})
endif()
foreach(dim ${UG_ENABLED_DIMENSIONS})
#message("will expand ${dim} ${ADD_LIB_OBJECT_DIM_LIBS}")
# if(ADD_LIB_OBJECT)
# set_property(GLOBAL PROPERTY ${LIB_NAME}_OBJECT_DIM_LIBS
# ${ADD_LIB_OBJECT_DIM_LIBS})
# set(ADD_LIB_OBJECT_DIM_LIBS "")
# else()
# foreach(lib ${ADD_LIB_OBJECT_DIM_LIBS})
# get_property(_saved_libs GLOBAL PROPERTY ${lib}_OBJECT_DIM_LIBS)
# set(ADD_LIB_OBJECT_DIM_LIBS ${ADD_LIB_OBJECT_DIM_LIBS} ${saved_libs})
# endforeach()
# endif()
ug_expand_object_libs(OBJECT_DIM_LIBS ${dim} ${ADD_LIB_OBJECT_DIM_LIBS})
message("creatig lib ${LIB_NAME}${dim}")
add_library("${LIB_NAME}${dim}" ${OBJECT} ${ADD_LIB_SOURCES}
${ADD_LIB_SOURCES_${dim}D}
${ADD_LIB_UNPARSED_ARGUMENTS} ${OBJECT_DIM_LIBS})
target_compile_definitions("${LIB_NAME}${dim}" PRIVATE "_${dim}")
endforeach()
endmacro()
# !!! maybe make this configurable later
set(DYNAMIC_MEMORY_ALLOCMODEL True)
if(UG_ENABLE_DEBUGGING)
add_definitions("Debug")
endif()
check_include_file(alloca.h HAVE_ALLOCA_H)
check_include_file(dirent.h HAVE_DIRENT_H)
check_include_file(float.h HAVE_FLOAT_H)
check_include_file(malloc.h HAVE_MALLOC_H)
check_include_file(memory.h HAVE_MEMORY_H)
check_include_file(stdlib.h HAVE_STDLIB_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(time.h HAVE_TIME_H)
include(CheckFunctionExists)
# Although the define is checked in low/ugmemory.h
# alloca is never called.
#check_function_exists(alloca HAVE_ALLOCA)
# define it unconditionally
set(HAVE_ALLOCA True)
check_function_exists(bzero HAVE_BZERO)
check_function_exists(malloc HAVE_MALLOC)
check_function_exists(memmove HAVE_MEMMOVE)
check_function_exists(memset HAVE_MEMSET)
check_function_exists(realloc HAVE_REALLOX)
check_function_exists(strchr HAVE_STRCHR)
check_function_exists(strstr HAVE_STRSTR)
check_function_exists(strtol HAVE_STRTOL)
# I am not really sure what AC_FUNC_FORK does
# For now just make the checks for defines needed
# for compilation
check_function_exists(vfork HAVE_VFORK)
set(HAVE_WORKING_VFORK "${HAVE_VFORK}")
if(NOT HAVE_ALLOCA_H)
message(SEND_ERROR "Could not find required header alloca.h")
endif()
if(NOT HAVE_ALLOCA)
message(SEND_ERROR "Could not find required function alloca")
endif()
if(HAVE_STRING_H OR HAVE_STRINGS_H)
set(STDC_HEADERS)
endif()
if(HAVE_TIME_H AND HAVE_SYS_TIME_H)
set(TIME_WITH_SYS_TIME True)
endif()
# do everything in the subdirs (order matters!)
set(SUBDIRS parallel low dev gm dom graphics np ui lib tools)
set(CMAKE_INSTALL_PKGINCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/ug")
# install pkg-config information
install(FILES libug.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
#install header
install(FILES initug.h DESTINATION ${CMAKE_INSTALL_PKGINCLUDEDIR})
foreach(i ${SUBDIRS})
if(${i} STREQUAL "test")
set(opt EXCLUDE_FROM_ALL)
endif(${i} STREQUAL "test")
add_subdirectory(${i} ${opt})
unset(opt)
endforeach(i ${SUBDIRS})
add_subdirectory(cmake/modules)
# finalize the dune project, e.g., generate config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
set(modules
DuneCommonMacros.cmake
)
install(FILES "${modules}" DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/modules)
find_package(Flex)
find_package(Bison)
if(MPI_FOUND)
add_definitions("ModelP")
endif()
set(UG_ENABLE_SYSTEM_HEAP True CACHE BOOL
"Whether to use the UG heap or the one of the operating system")
if(UG_ENABLE_SYSTEM_HEAP)
set(UG_USE_SYSTEM_HEAP True)
# The libs from these directories are needed for devices
#add_subdirectory(ppm)
#add_subdirectory(meta)
#add_subdirectory(ps)
set(SOURCES ugdevices.cc sockcomm.cc
ppm/ppm.cc meta/metafile.cc ps/postscript.cc ps/postscriptbw.cc)
set(devincludedir ${CMAKE_INSTALL_INCLUDEDIR})
set(devinclude_HEADERS ugdevices.h)
ug_add_dim_libs(devices OBJECT ${SOURCES})
add_library(devS ${SOURCES} sif/sif.cc)
add_library(devR ${SOURCES} rif/remote.cc)
add_library(devX ${SOURCE} xif/xmain.cc xif/xgraph.cc xif/xshell.cc)
target_compile_definitions(devX PRIVATE "_2")
#add_subdirectory(sif)
#add_subdirectory(xif)
#add_subdirectory(rif)
install(FILES ${devinclude_HEADERS} DESTINATION ${CMAKE_INSTALL_PKGINCLUDEDIR})
# compile the different domain-modules
add_subdirectory(std)
add_subdirectory(lgm)
# does not compile with C++-compiler
# gen
# install the central header
set(domincludedir ${CMAKE_INSTALL_INCLUDEDIR})
set(dominclude_HEADERS domain.h)
install(FILES ${dominclude_HEADERS} DESTINATION ${domincludedir})
ug_add_dim_libs(domG OBJECT SOURCES gen.c gen_parallel.c)
# !!! properly integrate netgen
set(SUBDIRS ngin ngin2d)
add_subdirectory(ngin)
add_subdirectory(ngin2d)
# !!! not good...
set(EXTRA_DIST netgen/lgm_gginterface.h)
set(SOURCES lgm_domain.cc lgm_load.cc lgm_parallel.cc)
ug_add_dim_libs(domL OBJECT SOURCES ${SOURCES}
SOURCES_2D lgm_transfer2d.cc lgm_domain2d.cc
SOURCES_3D lgm_transfer3d.cc lgm_domain3d.cc ansys2lgm.cc lgm_accel.cc)
# OBJECT_DIM_LIBS ngin)
install(FILES lgm_domain.h DESTINATION ${CMAKE_INSTALL_PKGINCLUDEDIR})
# generate header file, rename prefix
bison_target(nginyacc ngin-yacc.yy ${CMAKE_CURRENT_BINARY_DIR}/ngic-yac.cc
COMPILE_FLAGS "-d -p ${PARSERPREFIX}")
flex_target(nginlex ngin-lex.ll ${CMAKE_CURRENT_BINARY_DIR}/ngin-lex.cc
COMPILE_FLAGS "-P${PARSERPREFIX}")
add_library(ngin3 OBJECT ${BISON_nginyacc_OUTPUTS} ${FLEX_nginlex_OUTPUT})
# generate header file, rename prefix
bison_target(nginyacc ngin-yacc.yy ${CMAKE_CURRENT_BINARY_DIR}/ngic-yac.cc
COMPILE_FLAGS "-d -p ${PARSERPREFIX}")
flex_target(nginlex ngin-lex.ll ${CMAKE_CURRENT_BINARY_DIR}/ngin-lex.cc
COMPILE_FLAGS "-P${PARSERPREFIX}")
add_library(ngin2 OBJECT ${BISON_nginyacc_OUTPUTS} ${FLEX_nginlex_OUTPUT})
set(SOURCES std_domain.cc std_parallel.cc) # std_domain.h std_internal.h)
ug_add_dim_libs(domS OBJECT SOURCES ${SOURCES})
install(FILES std_domain.h DESTINATION ${CMAKE_INSTALL_PKGINCLUDEDIR})
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
parallel=@parallel@
fordune=@fordune@
Name: libug
Version: @VERSION@
Description: library for the discretization of PDEs on unstructured grids
Requires:
Libs: -L${libdir} -ldevS @UG_XLIBS@
Cflags: -I${includedir} @UG_EXTRAFLAGS@
Module: dune-uggrid
Version: 3.12.1
Depends: dune-common
Maintainer: ug@conan.iwr.uni-heidelberg.de
Whitespace-Hook: Yes
add_subdirectory(gg2)
add_subdirectory(gg3)
set(SOURCES algebra.cc enrol.cc evm.cc mgio.cc
ugio.cc ugm.cc cw.cc initgm.cc elements.cc
shapes.cc evalproc.cc rm.cc refine.cc smooth.cc
dlmgr.cc gmcheck.cc er.cc mgheapmgr.cc)
# put this "template" into distribution-tarball as well
set(EXTRA_DIST dlmgr.t)
set(gminclude_HEADERS cw.h elements.h gm.h pargm.h evm.h
shapes.h ugm.h dlmgr.h algebra.h rm.h refine.h)
ug_add_dim_libs(ug_gm OBJECT SOURCES ${SOURCES})# OBJECT_DIM_LIBS gg)
install(FILES ${gminclude_HEADERS} DESTINATION ${CMAKE_INSTALL_PKGINCLUDEDIR})
if(UG_ENABLE_2D)
add_library(gg2 OBJECT ggmain.cc ggaccel.cc ggm.cc)
endif()
if(UG_ENABLE_3D)
add_library(gg3 OBJECT gg3d.cc)
endif()
add_subdirectory(uggraph)
add_subdirectory(grape)
set(SOURCES graphics.cc)# graphics.h)
ug_add_dim_libs(graphics OBJECT SOURCES ${SOURCES})
# OBJECT_DIM_LIBS uggraph grape)
install(FILES graphics.h DESTINATION ${CMAKE_INSTALL_PKGINCLUDEDIR})
ug_add_dim_libs(uggrape OBJECT SOURCES connectuggrapeOFF.cc)
set(SOURCES wpm.cc graph.cc wop.cc initgraph.cc plotproc.cc placer.cc bullet.cc)
# bullet.h graph.h initgraph.h plotproc.h wop.h wpm.h iso.cc iso.h pixel.h)
ug_add_dim_libs(uggraph OBJECT SOURCES ${SOURCES})
add_subdirectory(ugdata)
if(MPI_FOUND)
set(_parallel parallel ddd analyser basic ctrl ident if join mgr prio xfer dddif)
endif()
set(_libs ug_gm gg np algebra amg field procs udm graphics uggrape uggraph ugui devices low)
ug_add_dim_libs(ugL SOURCES ../initug.cc OBJECT_DIM_LIBS ${_libs} domL ngin)
ug_add_dim_libs(ugS SOURCES ../initug.cc OBJECT_DIM_LIBS ${_libs} domS ${_parallel})
# install into share-directory
set(dist_data_DATA helpfile.list RefRules.data tetra.rls triangle.rls)
install(FILES ${dist_data_DATA} DESTINATION ${CMAKE_INSTALL_DATADIR})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment