aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2019-09-23 12:51:19 +0300
committerWohlstand <admin@wohlnet.ru>2019-09-23 12:55:41 +0300
commit22248f90dd83413e91c8d4b66e652ef1a7954b60 (patch)
tree458b7d861c5a0845388717e1f1a10f4295b7a22f /CMakeLists.txt
parent8749ddc3da9574c2406a7dfd2fd6a4639148beef (diff)
downloadlibADLMIDI-22248f90dd83413e91c8d4b66e652ef1a7954b60.tar.gz
libADLMIDI-22248f90dd83413e91c8d4b66e652ef1a7954b60.tar.bz2
libADLMIDI-22248f90dd83413e91c8d4b66e652ef1a7954b60.zip
Don't call "-no-pie" when it's unavailable
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2da1a4b..7b31f09 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 3.2)
project (libADLMIDI VERSION 1.4.1 LANGUAGES C CXX)
include(GNUInstallDirs)
+include(CheckCXXCompilerFlag)
# Prefer C90 standard
set(CMAKE_C_STANDARD 90)
@@ -68,6 +69,16 @@ if(OPENBSD_LOCALBASE)
include_directories(${OPENBSD_LOCALBASE}/include)
endif()
+if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+ check_cxx_compiler_flag("-no-pie" HAS_NO_PIE)
+endif()
+
+function(set_nopie _target)
+ if(HAS_NO_PIE AND CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+ set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS " -no-pie")
+ endif()
+endfunction()
+
function(set_legacy_standard destTarget)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Turn on warnings and legacy C/C++ standards to support more compilers