forked from meshadaptation/pragmatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
142 lines (116 loc) · 5.22 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
PROJECT(PRAgMaTIc)
# The version number.
set (PRAgMaTIc_VERSION_MAJOR 1)
set (PRAgMaTIc_VERSION_MINOR 3)
set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules ${CMAKE_MODULE_PATH})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
enable_language(CXX)
enable_language(C)
set(INSTALL_LIB_DIR "lib" CACHE PATH
"Installation directory for libraries")
set(INSTALL_BIN_DIR "bin" CACHE PATH
"Installation directory for executables")
set(INSTALL_INCLUDE_DIR "include/pragmatic" CACHE PATH
"Installation directory for header files")
include_directories(include)
find_library(LIBRT_LIBRARIES rt)
if (NOT LIBRT_LIBRARIES)
set (LIBRT_LIBRARIES "")
endif()
MESSAGE( STATUS "LIBRT_LIBRARIES: " ${LIBRT_LIBRARIES} )
set (PRAGMATIC_LIBRARIES)
# Use env variable iff it exists and command line arg was not given:
if (NOT (DEFINED ENABLE_VTK) AND (NOT (x$ENV{ENABLE_VTK} STREQUAL x)))
set(ENABLE_VTK $ENV{ENABLE_VTK})
else()
option(ENABLE_VTK "Enable VTK input/output." ON)
endif()
if (ENABLE_VTK)
FIND_PACKAGE(VTK NO_MODULE)
if(VTK_FOUND)
message(STATUS "Found VTK: ${VTK_DIR} (found version \"${VTK_VERSION}\")")
add_definitions(-DHAVE_VTK)
include(${VTK_USE_FILE})
set (PRAGMATIC_LIBRARIES ${VTK_LIBRARIES} ${PRAGMATIC_LIBRARIES})
endif()
endif()
if (NOT ENABLE_VTK OR NOT VTK_FOUND)
message(STATUS "Configured without VTK support.")
endif()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-literal-suffix -Wno-deprecated -Wno-inconsistent-missing-override")
FIND_PACKAGE(MPI REQUIRED)
include_directories(${MPI_CXX_INCLUDE_PATH} ${MPI_C_INCLUDE_PATH})
set (CMAKE_CXX_FLAGS "${MPI_CXX_COMPILE_FLAGS} ${CMAKE_CXX_FLAGS}")
set (CMAKE_C_FLAGS "${MPI_C_COMPILE_FLAGS} ${CMAKE_C_FLAGS}")
set (CMAKE_LINK_FLAGS "${MPI_C_LINK_FLAGS} ${CMAKE_LINK_FLAGS}")
set (PRAGMATIC_LIBRARIES ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES} ${PRAGMATIC_LIBRARIES})
FIND_PACKAGE(Metis REQUIRED)
add_definitions(-DHAVE_METIS)
include_directories(${METIS_INCLUDE_DIR})
set (PRAGMATIC_LIBRARIES ${METIS_LIBRARIES} ${PRAGMATIC_LIBRARIES})
find_package(PythonInterp 2.7)
if(PYTHONINTERP_FOUND)
set(ADAPTIVITY_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/python/adaptivity.py.in")
set(ADAPTIVITY_PY "${CMAKE_CURRENT_SOURCE_DIR}/python/adaptivity.py")
# Generate adaptivity.py
configure_file(${ADAPTIVITY_PY_IN} ${ADAPTIVITY_PY})
endif()
find_package(Eigen REQUIRED)
include_directories(${EIGEN_INCLUDE_DIR})
# Use Eigen in release mode. TODO add flag for vectorization support
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_NO_DEBUG")
# Use env variable iff it exists and command line arg was not given:
if (NOT (DEFINED ENABLE_LIBMESHB) AND (NOT (x$ENV{ENABLE_LIBMESHB} STREQUAL x)))
set(ENABLE_LIBMESHB $ENV{ENABLE_LIBMESHB})
else()
option(ENABLE_LIBMESHB "Enable libMeshb support." ON)
endif()
if (ENABLE_LIBMESHB)
FIND_PACKAGE(LibMeshb)
if(LIBMESHB_FOUND)
add_definitions(-DHAVE_LIBMESHB)
include_directories(${LIBMESHB_INCLUDE_DIR})
set (PRAGMATIC_LIBRARIES ${LIBMESHB_LIBRARIES} ${PRAGMATIC_LIBRARIES})
# set (CMAKE_EXE_LINKER_FLAGS ${LIBRT_LIBRARIES})
# set (CMAKE_SHARED_LINKER_FLAGS ${LIBRT_LIBRARIES})
endif()
endif()
if (NOT ENABLE_LIBMESHB OR NOT LIBMESHB_FOUND)
message(STATUS "Configured without libMeshb support.")
endif()
# Make sure libpragmatic.dylib works properly from the prefix location
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
# ADD_EXECUTABLE( ${PROJECT_NAME} main.cpp )
# TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${PRAgMaTIc_LIBS} )
# ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD COMMAND cp ${PROJECT_NAME} ${PROJECT_NAME}.o )
file(GLOB C_SOURCES src/*.c)
file(GLOB CXX_SOURCES src/*.cpp)
# target_link_library
add_library(pragmatic SHARED ${C_SOURCES} ${CXX_SOURCES})
target_link_libraries(pragmatic ${PRAGMATIC_LIBRARIES})
set (PRAGMATIC_LIBRARIES pragmatic ${PRAGMATIC_LIBRARIES})
add_subdirectory(tests EXCLUDE_FROM_ALL)
install(DIRECTORY include/ DESTINATION include/pragmatic FILES_MATCHING PATTERN *.h)
install(TARGETS pragmatic DESTINATION "${INSTALL_LIB_DIR}")
ADD_EXECUTABLE(coarsen_mesh_3d ./tools/coarsen_mesh_3d.cpp ./src/generate_Steiner_ellipse_3d.cpp ./src/mpi_tools.cpp ./src/ticker.cpp)
TARGET_LINK_LIBRARIES(coarsen_mesh_3d ${PRAGMATIC_LIBRARIES} ${LIBRT_LIBRARIES})
ADD_EXECUTABLE(jpeg2mesh ./tools/jpeg2mesh ./src/mpi_tools.cpp ./src/ticker.cpp)
TARGET_LINK_LIBRARIES(jpeg2mesh ${PRAGMATIC_LIBRARIES} ${LIBRT_LIBRARIES})
ADD_EXECUTABLE(mesh2vtu ./tools/mesh2vtu)
TARGET_LINK_LIBRARIES(mesh2vtu ${PRAGMATIC_LIBRARIES} ${LIBRT_LIBRARIES})
ADD_EXECUTABLE(vtu2mesh ./tools/vtu2mesh)
TARGET_LINK_LIBRARIES(vtu2mesh ${PRAGMATIC_LIBRARIES} ${LIBRT_LIBRARIES})