Commit 016bf4a8 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Make pigment and krita build with vc available

This copies the VcMacros.cmake and dependent files from Vc master. That
resolves the INCLUDE_DIRECTORIES problem. It also adds -fabi flags to the
PACKAGERS_BUILD macros, which resolves the build problem.

When Vc 1.0 is released, we remove the cmake/vc folder and port to the
new Vc.

Thanks to Matthias Kretz, Alex Merry, Stepen Kelly, Elvis Stansvik for their
help figuring out the issues!
parent 8b30b520
......@@ -472,10 +472,13 @@ configure_file(config-vc.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-vc.h )
if(HAVE_VC)
message(STATUS "Vc found!")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake/vc")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${Vc_CMAKE_MODULES_DIR}")
include (VcMacros)
set(ADDITIONAL_VC_FLAGS "-Wabi -fabi-version=0 -ffp-contract=fast")
#Handle Vc master
if(Vc_VERSION_MAJOR GREATER 0 OR Vc_VERSION_MINOR GREATER 7)
message(STATUS "Vc version is greater than 0.7, enabling AVX2 support")
......@@ -489,7 +492,7 @@ if(HAVE_VC)
macro(ko_compile_for_all_implementations_no_scalar _objs _src)
if(PACKAGERS_BUILD)
vc_compile_for_all_implementations(${_objs} ${_src} FLAGS -fPIC ONLY SSE2 SSSE3 SSE4_1 AVX AVX2)
vc_compile_for_all_implementations(${_objs} ${_src} FLAGS ${ADDITIONAL_VC_FLAGS} -fPIC ONLY SSE2 SSSE3 SSE4_1 AVX AVX2)
else()
set(${_objs} ${_src})
endif()
......@@ -497,7 +500,7 @@ if(HAVE_VC)
macro(ko_compile_for_all_implementations _objs _src)
if(PACKAGERS_BUILD)
vc_compile_for_all_implementations(${_objs} ${_src} FLAGS -fPIC ONLY Scalar SSE2 SSSE3 SSE4_1 AVX AVX2)
vc_compile_for_all_implementations(${_objs} ${_src} FLAGS ${ADDITIONAL_VC_FLAGS} -fPIC ONLY Scalar SSE2 SSSE3 SSE4_1 AVX AVX2)
else()
set(${_objs} ${_src})
endif()
......@@ -505,7 +508,7 @@ if(HAVE_VC)
else()
macro(ko_compile_for_all_implementations_no_scalar _objs _src)
if(PACKAGERS_BUILD)
vc_compile_for_all_implementations(${_objs} ${_src} FLAGS -fPIC ONLY SSE2 SSSE3 SSE4_1 AVX)
vc_compile_for_all_implementations(${_objs} ${_src} FLAGS ${ADDITIONAL_VC_FLAGS} -fPIC ONLY SSE2 SSSE3 SSE4_1 AVX)
else()
set(${_objs} ${_src})
endif()
......@@ -513,7 +516,7 @@ if(HAVE_VC)
macro(ko_compile_for_all_implementations _objs _src)
if(PACKAGERS_BUILD)
vc_compile_for_all_implementations(${_objs} ${_src} FLAGS -fPIC ONLY Scalar SSE2 SSSE3 SSE4_1 AVX)
vc_compile_for_all_implementations(${_objs} ${_src} FLAGS ${ADDITIONAL_VC_FLAGS} -fPIC ONLY Scalar SSE2 SSSE3 SSE4_1 AVX)
else()
set(${_objs} ${_src})
endif()
......
# - Add a given compiler flag to flags variables.
# AddCompilerFlag(<flag> [<var>])
# or
# AddCompilerFlag(<flag> [C_FLAGS <var>] [CXX_FLAGS <var>] [C_RESULT <var>]
# [CXX_RESULT <var>])
#=============================================================================
# Copyright 2010-2013 Matthias Kretz <kretz@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
get_filename_component(_currentDir "${CMAKE_CURRENT_LIST_FILE}" PATH)
include("${_currentDir}/CheckCCompilerFlag.cmake")
include("${_currentDir}/CheckCXXCompilerFlag.cmake")
include("${_currentDir}/CheckMicCCompilerFlag.cmake")
include("${_currentDir}/CheckMicCXXCompilerFlag.cmake")
macro(AddCompilerFlag _flag)
string(REGEX REPLACE "[-.+/:= ]" "_" _flag_esc "${_flag}")
set(_c_flags "CMAKE_C_FLAGS")
set(_cxx_flags "CMAKE_CXX_FLAGS")
set(_mic_c_flags "CMAKE_MIC_C_FLAGS")
set(_mic_cxx_flags "CMAKE_MIC_CXX_FLAGS")
set(_c_result tmp)
set(_cxx_result tmp)
set(_mic_c_result)
set(_mic_cxx_result)
if(${ARGC} EQUAL 2)
message(WARNING "Deprecated use of the AddCompilerFlag macro.")
unset(_c_result)
set(_cxx_result ${ARGV1})
elseif(${ARGC} GREATER 2)
set(state 0)
unset(_c_flags)
unset(_cxx_flags)
unset(_mic_c_flags)
unset(_mic_cxx_flags)
unset(_c_result)
unset(_cxx_result)
unset(_mic_c_result)
unset(_mic_cxx_result)
foreach(_arg ${ARGN})
if(_arg STREQUAL "C_FLAGS")
set(state 1)
if(NOT DEFINED _c_result)
set(_c_result tmp)
endif()
elseif(_arg STREQUAL "CXX_FLAGS")
set(state 2)
if(NOT DEFINED _cxx_result)
set(_cxx_result tmp)
endif()
elseif(_arg STREQUAL "C_RESULT")
set(state 3)
elseif(_arg STREQUAL "CXX_RESULT")
set(state 4)
elseif(_arg STREQUAL "MIC_C_RESULT")
set(state 5)
elseif(_arg STREQUAL "MIC_CXX_RESULT")
set(state 6)
elseif(_arg STREQUAL "MIC_C_FLAGS")
set(state 7)
elseif(_arg STREQUAL "MIC_CXX_FLAGS")
set(state 8)
elseif(state EQUAL 1)
set(_c_flags "${_arg}")
elseif(state EQUAL 2)
set(_cxx_flags "${_arg}")
elseif(state EQUAL 3)
set(_c_result "${_arg}")
elseif(state EQUAL 4)
set(_cxx_result "${_arg}")
elseif(state EQUAL 5)
set(_mic_c_result "${_arg}")
elseif(state EQUAL 6)
set(_mic_cxx_result "${_arg}")
elseif(state EQUAL 7)
set(_mic_c_flags "${_arg}")
elseif(state EQUAL 8)
set(_mic_cxx_flags "${_arg}")
else()
message(FATAL_ERROR "Syntax error for AddCompilerFlag")
endif()
endforeach()
endif()
if("${_flag}" STREQUAL "-mfma")
# Compiling with FMA3 support may fail only at the assembler level.
# In that case we need to have such an instruction in the test code
set(_code "#include <immintrin.h>
__m128 foo(__m128 x) { return _mm_fmadd_ps(x, x, x); }
int main() { return 0; }")
elseif("${_flag}" STREQUAL "-stdlib=libc++")
# Compiling with libc++ not only requires a compiler that understands it, but also
# the libc++ headers itself
set(_code "#include <iostream>
int main() { return 0; }")
else()
set(_code "int main() { return 0; }")
endif()
if(DEFINED _c_result)
check_c_compiler_flag("${_flag}" check_c_compiler_flag_${_flag_esc} "${_code}")
set(${_c_result} ${check_c_compiler_flag_${_flag_esc}})
endif()
if(DEFINED _cxx_result)
check_cxx_compiler_flag("${_flag}" check_cxx_compiler_flag_${_flag_esc} "${_code}")
set(${_cxx_result} ${check_cxx_compiler_flag_${_flag_esc}})
endif()
if(check_c_compiler_flag_${_flag_esc} AND DEFINED _c_flags)
set(${_c_flags} "${${_c_flags}} ${_flag}")
endif()
if(check_cxx_compiler_flag_${_flag_esc} AND DEFINED _cxx_flags)
set(${_cxx_flags} "${${_cxx_flags}} ${_flag}")
endif()
if(MIC_NATIVE_FOUND)
if(DEFINED _mic_c_result)
check_mic_c_compiler_flag("${_flag}" check_mic_c_compiler_flag_${_flag_esc} "${_code}")
set(${_mic_c_result} ${check_mic_c_compiler_flag_${_flag_esc}})
endif()
if(DEFINED _mic_cxx_result)
check_mic_cxx_compiler_flag("${_flag}" check_mic_cxx_compiler_flag_${_flag_esc} "${_code}")
set(${_mic_cxx_result} ${check_mic_cxx_compiler_flag_${_flag_esc}})
endif()
if(check_mic_c_compiler_flag_${_flag_esc} AND DEFINED _mic_c_flags)
set(${_mic_c_flags} "${${_mic_c_flags}} ${_flag}")
endif()
if(check_mic_cxx_compiler_flag_${_flag_esc} AND DEFINED _mic_cxx_flags)
set(${_mic_cxx_flags} "${${_mic_cxx_flags}} ${_flag}")
endif()
endif()
endmacro(AddCompilerFlag)
#=============================================================================
# Copyright 2010-2013 Matthias Kretz <kretz@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
macro(add_target_property _target _prop _value)
get_target_property(_oldprop "${_target}" ${_prop})
if(NOT _oldprop)
set_target_properties("${_target}" PROPERTIES ${_prop} "${_value}")
else(NOT _oldprop)
set_target_properties("${_target}" PROPERTIES ${_prop} "${_oldprop} ${_value}")
endif(NOT _oldprop)
endmacro(add_target_property)
# - Check whether the C compiler supports a given flag.
# CHECK_C_COMPILER_FLAG(<flag> <var>)
# <flag> - the compiler flag
# <var> - variable to store the result
# This internally calls the check_c_source_compiles macro.
# See help for CheckCSourceCompiles for a listing of variables
# that can modify the build.
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
# Copyright 2006 Alexander Neundorf <neundorf@kde.org>
# Copyright 2011-2013 Matthias Kretz <kretz@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
INCLUDE(CheckCSourceCompiles)
MACRO (CHECK_C_COMPILER_FLAG _FLAG _RESULT)
SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
if(${ARGC} GREATER 2)
SET(TEST_SOURCE "${ARGV2}")
else()
SET(TEST_SOURCE "int main() { return 0;}")
endif()
CHECK_C_SOURCE_COMPILES("${TEST_SOURCE}" ${_RESULT}
# Some compilers do not fail with a bad flag
FAIL_REGEX "error: bad value (.*) for .* switch" # GNU
FAIL_REGEX "argument unused during compilation" # clang
FAIL_REGEX "is valid for .* but not for C" # GNU
FAIL_REGEX "unrecognized .*option" # GNU
FAIL_REGEX "ignored for target" # GNU
FAIL_REGEX "ignoring unknown option" # MSVC
FAIL_REGEX "[Uu]nknown option" # HP
FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro
FAIL_REGEX "command option .* is not recognized" # XL
FAIL_REGEX "WARNING: unknown flag:" # Open64
FAIL_REGEX "command line error" # ICC
FAIL_REGEX "command line warning" # ICC
FAIL_REGEX "#10236:" # ICC: File not found
)
SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
ENDMACRO (CHECK_C_COMPILER_FLAG)
# - Check whether the CXX compiler supports a given flag.
# CHECK_CXX_COMPILER_FLAG(<flag> <var>)
# <flag> - the compiler flag
# <var> - variable to store the result
# This internally calls the check_cxx_source_compiles macro. See help
# for CheckCXXSourceCompiles for a listing of variables that can
# modify the build.
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
# Copyright 2006 Alexander Neundorf <neundorf@kde.org>
# Copyright 2011-2013 Matthias Kretz <kretz@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
INCLUDE(CheckCXXSourceCompiles)
MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
if(${ARGC} GREATER 2)
SET(TEST_SOURCE "${ARGV2}")
else()
SET(TEST_SOURCE "int main() { return 0;}")
endif()
CHECK_CXX_SOURCE_COMPILES("${TEST_SOURCE}" ${_RESULT}
# Some compilers do not fail with a bad flag
FAIL_REGEX "error: bad value (.*) for .* switch" # GNU
FAIL_REGEX "argument unused during compilation" # clang
FAIL_REGEX "is valid for .* but not for C\\\\+\\\\+" # GNU
FAIL_REGEX "unrecognized .*option" # GNU
FAIL_REGEX "ignored for target" # GNU
FAIL_REGEX "ignoring unknown option" # MSVC
FAIL_REGEX "[Uu]nknown option" # HP
FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro
FAIL_REGEX "command option .* is not recognized" # XL
FAIL_REGEX "WARNING: unknown flag:" # Open64
FAIL_REGEX "command line error" # ICC
FAIL_REGEX "command line warning" # ICC
FAIL_REGEX "#10236:" # ICC: File not found
)
SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
ENDMACRO (CHECK_CXX_COMPILER_FLAG)
# - Check whether the MIC C compiler supports a given flag.
# CHECK_MIC_C_COMPILER_FLAG(<flag> <var>)
# <flag> - the compiler flag
# <var> - variable to store the result
# This internally calls the check_c_source_compiles macro. See help
# for CheckCSourceCompiles for a listing of variables that can
# modify the build.
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
# Copyright 2006 Alexander Neundorf <neundorf@kde.org>
# Copyright 2011-2013 Matthias Kretz <kretz@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
macro(check_mic_c_compiler_flag _FLAG _RESULT)
if("${_RESULT}" MATCHES "^${_RESULT}$")
set(_tmpdir "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp")
if(${ARGC} GREATER 2)
file(WRITE "${_tmpdir}/src.c" "${ARGV2}")
else()
file(WRITE "${_tmpdir}/src.c" "int main() { return 0; }")
endif()
execute_process(
COMMAND "${MIC_CC}" -mmic -c -o "${_tmpdir}/src.o"
"${_FLAG}" "${_tmpdir}/src.c"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE ${_RESULT}
OUTPUT_VARIABLE OUTPUT
ERROR_VARIABLE OUTPUT
)
if(${_RESULT})
foreach(_fail_regex
"error: bad value (.*) for .* switch" # GNU
"argument unused during compilation" # clang
"is valid for .* but not for C" # GNU
"unrecognized .*option" # GNU
"ignored for target" # GNU
"ignoring unknown option" # MSVC
"[Uu]nknown option" # HP
"[Ww]arning: [Oo]ption" # SunPro
"command option .* is not recognized" # XL
"WARNING: unknown flag:" # Open64
"command line error" # ICC
"command line warning" # ICC
"#10236:" # ICC: File not found
)
if("${OUTPUT}" MATCHES "${_fail_regex}")
set(${_RESULT} FALSE)
endif()
endforeach()
endif()
if(${_RESULT})
set(${_RESULT} 1 CACHE INTERNAL "Test ${_FLAG}")
message(STATUS "Performing Test Check MIC C Compiler flag ${_FLAG} - Success")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Performing MIC C Compiler Flag Test ${_FLAG} succeded with the following output:\n"
"${OUTPUT}\n"
"COMMAND: ${MIC_CC} -mmic -c -o ${_tmpdir}/src.o ${_FLAG} ${_tmpdir}/src.cpp\n"
)
else()
message(STATUS "Performing Test Check MIC C Compiler flag ${_FLAG} - Failed")
set(${_RESULT} "" CACHE INTERNAL "Test ${_FLAG}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing MIC C Compiler Flag Test ${_FLAG} failed with the following output:\n"
"${OUTPUT}\n"
"COMMAND: ${MIC_CC} -mmic -c -o ${_tmpdir}/src.o ${_FLAG} ${_tmpdir}/src.cpp\n"
)
endif()
endif()
endmacro()
# - Check whether the MIC CXX compiler supports a given flag.
# CHECK_MIC_CXX_COMPILER_FLAG(<flag> <var>)
# <flag> - the compiler flag
# <var> - variable to store the result
# This internally calls the check_cxx_source_compiles macro. See help
# for CheckCXXSourceCompiles for a listing of variables that can
# modify the build.
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
# Copyright 2006 Alexander Neundorf <neundorf@kde.org>
# Copyright 2011-2013 Matthias Kretz <kretz@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
macro(check_mic_cxx_compiler_flag _FLAG _RESULT)
if("${_RESULT}" MATCHES "^${_RESULT}$")
set(_tmpdir "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp")
if(${ARGC} GREATER 2)
file(WRITE "${_tmpdir}/src.cpp" "${ARGV2}")
else()
file(WRITE "${_tmpdir}/src.cpp" "int main() { return 0; }")
endif()
execute_process(
COMMAND "${MIC_CXX}" -mmic -c -o "${_tmpdir}/src.o"
"${_FLAG}" "${_tmpdir}/src.cpp"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE ${_RESULT}
OUTPUT_VARIABLE OUTPUT
ERROR_VARIABLE OUTPUT
)
if(${_RESULT} EQUAL 0)
foreach(_fail_regex
"error: bad value (.*) for .* switch" # GNU
"argument unused during compilation" # clang
"is valid for .* but not for C\\\\+\\\\+" # GNU
"unrecognized .*option" # GNU
"ignored for target" # GNU
"ignoring unknown option" # MSVC
"[Uu]nknown option" # HP
"[Ww]arning: [Oo]ption" # SunPro
"command option .* is not recognized" # XL
"WARNING: unknown flag:" # Open64
"command line error" # ICC
"command line warning" # ICC
"#10236:" # ICC: File not found
)
if("${OUTPUT}" MATCHES "${_fail_regex}")
set(${_RESULT} FALSE)
endif()
endforeach()
endif()
if(${_RESULT} EQUAL 0)
set(${_RESULT} 1 CACHE INTERNAL "Test ${_FLAG}")
message(STATUS "Performing Test Check MIC C++ Compiler flag ${_FLAG} - Success")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Performing MIC C++ Compiler Flag Test ${_FLAG} succeded with the following output:\n"
"${OUTPUT}\n"
"COMMAND: ${MIC_CXX} -mmic -c -o ${_tmpdir}/src.o ${_FLAG} ${_tmpdir}/src.cpp\n"
)
else()
message(STATUS "Performing Test Check MIC C++ Compiler flag ${_FLAG} - Failed")
set(${_RESULT} "" CACHE INTERNAL "Test ${_FLAG}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing MIC C++ Compiler Flag Test ${_FLAG} failed with the following output:\n"
"${OUTPUT}\n"
"COMMAND: ${MIC_CXX} -mmic -c -o ${_tmpdir}/src.o ${_FLAG} ${_tmpdir}/src.cpp\n"
)
endif()
endif()
endmacro()
This diff is collapsed.
# Check if SSE instructions are available on the machine where
# the project is compiled.
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
EXEC_PROGRAM(cat ARGS "/proc/cpuinfo" OUTPUT_VARIABLE CPUINFO)
STRING(REGEX REPLACE "^.*(sse2).*$" "\\1" SSE_THERE ${CPUINFO})
STRING(COMPARE EQUAL "sse2" "${SSE_THERE}" SSE2_TRUE)
IF (SSE2_TRUE)
set(SSE2_FOUND true CACHE BOOL "SSE2 available on host")
ELSE (SSE2_TRUE)
set(SSE2_FOUND false CACHE BOOL "SSE2 available on host")
ENDIF (SSE2_TRUE)
# /proc/cpuinfo apparently omits sse3 :(
STRING(REGEX REPLACE "^.*[^s](sse3).*$" "\\1" SSE_THERE ${CPUINFO})
STRING(COMPARE EQUAL "sse3" "${SSE_THERE}" SSE3_TRUE)
IF (NOT SSE3_TRUE)
STRING(REGEX REPLACE "^.*(T2300).*$" "\\1" SSE_THERE ${CPUINFO})
STRING(COMPARE EQUAL "T2300" "${SSE_THERE}" SSE3_TRUE)
ENDIF (NOT SSE3_TRUE)
STRING(REGEX REPLACE "^.*(ssse3).*$" "\\1" SSE_THERE ${CPUINFO})
STRING(COMPARE EQUAL "ssse3" "${SSE_THERE}" SSSE3_TRUE)
IF (SSE3_TRUE OR SSSE3_TRUE)
set(SSE3_FOUND true CACHE BOOL "SSE3 available on host")
ELSE (SSE3_TRUE OR SSSE3_TRUE)
set(SSE3_FOUND false CACHE BOOL "SSE3 available on host")
ENDIF (SSE3_TRUE OR SSSE3_TRUE)
IF (SSSE3_TRUE)
set(SSSE3_FOUND true CACHE BOOL "SSSE3 available on host")
ELSE (SSSE3_TRUE)
set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host")
ENDIF (SSSE3_TRUE)
STRING(REGEX REPLACE "^.*(sse4_1).*$" "\\1" SSE_THERE ${CPUINFO})
STRING(COMPARE EQUAL "sse4_1" "${SSE_THERE}" SSE41_TRUE)
IF (SSE41_TRUE)
set(SSE4_1_FOUND true CACHE BOOL "SSE4.1 available on host")
ELSE (SSE41_TRUE)
set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host")
ENDIF (SSE41_TRUE)
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
EXEC_PROGRAM("/usr/sbin/sysctl -n machdep.cpu.features" OUTPUT_VARIABLE
CPUINFO)
STRING(REGEX REPLACE "^.*[^S](SSE2).*$" "\\1" SSE_THERE ${CPUINFO})
STRING(COMPARE EQUAL "SSE2" "${SSE_THERE}" SSE2_TRUE)
IF (SSE2_TRUE)
set(SSE2_FOUND true CACHE BOOL "SSE2 available on host")
ELSE (SSE2_TRUE)
set(SSE2_FOUND false CACHE BOOL "SSE2 available on host")
ENDIF (SSE2_TRUE)
STRING(REGEX REPLACE "^.*[^S](SSE3).*$" "\\1" SSE_THERE ${CPUINFO})
STRING(COMPARE EQUAL "SSE3" "${SSE_THERE}" SSE3_TRUE)
IF (SSE3_TRUE)
set(SSE3_FOUND true CACHE BOOL "SSE3 available on host")
ELSE (SSE3_TRUE)
set(SSE3_FOUND false CACHE BOOL "SSE3 available on host")
ENDIF (SSE3_TRUE)
STRING(REGEX REPLACE "^.*(SSSE3).*$" "\\1" SSE_THERE ${CPUINFO})
STRING(COMPARE EQUAL "SSSE3" "${SSE_THERE}" SSSE3_TRUE)
IF (SSSE3_TRUE)
set(SSSE3_FOUND true CACHE BOOL "SSSE3 available on host")
ELSE (SSSE3_TRUE)
set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host")
ENDIF (SSSE3_TRUE)
STRING(REGEX REPLACE "^.*(SSE4.1).*$" "\\1" SSE_THERE ${CPUINFO})
STRING(COMPARE EQUAL "SSE4.1" "${SSE_THERE}" SSE41_TRUE)
IF (SSE41_TRUE)
set(SSE4_1_FOUND true CACHE BOOL "SSE4.1 available on host")
ELSE (SSE41_TRUE)
set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host")
ENDIF<