Select Git revision
CMakeLists.txt

Van Dung NGUYEN authored
CMakeLists.txt 3.55 KiB
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
if(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type")
else(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose build type")
endif(DEFINED CMAKE_BUILD_TYPE)
if(CMAKE_BUILD_TYPE MATCHES "debug")
set(INDEBUG TRUE)
elseif(CMAKE_BUILD_TYPE MATCHES "Debug")
set(INDEBUG TRUE)
else()
set(INDEBUG FALSE)
endif(CMAKE_BUILD_TYPE MATCHES "debug")
if(INDEBUG)
set(CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -D_DEBUG")
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -D_DEBUG")
endif(INDEBUG)
if(INDEBUG AND NOT CM3APPS)
set(LIBDG3DNAME "dG3DpyDebug")
else()
set(LIBDG3DNAME "dG3Dpy")
endif(INDEBUG AND NOT CM3APPS)
set(CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -DNONLOCALGMSH")
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -DNONLOCALGMSH")
if(ENABLE_CXX11)
# in recent cmake versions we could do e.g. set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -std=c++0x")
endif(ENABLE_CXX11)
project(dG3D CXX)
macro(append_dG3D_src DIRNAME FILES)
foreach(FILE ${FILES})
list(APPEND LIST ${DIRNAME}/${FILE})
endforeach(FILE)
set(DG3D_SRC ${DG3D_SRC};${LIST} PARENT_SCOPE)
set(DG3D_DIRS ${DG3D_DIRS};${DIRNAME} PARENT_SCOPE)
endmacro(append_dG3D_src)
if(CM3APPS AND BUILD_TESTING)
add_subdirectory(benchmarks)
endif(CM3APPS AND BUILD_TESTING)
if (NOT CM3APPS)
add_subdirectory(../NonLinearSolver "${CMAKE_CURRENT_BINARY_DIR}/NonLinearSolver")
endif(NOT CM3APPS)
add_subdirectory("src")
if(NOT CM3APPS)
include_directories(src ../../gmsh/Common ../../gmsh/Numeric ../../gmsh/Geo ../../gmsh/Mesh
../../gmsh/Solver ../../gmsh/Post ../../gmsh/Plugin ../../gmsh/Graphics ../NonLinearSolver/internalPoints ../NonLinearSolver/nlsolver ../NonLinearSolver ../NonLinearSolver/Interface ../NonLinearSolver/contact ../NonLinearSolver/materialLaw ../NonLinearSolver/Domain ../NonLinearSolver/BoundaryConditions ../NonLinearSolver/nlTerms ../NonLinearSolver/field ../NonLinearSolver/space ../NonLinearSolver/restart ${GMSH_EXTERNAL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/NonLinearSolver/gmsh/Common ../../gmsh/contrib/gmm ${CMAKE_CURRENT_BINARY_DIR}/NonLinearSolver ../NonLinearSolver/periodicBC $ENV{NLSMPIINC})
endif(NOT CM3APPS)
file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src *.h)
if(HAVE_MPI)
cmake_force_cxx_compiler(${MPI_COMPILER} "MPI C++ Compiler")
endif(HAVE_MPI)
# new swig
if(INDEBUG AND NOT CM3APPS)
add_library(dG3DDebug SHARED EXCLUDE_FROM_ALL ${DG3D_SRC})
target_link_libraries(dG3DDebug ${EXTERNAL_LIBRARIES} shared nlsolverDebug)
else()
add_library(dG3D SHARED EXCLUDE_FROM_ALL ${DG3D_SRC})
target_link_libraries(dG3D ${EXTERNAL_LIBRARIES} shared nlsolver)
endif(INDEBUG AND NOT CM3APPS)
if(ENABLE_WRAP_PYTHON_DEPRECATED)
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_DIR})
set_source_files_properties(src/dG3Dpy.i PROPERTIES CPLUSPLUS ON)
if(INDEBUG AND NOT CM3APPS)
set_source_files_properties(src/dG3Dpy.i PROPERTIES SWIG_FLAGS "-D_DEBUG")
endif(INDEBUG AND NOT CM3APPS)
swig_add_module(${LIBDG3DNAME} python src/dG3Dpy.i)
if(INDEBUG AND NOT CM3APPS)
swig_link_libraries(${LIBDG3DNAME} ${PYTHON_LIBRARIES} dG3DDebug)
else()
swig_link_libraries(${LIBDG3DNAME} ${PYTHON_LIBRARIES} dG3D)
endif(INDEBUG AND NOT CM3APPS)
add_custom_command(TARGET _${LIBDG3DNAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/dG3DpyPYTHON_wrap.cxx)
endif(ENABLE_WRAP_PYTHON_DEPRECATED)