mirror of
https://github.com/CPunch/Laika.git
synced 2024-11-23 05:10:09 +00:00
Removed unused cmake-modules
This commit is contained in:
parent
8092a636ca
commit
ff8b059eff
@ -9,9 +9,6 @@ execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_VERSION O
|
||||
# Set the project as the default startup project for VS
|
||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT LaikaLib)
|
||||
|
||||
# include our cmake modules
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules" ${CMAKE_MODULE_PATH})
|
||||
|
||||
# Output binaries to the bin folder in the source directory
|
||||
if(WIN32)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/winbin)
|
||||
@ -37,10 +34,7 @@ if(RAWCMAKEBUILDTYPE STREQUAL "debug")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
|
||||
else()
|
||||
message(STATUS "Adding sanitizer...")
|
||||
#set(SANITIZE_ADDRESS TRUE)
|
||||
#add_sanitizers(LaikaLib LaikaBot LaikaCNC)
|
||||
|
||||
# bug in FindSanitizer.cmake ??? idfk, i'll investigate l8tr
|
||||
|
||||
add_compile_options(-fsanitize=address)
|
||||
add_link_options(-fsanitize=address)
|
||||
endif ()
|
||||
|
@ -1,60 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
option(SANITIZE_ADDRESS "Enable AddressSanitizer for sanitized targets." Off)
|
||||
|
||||
set(FLAG_CANDIDATES
|
||||
# Clang 3.2+ use this version. The no-omit-frame-pointer option is optional.
|
||||
"-g -fsanitize=address -fno-omit-frame-pointer"
|
||||
"-g -fsanitize=address"
|
||||
|
||||
# Older deprecated flag for ASan
|
||||
"-g -faddress-sanitizer"
|
||||
)
|
||||
|
||||
|
||||
if (SANITIZE_ADDRESS AND (SANITIZE_THREAD OR SANITIZE_MEMORY))
|
||||
message(FATAL_ERROR "AddressSanitizer is not compatible with "
|
||||
"ThreadSanitizer or MemorySanitizer.")
|
||||
endif ()
|
||||
|
||||
|
||||
include(sanitize-helpers)
|
||||
|
||||
if (SANITIZE_ADDRESS)
|
||||
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "AddressSanitizer"
|
||||
"ASan")
|
||||
|
||||
find_program(ASan_WRAPPER "asan-wrapper" PATHS ${CMAKE_MODULE_PATH})
|
||||
mark_as_advanced(ASan_WRAPPER)
|
||||
endif ()
|
||||
|
||||
function (add_sanitize_address TARGET)
|
||||
if (NOT SANITIZE_ADDRESS)
|
||||
return()
|
||||
endif ()
|
||||
|
||||
message(STATUS "Adding ASAN for " ${TARGET} "")
|
||||
sanitizer_add_flags(${TARGET} "AddressSanitizer" "ASan")
|
||||
endfunction ()
|
@ -1,57 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
option(SANITIZE_MEMORY "Enable MemorySanitizer for sanitized targets." Off)
|
||||
|
||||
set(FLAG_CANDIDATES
|
||||
"-g -fsanitize=memory"
|
||||
)
|
||||
|
||||
|
||||
include(sanitize-helpers)
|
||||
|
||||
if (SANITIZE_MEMORY)
|
||||
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
message(WARNING "MemorySanitizer disabled for target ${TARGET} because "
|
||||
"MemorySanitizer is supported for Linux systems only.")
|
||||
set(SANITIZE_MEMORY Off CACHE BOOL
|
||||
"Enable MemorySanitizer for sanitized targets." FORCE)
|
||||
elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
message(WARNING "MemorySanitizer disabled for target ${TARGET} because "
|
||||
"MemorySanitizer is supported for 64bit systems only.")
|
||||
set(SANITIZE_MEMORY Off CACHE BOOL
|
||||
"Enable MemorySanitizer for sanitized targets." FORCE)
|
||||
else ()
|
||||
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "MemorySanitizer"
|
||||
"MSan")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
function (add_sanitize_memory TARGET)
|
||||
if (NOT SANITIZE_MEMORY)
|
||||
return()
|
||||
endif ()
|
||||
|
||||
sanitizer_add_flags(${TARGET} "MemorySanitizer" "MSan")
|
||||
endfunction ()
|
@ -1,94 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# If any of the used compiler is a GNU compiler, add a second option to static
|
||||
# link against the sanitizers.
|
||||
option(SANITIZE_LINK_STATIC "Try to link static against sanitizers." Off)
|
||||
|
||||
|
||||
|
||||
|
||||
set(FIND_QUIETLY_FLAG "")
|
||||
if (DEFINED Sanitizers_FIND_QUIETLY)
|
||||
set(FIND_QUIETLY_FLAG "QUIET")
|
||||
endif ()
|
||||
|
||||
find_package(ASan ${FIND_QUIETLY_FLAG})
|
||||
find_package(TSan ${FIND_QUIETLY_FLAG})
|
||||
find_package(MSan ${FIND_QUIETLY_FLAG})
|
||||
find_package(UBSan ${FIND_QUIETLY_FLAG})
|
||||
|
||||
|
||||
|
||||
|
||||
function(sanitizer_add_blacklist_file FILE)
|
||||
if(NOT IS_ABSOLUTE ${FILE})
|
||||
set(FILE "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}")
|
||||
endif()
|
||||
get_filename_component(FILE "${FILE}" REALPATH)
|
||||
|
||||
sanitizer_check_compiler_flags("-fsanitize-blacklist=${FILE}"
|
||||
"SanitizerBlacklist" "SanBlist")
|
||||
endfunction()
|
||||
|
||||
function(add_sanitizers ...)
|
||||
# If no sanitizer is enabled, return immediately.
|
||||
if (NOT (SANITIZE_ADDRESS OR SANITIZE_MEMORY OR SANITIZE_THREAD OR
|
||||
SANITIZE_UNDEFINED))
|
||||
return()
|
||||
endif ()
|
||||
|
||||
foreach (TARGET ${ARGV})
|
||||
# Check if this target will be compiled by exactly one compiler. Other-
|
||||
# wise sanitizers can't be used and a warning should be printed once.
|
||||
get_target_property(TARGET_TYPE ${TARGET} TYPE)
|
||||
if (TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
|
||||
message(WARNING "Can't use any sanitizers for target ${TARGET}, "
|
||||
"because it is an interface library and cannot be "
|
||||
"compiled directly.")
|
||||
return()
|
||||
endif ()
|
||||
sanitizer_target_compilers(${TARGET} TARGET_COMPILER)
|
||||
list(LENGTH TARGET_COMPILER NUM_COMPILERS)
|
||||
if (NUM_COMPILERS GREATER 1)
|
||||
message(WARNING "Can't use any sanitizers for target ${TARGET}, "
|
||||
"because it will be compiled by incompatible compilers. "
|
||||
"Target will be compiled without sanitizers.")
|
||||
return()
|
||||
|
||||
# If the target is compiled by no or no known compiler, give a warning.
|
||||
elseif (NUM_COMPILERS EQUAL 0)
|
||||
message(WARNING "Sanitizers for target ${TARGET} may not be"
|
||||
" usable, because it uses no or an unknown compiler. "
|
||||
"This is a false warning for targets using only "
|
||||
"object lib(s) as input.")
|
||||
endif ()
|
||||
|
||||
# Add sanitizers for target.
|
||||
add_sanitize_address(${TARGET})
|
||||
add_sanitize_thread(${TARGET})
|
||||
add_sanitize_memory(${TARGET})
|
||||
add_sanitize_undefined(${TARGET})
|
||||
endforeach ()
|
||||
endfunction(add_sanitizers)
|
@ -1,297 +0,0 @@
|
||||
# Written in 2016 by Henrik Steffen Gaßmann <henrik@gassmann.onl>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all
|
||||
# copyright and related and neighboring rights to this software to the
|
||||
# public domain worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication
|
||||
# along with this software. If not, see
|
||||
#
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
#
|
||||
########################################################################
|
||||
# Tries to find the local libsodium installation.
|
||||
#
|
||||
# On Windows the sodium_DIR environment variable is used as a default
|
||||
# hint which can be overridden by setting the corresponding cmake variable.
|
||||
#
|
||||
# Once done the following variables will be defined:
|
||||
#
|
||||
# sodium_FOUND
|
||||
# sodium_INCLUDE_DIR
|
||||
# sodium_LIBRARY_DEBUG
|
||||
# sodium_LIBRARY_RELEASE
|
||||
#
|
||||
#
|
||||
# Furthermore an imported "sodium" target is created.
|
||||
#
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
|
||||
OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set(_GCC_COMPATIBLE 1)
|
||||
endif()
|
||||
|
||||
# static library option
|
||||
if (NOT DEFINED sodium_USE_STATIC_LIBS)
|
||||
option(sodium_USE_STATIC_LIBS "enable to statically link against sodium" OFF)
|
||||
endif()
|
||||
if(NOT (sodium_USE_STATIC_LIBS EQUAL sodium_USE_STATIC_LIBS_LAST))
|
||||
unset(sodium_LIBRARY CACHE)
|
||||
unset(sodium_LIBRARY_DEBUG CACHE)
|
||||
unset(sodium_LIBRARY_RELEASE CACHE)
|
||||
unset(sodium_DLL_DEBUG CACHE)
|
||||
unset(sodium_DLL_RELEASE CACHE)
|
||||
set(sodium_USE_STATIC_LIBS_LAST ${sodium_USE_STATIC_LIBS} CACHE INTERNAL "internal change tracking variable")
|
||||
endif()
|
||||
|
||||
|
||||
########################################################################
|
||||
# UNIX
|
||||
if (UNIX)
|
||||
# import pkg-config
|
||||
find_package(PkgConfig QUIET)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(sodium_PKG QUIET libsodium)
|
||||
endif()
|
||||
|
||||
if(sodium_USE_STATIC_LIBS)
|
||||
foreach(_libname ${sodium_PKG_STATIC_LIBRARIES})
|
||||
if (NOT _libname MATCHES "^lib.*\\.a$") # ignore strings already ending with .a
|
||||
list(INSERT sodium_PKG_STATIC_LIBRARIES 0 "lib${_libname}.a")
|
||||
endif()
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES sodium_PKG_STATIC_LIBRARIES)
|
||||
|
||||
# if pkgconfig for libsodium doesn't provide
|
||||
# static lib info, then override PKG_STATIC here..
|
||||
if (NOT sodium_PKG_STATIC_FOUND)
|
||||
set(sodium_PKG_STATIC_LIBRARIES libsodium.a)
|
||||
endif()
|
||||
|
||||
set(XPREFIX sodium_PKG_STATIC)
|
||||
else()
|
||||
if (NOT sodium_PKG_FOUND)
|
||||
set(sodium_PKG_LIBRARIES sodium)
|
||||
endif()
|
||||
|
||||
set(XPREFIX sodium_PKG)
|
||||
endif()
|
||||
|
||||
find_path(sodium_INCLUDE_DIR sodium.h
|
||||
HINTS ${${XPREFIX}_INCLUDE_DIRS}
|
||||
)
|
||||
find_library(sodium_LIBRARY_DEBUG NAMES ${${XPREFIX}_LIBRARIES}
|
||||
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
||||
)
|
||||
find_library(sodium_LIBRARY_RELEASE NAMES ${${XPREFIX}_LIBRARIES}
|
||||
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
|
||||
########################################################################
|
||||
# Windows
|
||||
elseif (WIN32)
|
||||
set(sodium_DIR "$ENV{sodium_DIR}" CACHE FILEPATH "sodium install directory")
|
||||
mark_as_advanced(sodium_DIR)
|
||||
|
||||
find_path(sodium_INCLUDE_DIR sodium.h
|
||||
HINTS ${sodium_DIR}
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
# detect target architecture
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" [=[
|
||||
#if defined _M_IX86
|
||||
#error ARCH_VALUE x86_32
|
||||
#elif defined _M_X64
|
||||
#error ARCH_VALUE x86_64
|
||||
#endif
|
||||
#error ARCH_VALUE unknown
|
||||
]=])
|
||||
try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp"
|
||||
OUTPUT_VARIABLE _COMPILATION_LOG
|
||||
)
|
||||
string(REGEX REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*" "\\1" _TARGET_ARCH "${_COMPILATION_LOG}")
|
||||
|
||||
# construct library path
|
||||
if (_TARGET_ARCH STREQUAL "x86_32")
|
||||
string(APPEND _PLATFORM_PATH "Win32")
|
||||
elseif(_TARGET_ARCH STREQUAL "x86_64")
|
||||
string(APPEND _PLATFORM_PATH "x64")
|
||||
else()
|
||||
message(FATAL_ERROR "the ${_TARGET_ARCH} architecture is not supported by Findsodium.cmake.")
|
||||
endif()
|
||||
string(APPEND _PLATFORM_PATH "/$$CONFIG$$")
|
||||
|
||||
if (MSVC_VERSION LESS 1900)
|
||||
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
|
||||
else()
|
||||
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
|
||||
endif()
|
||||
string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")
|
||||
|
||||
if (sodium_USE_STATIC_LIBS)
|
||||
string(APPEND _PLATFORM_PATH "/static")
|
||||
else()
|
||||
string(APPEND _PLATFORM_PATH "/dynamic")
|
||||
endif()
|
||||
|
||||
string(REPLACE "$$CONFIG$$" "Debug" _DEBUG_PATH_SUFFIX "${_PLATFORM_PATH}")
|
||||
string(REPLACE "$$CONFIG$$" "Release" _RELEASE_PATH_SUFFIX "${_PLATFORM_PATH}")
|
||||
|
||||
find_library(sodium_LIBRARY_DEBUG libsodium.lib
|
||||
HINTS ${sodium_DIR}
|
||||
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
|
||||
)
|
||||
find_library(sodium_LIBRARY_RELEASE libsodium.lib
|
||||
HINTS ${sodium_DIR}
|
||||
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
|
||||
)
|
||||
if (NOT sodium_USE_STATIC_LIBS)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
|
||||
find_library(sodium_DLL_DEBUG libsodium
|
||||
HINTS ${sodium_DIR}
|
||||
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
|
||||
)
|
||||
find_library(sodium_DLL_RELEASE libsodium
|
||||
HINTS ${sodium_DIR}
|
||||
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
|
||||
)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK})
|
||||
endif()
|
||||
|
||||
elseif(_GCC_COMPATIBLE)
|
||||
if (sodium_USE_STATIC_LIBS)
|
||||
find_library(sodium_LIBRARY_DEBUG libsodium.a
|
||||
HINTS ${sodium_DIR}
|
||||
PATH_SUFFIXES lib
|
||||
)
|
||||
find_library(sodium_LIBRARY_RELEASE libsodium.a
|
||||
HINTS ${sodium_DIR}
|
||||
PATH_SUFFIXES lib
|
||||
)
|
||||
else()
|
||||
find_library(sodium_LIBRARY_DEBUG libsodium.dll.a
|
||||
HINTS ${sodium_DIR}
|
||||
PATH_SUFFIXES lib
|
||||
)
|
||||
find_library(sodium_LIBRARY_RELEASE libsodium.dll.a
|
||||
HINTS ${sodium_DIR}
|
||||
PATH_SUFFIXES lib
|
||||
)
|
||||
|
||||
file(GLOB _DLL
|
||||
LIST_DIRECTORIES false
|
||||
RELATIVE "${sodium_DIR}/bin"
|
||||
"${sodium_DIR}/bin/libsodium*.dll"
|
||||
)
|
||||
find_library(sodium_DLL_DEBUG ${_DLL} libsodium
|
||||
HINTS ${sodium_DIR}
|
||||
PATH_SUFFIXES bin
|
||||
)
|
||||
find_library(sodium_DLL_RELEASE ${_DLL} libsodium
|
||||
HINTS ${sodium_DIR}
|
||||
PATH_SUFFIXES bin
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
|
||||
endif()
|
||||
|
||||
|
||||
########################################################################
|
||||
# unsupported
|
||||
else()
|
||||
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
|
||||
endif()
|
||||
|
||||
|
||||
########################################################################
|
||||
# common stuff
|
||||
|
||||
# extract sodium version
|
||||
if (sodium_INCLUDE_DIR)
|
||||
set(_VERSION_HEADER "${_INCLUDE_DIR}/sodium/version.h")
|
||||
if (EXISTS _VERSION_HEADER)
|
||||
file(READ "${_VERSION_HEADER}" _VERSION_HEADER_CONTENT)
|
||||
string(REGEX REPLACE ".*#[ \t]*define[ \t]*SODIUM_VERSION_STRING[ \t]*\"([^\n]*)\".*" "\\1"
|
||||
sodium_VERSION "${_VERSION_HEADER_CONTENT}")
|
||||
set(sodium_VERSION "${sodium_VERSION}" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# communicate results
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
Sodium # The name must be either uppercase or match the filename case.
|
||||
REQUIRED_VARS
|
||||
sodium_LIBRARY_RELEASE
|
||||
sodium_LIBRARY_DEBUG
|
||||
sodium_INCLUDE_DIR
|
||||
VERSION_VAR
|
||||
sodium_VERSION
|
||||
)
|
||||
|
||||
if(Sodium_FOUND)
|
||||
set(sodium_LIBRARIES
|
||||
optimized ${sodium_LIBRARY_RELEASE} debug ${sodium_LIBRARY_DEBUG})
|
||||
endif()
|
||||
|
||||
# mark file paths as advanced
|
||||
mark_as_advanced(sodium_INCLUDE_DIR)
|
||||
mark_as_advanced(sodium_LIBRARY_DEBUG)
|
||||
mark_as_advanced(sodium_LIBRARY_RELEASE)
|
||||
if (WIN32)
|
||||
mark_as_advanced(sodium_DLL_DEBUG)
|
||||
mark_as_advanced(sodium_DLL_RELEASE)
|
||||
endif()
|
||||
|
||||
# create imported target
|
||||
if(sodium_USE_STATIC_LIBS)
|
||||
set(_LIB_TYPE STATIC)
|
||||
else()
|
||||
set(_LIB_TYPE SHARED)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET sodium)
|
||||
add_library(sodium ${_LIB_TYPE} IMPORTED)
|
||||
endif()
|
||||
|
||||
set_target_properties(sodium PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${sodium_INCLUDE_DIR}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
)
|
||||
|
||||
if (sodium_USE_STATIC_LIBS)
|
||||
set_target_properties(sodium PROPERTIES
|
||||
INTERFACE_COMPILE_DEFINITIONS "SODIUM_STATIC"
|
||||
IMPORTED_LOCATION "${sodium_LIBRARY_RELEASE}"
|
||||
IMPORTED_LOCATION_DEBUG "${sodium_LIBRARY_DEBUG}"
|
||||
)
|
||||
else()
|
||||
if (UNIX)
|
||||
set_target_properties(sodium PROPERTIES
|
||||
IMPORTED_LOCATION "${sodium_LIBRARY_RELEASE}"
|
||||
IMPORTED_LOCATION_DEBUG "${sodium_LIBRARY_DEBUG}"
|
||||
)
|
||||
elseif (WIN32)
|
||||
set_target_properties(sodium PROPERTIES
|
||||
IMPORTED_IMPLIB "${sodium_LIBRARY_RELEASE}"
|
||||
IMPORTED_IMPLIB_DEBUG "${sodium_LIBRARY_DEBUG}"
|
||||
)
|
||||
if (NOT (sodium_DLL_DEBUG MATCHES ".*-NOTFOUND"))
|
||||
set_target_properties(sodium PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${sodium_DLL_DEBUG}"
|
||||
)
|
||||
endif()
|
||||
if (NOT (sodium_DLL_RELEASE MATCHES ".*-NOTFOUND"))
|
||||
set_target_properties(sodium PROPERTIES
|
||||
IMPORTED_LOCATION_RELWITHDEBINFO "${sodium_DLL_RELEASE}"
|
||||
IMPORTED_LOCATION_MINSIZEREL "${sodium_DLL_RELEASE}"
|
||||
IMPORTED_LOCATION_RELEASE "${sodium_DLL_RELEASE}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
@ -1,65 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
option(SANITIZE_THREAD "Enable ThreadSanitizer for sanitized targets." Off)
|
||||
|
||||
set(FLAG_CANDIDATES
|
||||
"-g -fsanitize=thread"
|
||||
)
|
||||
|
||||
|
||||
# ThreadSanitizer is not compatible with MemorySanitizer.
|
||||
if (SANITIZE_THREAD AND SANITIZE_MEMORY)
|
||||
message(FATAL_ERROR "ThreadSanitizer is not compatible with "
|
||||
"MemorySanitizer.")
|
||||
endif ()
|
||||
|
||||
|
||||
include(sanitize-helpers)
|
||||
|
||||
if (SANITIZE_THREAD)
|
||||
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND
|
||||
NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
message(WARNING "ThreadSanitizer disabled for target ${TARGET} because "
|
||||
"ThreadSanitizer is supported for Linux systems and macOS only.")
|
||||
set(SANITIZE_THREAD Off CACHE BOOL
|
||||
"Enable ThreadSanitizer for sanitized targets." FORCE)
|
||||
elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
message(WARNING "ThreadSanitizer disabled for target ${TARGET} because "
|
||||
"ThreadSanitizer is supported for 64bit systems only.")
|
||||
set(SANITIZE_THREAD Off CACHE BOOL
|
||||
"Enable ThreadSanitizer for sanitized targets." FORCE)
|
||||
else ()
|
||||
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "ThreadSanitizer"
|
||||
"TSan")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
function (add_sanitize_thread TARGET)
|
||||
if (NOT SANITIZE_THREAD)
|
||||
return()
|
||||
endif ()
|
||||
|
||||
sanitizer_add_flags(${TARGET} "ThreadSanitizer" "TSan")
|
||||
endfunction ()
|
@ -1,46 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
option(SANITIZE_UNDEFINED
|
||||
"Enable UndefinedBehaviorSanitizer for sanitized targets." Off)
|
||||
|
||||
set(FLAG_CANDIDATES
|
||||
"-g -fsanitize=undefined"
|
||||
)
|
||||
|
||||
|
||||
include(sanitize-helpers)
|
||||
|
||||
if (SANITIZE_UNDEFINED)
|
||||
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}"
|
||||
"UndefinedBehaviorSanitizer" "UBSan")
|
||||
endif ()
|
||||
|
||||
function (add_sanitize_undefined TARGET)
|
||||
if (NOT SANITIZE_UNDEFINED)
|
||||
return()
|
||||
endif ()
|
||||
|
||||
sanitizer_add_flags(${TARGET} "UndefinedBehaviorSanitizer" "UBSan")
|
||||
endfunction ()
|
@ -1,55 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# This script is a wrapper for AddressSanitizer. In some special cases you need
|
||||
# to preload AddressSanitizer to avoid error messages - e.g. if you're
|
||||
# preloading another library to your application. At the moment this script will
|
||||
# only do something, if we're running on a Linux platform. OSX might not be
|
||||
# affected.
|
||||
|
||||
|
||||
# Exit immediately, if platform is not Linux.
|
||||
if [ "$(uname)" != "Linux" ]
|
||||
then
|
||||
exec $@
|
||||
fi
|
||||
|
||||
|
||||
# Get the used libasan of the application ($1). If a libasan was found, it will
|
||||
# be prepended to LD_PRELOAD.
|
||||
libasan=$(ldd $1 | grep libasan | sed "s/^[[:space:]]//" | cut -d' ' -f1)
|
||||
if [ -n "$libasan" ]
|
||||
then
|
||||
if [ -n "$LD_PRELOAD" ]
|
||||
then
|
||||
export LD_PRELOAD="$libasan:$LD_PRELOAD"
|
||||
else
|
||||
export LD_PRELOAD="$libasan"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Execute the application.
|
||||
exec $@
|
@ -1,177 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# Helper function to get the language of a source file.
|
||||
function (sanitizer_lang_of_source FILE RETURN_VAR)
|
||||
get_filename_component(LONGEST_EXT "${FILE}" EXT)
|
||||
# If extension is empty return. This can happen for extensionless headers
|
||||
if("${LONGEST_EXT}" STREQUAL "")
|
||||
set(${RETURN_VAR} "" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
# Get shortest extension as some files can have dot in their names
|
||||
string(REGEX REPLACE "^.*(\\.[^.]+)$" "\\1" FILE_EXT ${LONGEST_EXT})
|
||||
string(TOLOWER "${FILE_EXT}" FILE_EXT)
|
||||
string(SUBSTRING "${FILE_EXT}" 1 -1 FILE_EXT)
|
||||
|
||||
get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
foreach (LANG ${ENABLED_LANGUAGES})
|
||||
list(FIND CMAKE_${LANG}_SOURCE_FILE_EXTENSIONS "${FILE_EXT}" TEMP)
|
||||
if (NOT ${TEMP} EQUAL -1)
|
||||
set(${RETURN_VAR} "${LANG}" PARENT_SCOPE)
|
||||
return()
|
||||
endif ()
|
||||
endforeach()
|
||||
|
||||
set(${RETURN_VAR} "" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
|
||||
# Helper function to get compilers used by a target.
|
||||
function (sanitizer_target_compilers TARGET RETURN_VAR)
|
||||
# Check if all sources for target use the same compiler. If a target uses
|
||||
# e.g. C and Fortran mixed and uses different compilers (e.g. clang and
|
||||
# gfortran) this can trigger huge problems, because different compilers may
|
||||
# use different implementations for sanitizers.
|
||||
set(BUFFER "")
|
||||
get_target_property(TSOURCES ${TARGET} SOURCES)
|
||||
foreach (FILE ${TSOURCES})
|
||||
# If expression was found, FILE is a generator-expression for an object
|
||||
# library. Object libraries will be ignored.
|
||||
string(REGEX MATCH "TARGET_OBJECTS:([^ >]+)" _file ${FILE})
|
||||
if ("${_file}" STREQUAL "")
|
||||
sanitizer_lang_of_source(${FILE} LANG)
|
||||
if (LANG)
|
||||
list(APPEND BUFFER ${CMAKE_${LANG}_COMPILER_ID})
|
||||
endif ()
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
list(REMOVE_DUPLICATES BUFFER)
|
||||
set(${RETURN_VAR} "${BUFFER}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
|
||||
# Helper function to check compiler flags for language compiler.
|
||||
function (sanitizer_check_compiler_flag FLAG LANG VARIABLE)
|
||||
if (${LANG} STREQUAL "C")
|
||||
include(CheckCCompilerFlag)
|
||||
check_c_compiler_flag("${FLAG}" ${VARIABLE})
|
||||
|
||||
elseif (${LANG} STREQUAL "CXX")
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag("${FLAG}" ${VARIABLE})
|
||||
|
||||
elseif (${LANG} STREQUAL "Fortran")
|
||||
# CheckFortranCompilerFlag was introduced in CMake 3.x. To be compatible
|
||||
# with older Cmake versions, we will check if this module is present
|
||||
# before we use it. Otherwise we will define Fortran coverage support as
|
||||
# not available.
|
||||
include(CheckFortranCompilerFlag OPTIONAL RESULT_VARIABLE INCLUDED)
|
||||
if (INCLUDED)
|
||||
check_fortran_compiler_flag("${FLAG}" ${VARIABLE})
|
||||
elseif (NOT CMAKE_REQUIRED_QUIET)
|
||||
message(STATUS "Performing Test ${VARIABLE}")
|
||||
message(STATUS "Performing Test ${VARIABLE}"
|
||||
" - Failed (Check not supported)")
|
||||
endif ()
|
||||
endif()
|
||||
endfunction ()
|
||||
|
||||
|
||||
# Helper function to test compiler flags.
|
||||
function (sanitizer_check_compiler_flags FLAG_CANDIDATES NAME PREFIX)
|
||||
set(CMAKE_REQUIRED_QUIET ${${PREFIX}_FIND_QUIETLY})
|
||||
|
||||
get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
foreach (LANG ${ENABLED_LANGUAGES})
|
||||
# Sanitizer flags are not dependend on language, but the used compiler.
|
||||
# So instead of searching flags foreach language, search flags foreach
|
||||
# compiler used.
|
||||
set(COMPILER ${CMAKE_${LANG}_COMPILER_ID})
|
||||
if (NOT DEFINED ${PREFIX}_${COMPILER}_FLAGS)
|
||||
foreach (FLAG ${FLAG_CANDIDATES})
|
||||
if(NOT CMAKE_REQUIRED_QUIET)
|
||||
message(STATUS "Try ${COMPILER} ${NAME} flag = [${FLAG}]")
|
||||
endif()
|
||||
|
||||
set(CMAKE_REQUIRED_FLAGS "${FLAG}")
|
||||
unset(${PREFIX}_FLAG_DETECTED CACHE)
|
||||
sanitizer_check_compiler_flag("${FLAG}" ${LANG}
|
||||
${PREFIX}_FLAG_DETECTED)
|
||||
|
||||
if (${PREFIX}_FLAG_DETECTED)
|
||||
# If compiler is a GNU compiler, search for static flag, if
|
||||
# SANITIZE_LINK_STATIC is enabled.
|
||||
if (SANITIZE_LINK_STATIC AND (${COMPILER} STREQUAL "GNU"))
|
||||
string(TOLOWER ${PREFIX} PREFIX_lower)
|
||||
sanitizer_check_compiler_flag(
|
||||
"-static-lib${PREFIX_lower}" ${LANG}
|
||||
${PREFIX}_STATIC_FLAG_DETECTED)
|
||||
|
||||
if (${PREFIX}_STATIC_FLAG_DETECTED)
|
||||
set(FLAG "-static-lib${PREFIX_lower} ${FLAG}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
set(${PREFIX}_${COMPILER}_FLAGS "${FLAG}" CACHE STRING
|
||||
"${NAME} flags for ${COMPILER} compiler.")
|
||||
mark_as_advanced(${PREFIX}_${COMPILER}_FLAGS)
|
||||
break()
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
if (NOT ${PREFIX}_FLAG_DETECTED)
|
||||
set(${PREFIX}_${COMPILER}_FLAGS "" CACHE STRING
|
||||
"${NAME} flags for ${COMPILER} compiler.")
|
||||
mark_as_advanced(${PREFIX}_${COMPILER}_FLAGS)
|
||||
|
||||
message(WARNING "${NAME} is not available for ${COMPILER} "
|
||||
"compiler. Targets using this compiler will be "
|
||||
"compiled without ${NAME}.")
|
||||
endif ()
|
||||
endif ()
|
||||
endforeach ()
|
||||
endfunction ()
|
||||
|
||||
|
||||
# Helper to assign sanitizer flags for TARGET.
|
||||
function (sanitizer_add_flags TARGET NAME PREFIX)
|
||||
# Get list of compilers used by target and check, if sanitizer is available
|
||||
# for this target. Other compiler checks like check for conflicting
|
||||
# compilers will be done in add_sanitizers function.
|
||||
sanitizer_target_compilers(${TARGET} TARGET_COMPILER)
|
||||
list(LENGTH TARGET_COMPILER NUM_COMPILERS)
|
||||
if ("${${PREFIX}_${TARGET_COMPILER}_FLAGS}" STREQUAL "")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Set compile- and link-flags for target.
|
||||
set_property(TARGET ${TARGET} APPEND_STRING
|
||||
PROPERTY COMPILE_FLAGS " ${${PREFIX}_${TARGET_COMPILER}_FLAGS}")
|
||||
set_property(TARGET ${TARGET} APPEND_STRING
|
||||
PROPERTY COMPILE_FLAGS " ${SanBlist_${TARGET_COMPILER}_FLAGS}")
|
||||
set_property(TARGET ${TARGET} APPEND_STRING
|
||||
PROPERTY LINK_FLAGS " ${${PREFIX}_${TARGET_COMPILER}_FLAGS}")
|
||||
endfunction ()
|
Loading…
Reference in New Issue
Block a user