Snippets

Created by Franco Milicchio last modified
cmake_minimum_required(VERSION 3.7)

project(test2016_2)

set(CMAKE_CXX_STANDARD 14)

# Set CMake behavior
cmake_policy(SET CMP0004 NEW)

# Get DOLFIN configuration data (DOLFINConfig.cmake must be in
# DOLFIN_CMAKE_CONFIG_PATH)
find_package(DOLFIN REQUIRED)

set(CMAKE_BUILD_TYPE "Release")

if (EXISTS ${DOLFIN_USE_FILE})
    include(${DOLFIN_USE_FILE})

    # Default build type (can be overridden by user)
    if (NOT CMAKE_BUILD_TYPE)
        set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
                "Choose the type of build, options are: Debug MinSizeRel Release RelWithDebInfo." FORCE)
    endif()

    # Do not throw error for 'multi-line comments' (these are typical in
    # rst which includes LaTeX)
    include(CheckCXXCompilerFlag)
    CHECK_CXX_COMPILER_FLAG("-Wno-comment" HAVE_NO_MULTLINE)
    if (HAVE_NO_MULTLINE)
        set(CMAKE_CXX_FLAGS "-Wno-comment ${CMAKE_CXX_FLAGS}")
    endif()

else()
    # Compiler definitions
    add_definitions(${DOLFIN_CXX_DEFINITIONS})

    # Compiler flags
    set(CMAKE_CXX_FLAGS "${DOLFIN_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")

    # Do not throw error for 'multi-line comments' (these are typical in
    # rst which includes LaTeX)
    include(CheckCXXCompilerFlag)
    CHECK_CXX_COMPILER_FLAG("-Wno-comment" HAVE_NO_MULTLINE)
    if (HAVE_NO_MULTLINE)
        set(CMAKE_CXX_FLAGS "-Wno-comment ${CMAKE_CXX_FLAGS}")
    endif()

    # Include directories
    include_directories(${DOLFIN_INCLUDE_DIRS})
    include_directories(SYSTEM ${DOLFIN_3RD_PARTY_INCLUDE_DIRS})
endif()

set(MKLROOT "/opt/intel/compilers_and_libraries/mac/mkl")
set(OMPROOT "/opt/intel/compilers_and_libraries/mac")

set(CMAKE_CXX_FLAGS "-DEIGEN_USE_MKL_ALL -m64 -I${MKLROOT}/include -Ofast ${CMAKE_CXX_FLAGS}")

set(CMAKE_EXE_LINKER_FLAGS "-L${MKLROOT}/lib -L${OMPROOT}/lib -Wl,-rpath,${MKLROOT}/lib -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm -ldl ${CMAKE_EXE_LINKER_FLAGS}")

set(SOURCE_FILES main.cpp)

add_executable(test2016_2 ${SOURCE_FILES})

target_link_libraries(${PROJECT_NAME} ${DOLFIN_LIBRARIES} ${MKL_LIBRARIES})

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.