diff options
author | Andres Mejia <amejia004@gmail.com> | 2013-01-31 19:20:34 -0500 |
---|---|---|
committer | Andres Mejia <amejia004@gmail.com> | 2013-01-31 19:20:34 -0500 |
commit | 146a5067ca976b208b4aab06127efdf4ba9096f9 (patch) | |
tree | c129f6b5e99e8fa72bb776ffa719d62605be5c2c | |
parent | b708276ac543fb1c3d48fbd57f5592334a0dea28 (diff) | |
download | libarchive-146a5067ca976b208b4aab06127efdf4ba9096f9.tar.gz |
Add CMake option to explicitly enable/disable /SAFESEH linker flag for Visual Studio builds.
Visual Studio 12 enables this option by default. Enabling /SAFESEH will produce build failures when
attempting to link other libraries which were not built with /SAFESEH. This would typically be
the case for libraries built using the mingw toolchain, where the option to use structured exception
handling is not yet available.
The option is used as follows.
Setting to "YES" sets "/SAFESEH" linker flag
Setting to "NO" sets "/SAFESEH:NO" linker flag
Setting to any other value such as "AUTO" won't do anything (set the default linker flag from Visual Studio)
-rw-r--r-- | CMakeLists.txt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a77ff51..8ad6504e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,6 +152,7 @@ OPTION(ENABLE_ACL "Enable ACL support" ON) OPTION(ENABLE_ICONV "Enable iconv support" ON) OPTION(ENABLE_PCREPOSIX "Enable POSIX regular expression support using PCRE" OFF) OPTION(ENABLE_TEST "Enable unit and regression tests" ON) +SET(ENABLE_SAFESEH "AUTO" CACHE STRING "Enable use of /SAFESEH linker flag (MSVC only)") IF(ENABLE_TEST) ENABLE_TESTING() @@ -166,6 +167,18 @@ IF(WIN32) SET(_WIN32_WINNT ${WINVER}) ENDIF(WIN32) +IF(MSVC) + IF(ENABLE_SAFESEH STREQUAL "YES") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH") + SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH") + ELSEIF(ENABLE_SAFESEH STREQUAL "NO") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") + SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO") + ENDIF(ENABLE_SAFESEH STREQUAL "YES") +ENDIF(MSVC) + IF("${CMAKE_C_PLATFORM_ID}" MATCHES "^(HP-UX)$") ADD_DEFINITIONS(-D_XOPEN_SOURCE=500) # Ask wchar.h for mbstate_t ENDIF() |