/
CMakeLists.txt
74 lines (58 loc) · 3.88 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
cmake_minimum_required (VERSION 2.6.3)
project (Dohp)
list (APPEND CMAKE_MODULE_PATH "${Dohp_SOURCE_DIR}/CMake")
# Normally PETSc is built with MPI, if not, use CC=mpicc, etc
find_package (PETSc REQUIRED)
find_package (ITAPS COMPONENTS MESH GEOM REL)
#find_package (Doxygen)
option (dUSE_DEBUG "Compile Dohp with extra debugging" ON)
option (Dohp_BUILD_TESTS "Build tests" ON)
option (Dohp_BUILD_TOOLS "Build tools" ON)
option (Dohp_BUILD_SANDBOX "Build programs in sandbox" OFF)
option (PEDANTIC_WARNINGS "Compile with pedantic warnings" ON)
option (BUILD_SHARED_LIBS "Build shared Dohp libraries" ON)
add_definitions (-std=c99)
if (Dohp_BUILD_TESTS)
enable_testing ()
set (Dohp_DATA_DIR "${Dohp_SOURCE_DIR}/data")
endif (Dohp_BUILD_TESTS)
if (PEDANTIC_WARNINGS)
set (DEFAULT_PEDANTIC_FLAGS "-pedantic -Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wmissing-format-attribute -Wmissing-noreturn -Wpacked -Wdisabled-optimization -Wmultichar -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wendif-labels -Wdeclaration-after-statement -Wold-style-definition -Winvalid-pch -Wmissing-field-initializers -Wvariadic-macros -Wunsafe-loop-optimizations -Wvolatile-register-var -Wstrict-aliasing -funit-at-a-time -Wno-sign-conversion")
#set (DEFAULT_PEDANTIC_FLAGS "-Wunreachable-code -Wfloat-equal -Wc++-compat")
#set (DEFAULT_PEDANTIC_FLAGS "-pedantic -Wall -Wextra -Winline -Wshadow -Wconversion -Wlogical-op -Wmissing-prototypes -Wvla")
#set (DEFAULT_PEDANTIC_FLAGS "${DEFAULT_PEDANTIC_FLAGS} -Wno-sign-conversion -Wwrite-strings -Wstrict-aliasing -Wcast-align -fstrict-aliasing")
#set (DEFAULT_PEDANTIC_FLAGS "${DEFAULT_PEDANTIC_FLAGS} -Wdisabled-optimization -funit-at-a-time")
#set (DEFAULT_PEDANTIC_FLAGS "${DEFAULT_PEDANTIC_FLAGS} -Wpadded")
set (PEDANTIC_FLAGS ${DEFAULT_PEDANTIC_FLAGS} CACHE STRING "Compiler flags to enable pedantic warnings")
add_definitions (${PEDANTIC_FLAGS})
endif (PEDANTIC_WARNINGS)
configure_file (${Dohp_SOURCE_DIR}/dohpconfig.h.in
${Dohp_BINARY_DIR}/include/dohpconfig.h @ONLY)
add_custom_target (etags
etags `find include src sandbox -name *.[ch]`
WORKING_DIRECTORY ${Dohp_SOURCE_DIR})
# Essential: include our directories first otherwise we can get internal headers from some installed path
include_directories ("${Dohp_SOURCE_DIR}/include" "${Dohp_BINARY_DIR}/include" ${PETSC_INCLUDES} ${ITAPS_INCLUDES})
add_definitions (${PETSC_DEFINITIONS})
set (Dohp_DEPENDENT_LIBRARIES "${ITAPS_REL_LIBRARIES}" "${ITAPS_MESH_LIBRARIES}" "${ITAPS_GEOM_LIBRARIES}" "${PETSC_LIBRARIES}")
set (Dohp_LIBRARIES dohp ${Dohp_DEPENDENT_LIBRARIES})
set (ARCHIVE_OUTPUT_DIRECTORY ${Dohp_BINARY_DIR}/lib CACHE PATH "Output directory for Dohp archives")
set (LIBRARY_OUTPUT_DIRECTORY ${Dohp_BINARY_DIR}/lib CACHE PATH "Output directory for Dohp libraries")
set (RUNTIME_OUTPUT_DIRECTORY ${Dohp_BINARY_DIR}/bin CACHE PATH "Output directory for Dohp executables")
mark_as_advanced (ARCHIVE_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY)
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Convenience for testing
macro (dohp_link_executable name source)
add_executable (${name} ${source})
target_link_libraries (${name} dohp)
endmacro ()
macro (dohp_add_test name np)
add_test ("${name}" "${Dohp_TestWithReference}" "${PETSC_MPIEXEC}" "${np}" "${CMAKE_CURRENT_SOURCE_DIR}/refout/${name}.refout" ${ARGN})
endmacro()
set (Dohp_TestWithReference "${Dohp_SOURCE_DIR}/TestWithReference.sh")
add_subdirectory (include)
add_subdirectory (src)
if (Dohp_BUILD_SANDBOX)
add_subdirectory (${Dohp_SOURCE_DIR}/sandbox)
endif (Dohp_BUILD_SANDBOX)