Skip to content

Commit 5bad748

Browse files
authored
Merge pull request #61 from prj-/jolivet/fix-position-independent
Set CMAKE_POSITION_INDEPENDENT_CODE if need be
2 parents 669d5f6 + 877f024 commit 5bad748

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

BLACS/INSTALL/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ cmake_minimum_required(VERSION 2.8)
22
project(INSTALL C Fortran)
33

44
add_executable(xintface Fintface.f Cintface.c)
5+
set_property(TARGET xintface PROPERTY POSITION_INDEPENDENT_CODE TRUE)

CMakeLists.txt

+15-5
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SCALAPACK_BINARY_DIR}/TESTING)
101101
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SCALAPACK_BINARY_DIR}/lib)
102102
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SCALAPACK_BINARY_DIR}/lib)
103103

104+
# --------------------------------------------------
105+
# By default static library
106+
function (invertBoolean varName varValue)
107+
if (${varValue})
108+
set(${varName} false PARENT_SCOPE)
109+
else ()
110+
set(${varName} true PARENT_SCOPE)
111+
endif ()
112+
endfunction ()
113+
option(BUILD_SHARED_LIBS "Build shared libraries" OFF )
114+
invertBoolean("BUILD_STATIC_LIBS" ${BUILD_SHARED_LIBS})
115+
if ((${BUILD_SHARED_LIBS} EQUAL ON) AND NOT CMAKE_POSITION_INDEPENDENT_CODE)
116+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
117+
endif ()
118+
104119
# --------------------------------------------------
105120
# Check for any necessary platform specific compiler flags
106121
include( CheckBLACSCompilerFlags )
@@ -176,11 +191,6 @@ message(STATUS "LAPACK library: ${LAPACK_LIBRARIES}")
176191

177192
MESSAGE(STATUS "=========")
178193

179-
# --------------------------------------------------
180-
# By default static library
181-
OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF )
182-
OPTION(BUILD_STATIC_LIBS "Build static libraries" ON )
183-
184194
# --------------------------------------------------
185195
# Subdirectories that need to be processed
186196

0 commit comments

Comments
 (0)