diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 11 |
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 |