-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
128 lines (100 loc) · 3.92 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
cmake_minimum_required(VERSION 2.8)
# --- project ---
#set(CMAKE_CXX_COMPILER mpicxx)
project(fem)
set(MY_CXX_FLAGS "-std=c++0x -Wall")
# ---------------
# --- choosing build type ---
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build: Debug | Release" FORCE)
endif(NOT CMAKE_BUILD_TYPE)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(DEBUG ON CACHE BOOL "This option is for internal usage - not the compiler debug options" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MY_CXX_FLAGS}")
message("build type: Debug")
message("compiler flags: ${CMAKE_CXX_FLAGS_DEBUG}")
elseif(CMAKE_BUILD_TYPE MATCHES Release)
set(DEBUG OFF CACHE BOOL "This option is for internal usage - not the compiler debug options" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MY_CXX_FLAGS}")
message("build type: Release")
message("compiler flags: ${CMAKE_CXX_FLAGS_RELEASE}")
else(CMAKE_BUILD_TYPE MATCHES Debug)
message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}")
endif(CMAKE_BUILD_TYPE MATCHES Debug)
# ---------------------------
# --- define and connect some important directories ---
set(INSTALL_DIR $ENV{HOME}/install)
set(INCLUDE_DIR ${INSTALL_DIR}/include)
set(LIB_DIR ${INSTALL_DIR}/lib)
include_directories(${INCLUDE_DIR})
link_directories(${LIB_DIR})
# -----------------------------------------------------
# --- boost ---
#find_library(BOOST_PO_LIB libboost_program_options.so ${LIB_DIR})
#if(NOT BOOST_PO_LIB)
# message(FATAL_ERROR "boost program_options library wasn't found!")
#endif(NOT BOOST_PO_LIB)
#find_library(BOOST_TIMER_LIB libboost_timer.so ${LIB_DIR})
#if(NOT BOOST_TIMER_LIB)
# message(FATAL_ERROR "boost timer library wasn't found!")
#endif(NOT BOOST_TIMER_LIB)
set(Boost_INCLUDE_DIR ${INCLUDE_DIR})
set(Boost_LIBRARY_DIR ${LIB_DIR})
find_package(Boost 1.55 COMPONENTS program_options timer system filesystem REQUIRED)
# -------------
# --- google test ---
#find_library(GTEST_LIB gtest ${LIB_DIR})
#if(NOT GTEST_LIB)
# message(FATAL_ERROR "GTest library was not found!")
#endif(NOT GTEST_LIB)
# -------------------
# --- petsc ---
find_library(PETSC_LIB petsc ${LIB_DIR})
if(NOT PETSC_LIB)
message(FATAL_ERROR "PETSc library was not found!")
endif(NOT PETSC_LIB)
# -------------
# --- mpi ---
#set(MPI_LIB libmpi.so ${LIB_DIR})
#if(NOT MPI_LIB)
# message(FATAL_ERROR "mpi library was not found!")
#endif(NOT MPI_LIB)
# -----------
# --- 64-bitness ---
set(HAVE_64BIT_SIZE_T OFF CACHE INTERNAL "")
include(CheckTypeSize)
check_type_size("void*" SIZEOF_VOID_P)
if(SIZEOF_VOID_P EQUAL 8)
set(HAVE_64BIT_SIZE_T ON CACHE INTERNAL "" FORCE)
endif(SIZEOF_VOID_P EQUAL 8)
# ------------------
# --- config file ---
configure_file(
"${PROJECT_SOURCE_DIR}/config.h.in"
"${PROJECT_SOURCE_DIR}/headers/config.h")
# -------------------
# --- headers and sources ---
aux_source_directory(${PROJECT_SOURCE_DIR}/sources SRC_LIST) # all .cpp files
include_directories(${PROJECT_SOURCE_DIR}/headers)
FILE(GLOB HDR_LIST "${PROJECT_SOURCE_DIR}/headers/*.h") # all .h files
# ---------------------------
# --- some options and dependencies ---
if(CMAKE_BUILD_TYPE MATCHES Debug)
message("build type " ${CMAKE_BUILD_TYPE})
#message("gtest lib " ${GTEST_LIB})
message("boost libs " ${Boost_LIBRARIES})
message("petsc lib " ${PETSC_LIB})
#message("mpi lib " ${MPI_LIB})
message("SRC_LIST " ${SRC_LIST})
message("HDR_LIST " ${HDR_LIST})
endif(CMAKE_BUILD_TYPE MATCHES Debug)
# -------------------------------------
#if(CMAKE_BUILD_TYPE MATCHES Debug)
# set(LIB_NAME "femd")
#else(CMAKE_BUILD_TYPE MATCHES Debug)
# set(LIB_NAME "fem")
#endif(CMAKE_BUILD_TYPE MATCHES Debug)
add_library(${PROJECT_NAME} ${SRC_LIST} ${HDR_LIST})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} ${PETSC_LIB}) # ${GTEST_LIB} ${PETSC_LIB} ${MPI_LIB})
install(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_DIR})
install(FILES ${HDR_LIST} DESTINATION ${INCLUDE_DIR}/fem)