Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for position independent code in CMake #930

Merged
merged 1 commit into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CMAKE_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down