forked from IHPCSS/software-engineering
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
75 lines (60 loc) · 2.35 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
#
# Example CMake file for the IHPCSS Software Engineering
# project, based on John Urbanic's laplace
# solver ported to use a C++ compiler.
#
# Make sure we don't have a pre-historic CMake version
cmake_minimum_required(VERSION 3.0)
# Enable policy 0048 to allow setting version with the project command
set(CMP0048 NEW)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
project(Software-engineering VERSION 0.2)
set(PROJECT_VERSION_STRING "${PROJECT_VERSION}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose type of build, options are: Debug, MinSizeRel, Release, RelWithDebInfo" FORCE)
option(BUILD_TESTS "Enable unit test building" ON)
option(MPI "Enable MPI compiler support" OFF)
option(OPENMP "Enable OpenMP compiler support" OFF)
option(OPENACC "Enable OpenACC compiler support" OFF)
# Use GNUInstallDirs to set paths on multiarch systems.
include(GNUInstallDirs)
# Add the MPI/OpenMP/OpenACC compiler flags before other tests,
# since this might change the behavior on some platforms
if(MPI)
find_package(MPI)
if(MPI_CXX_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_CXX_COMPILE_FLAGS}")
include_directories(${MPI_CXX_INCLUDE_PATH})
set(CMAKE_EXE_LINKER_FLAGS ${MPI_CXX_LINK_FLAGS})
set(CMAKE_SHARED_LINKER_FLAGS ${MPI_CXX_LINK_FLAGS})
list(APPEND EXTRA_LIBRARIES ${MPI_CXX_LIBRARIES})
set(HAVE_MPI TRUE)
else()
message(ERROR "MPI support requested, but no compiler support found.")
endif()
endif()
if(OPENMP)
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(HAVE_OPENMP TRUE)
else()
message(ERROR "OpenMP support requested, but no compiler support found.")
endif()
endif()
if(OPENACC)
find_package(OpenACC)
if(OPENACC_CXX_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenACC_CXX_FLAGS}")
set(HAVE_OPENACC TRUE)
set(OPENACC_VERSION OpenACC_CXX_VERSION)
else()
message(ERROR "OpenACC support requested, but no compiler support found.")
endif()
endif()
# Test and add some extra compiler flags
include(CompilerFlags)
add_subdirectory(src)
add_subdirectory(docs)