From 5906a1807f06075d8d6419cdeaf8e3b7d2805dc2 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Fri, 4 Mar 2022 13:47:48 -0500 Subject: [PATCH] Add option for position independent code --- CMAKE_INSTRUCTIONS.md | 7 ++++--- CMakeLists.txt | 12 +++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMAKE_INSTRUCTIONS.md b/CMAKE_INSTRUCTIONS.md index aab471b5d..ff845be9d 100644 --- a/CMAKE_INSTRUCTIONS.md +++ b/CMAKE_INSTRUCTIONS.md @@ -43,9 +43,10 @@ By default, FMS is built without `OpenMP` and in `single precision (r4)` The following build options are available: ``` --DOPENMP "Build FMS with OpenMP support" DEFAULT: OFF --D32BIT "Build 32-bit (r4) FMS library" DEFAULT: ON --D64BIT "Build 64-bit (r8) FMS library" DEFAULT: OFF +-DOPENMP "Build FMS with OpenMP support" DEFAULT: OFF +-D32BIT "Build 32-bit (r4) FMS library" DEFAULT: ON +-D64BIT "Build 64-bit (r8) FMS library" DEFAULT: OFF +-DFPIC "Build with position independent code" DEFAULT: OFF -DINTERNAL_FILE_NML "Enable compiler definition -DINTERNAL_FILE_NML" DEFAULT: ON -DENABLE_QUAD_PRECISION "Enable compiler definition -DENABLE_QUAD_PRECISION" DEFAULT: ON diff --git a/CMakeLists.txt b/CMakeLists.txt index 524307c7d..b1d38ada3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,9 +52,10 @@ endif() list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # Build options -option(OPENMP "Build FMS with OpenMP support" OFF) -option(32BIT "Build 32-bit (r4) FMS library" ON) -option(64BIT "Build 64-bit (r8) FMS library" OFF) +option(OPENMP "Build FMS with OpenMP support" OFF) +option(32BIT "Build 32-bit (r4) FMS library" ON) +option(64BIT "Build 64-bit (r8) FMS library" OFF) +option(FPIC "Build with position independent code" OFF) # Options for compiler definitions option(INTERNAL_FILE_NML "Enable compiler definition -DINTERNAL_FILE_NML" ON) @@ -89,6 +90,11 @@ if (WITH_YAML) include_directories(${LIBYAML_INCLUDE_DIR}) endif () +# Enables position independent code (i.e., -fPIC) +if (FPIC) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endif () + # Collect FMS Fortran source files list(APPEND fms_fortran_src_files affinity/fms_affinity.F90