-
Notifications
You must be signed in to change notification settings - Fork 32
/
CMakeLists.txt
78 lines (66 loc) · 2.3 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
PROJECT(DGalerkin)
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
# put all generated files in a single folder (required in windows for exe linked to dlls)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "")
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "")
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
# build type is "" by default in Linux
IF(NOT CMAKE_BUILD_TYPE)
SET( CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
ENDIF()
# enable C++11
SET(CMAKE_CXX_STANDARD 11) # newer way to set C++11 (requires cmake>3.1)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
# compiler options
IF(UNIX AND CMAKE_CXX_COMPILER_ID STREQUAL GNU)
ADD_DEFINITIONS(-D_GLIBCXX_USE_CXX11_ABI=0)
ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS)
ADD_DEFINITIONS(-D_USE_MATH_DEFINES)
ENDIF()
# find gmsh-sdk
# gmsh.h
FIND_PATH(GMSH_INCLUDE_DIRS NAMES "gmsh.h")
MESSAGE(STATUS "GMSH_INCLUDE_DIRS=" ${GMSH_INCLUDE_DIRS})
if(NOT GMSH_INCLUDE_DIRS)
MESSAGE(FATAL_ERROR "gmsh.h not found!")
ENDIF()
INCLUDE_DIRECTORIES(${GMSH_INCLUDE_DIRS})
# libgmsh.so
FIND_LIBRARY(GMSH_LIBRARIES gmsh)
MESSAGE(STATUS "GMSH_LIBRARIES=" ${GMSH_LIBRARIES})
IF(NOT GMSH_LIBRARIES)
message(FATAL_ERROR "gmsh library not found!")
ENDIF()
# gmsh.exe
FIND_PROGRAM(GMSH_EXECUTABLE gmsh)
MESSAGE(STATUS "GMSH_EXECUTABLE=" ${GMSH_EXECUTABLE})
IF(NOT GMSH_EXECUTABLE)
message(FATAL_ERROR "gmsh executable not found!")
ENDIF()
# Lapack
FIND_PACKAGE(BLAS)
FIND_PACKAGE(LAPACK)
MESSAGE(STATUS "LAPACK=" ${LAPACK_LIBRARIES})
if(LAPACK_FOUND AND BLAS_FOUND)
set(LAPACKBLAS_LIBRARIES ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
endif()
# Eigen
FIND_PATH(EIGEN_INCLUDE_DIRS NAMES "Eigen/Eigen")
MESSAGE(STATUS "EIGEN_INCLUDE_DIRS=" ${EIGEN_INCLUDE_DIRS})
if(NOT EIGEN_INCLUDE_DIRS)
MESSAGE(FATAL_ERROR "Eigen not found!")
ENDIF()
INCLUDE_DIRECTORIES(${EIGEN_INCLUDE_DIRS})
# OpenMP
FIND_PACKAGE( OpenMP REQUIRED)
if(OPENMP_FOUND)
message("OpenMP found")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
# Libraries
INCLUDE_DIRECTORIES(include)
# Sources
ADD_SUBDIRECTORY(src)