diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-07-15 16:57:19 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-07-15 16:57:19 +0000 |
commit | 5b4acbd6b6bceaa3ea25b237168b434a24e1181d (patch) | |
tree | 02a4990e110c1aa3af4a31a071a17d5646fd7c55 /openmp/runtime/cmake | |
parent | 21ca199cead1044385001204eddb3c9cfe63bc33 (diff) | |
download | bcm5719-llvm-5b4acbd6b6bceaa3ea25b237168b434a24e1181d.tar.gz bcm5719-llvm-5b4acbd6b6bceaa3ea25b237168b434a24e1181d.zip |
Re-indent the CMake refactor to two-space indention
I apologize for this nasty commit, but I somehow overlooked Chandler's
comment to re-indent these files to two space indention. I know this
is a horrible commit, but I figured if it was done quickly after the
first one, not too many conflicts would arise.
Again, I'm sorry and won't do this again.
llvm-svn: 242301
Diffstat (limited to 'openmp/runtime/cmake')
-rw-r--r-- | openmp/runtime/cmake/LibompCheckFortranFlag.cmake | 86 | ||||
-rw-r--r-- | openmp/runtime/cmake/LibompCheckLinkerFlag.cmake | 90 | ||||
-rw-r--r-- | openmp/runtime/cmake/LibompDefinitions.cmake | 160 | ||||
-rw-r--r-- | openmp/runtime/cmake/LibompExports.cmake | 70 | ||||
-rw-r--r-- | openmp/runtime/cmake/LibompGetArchitecture.cmake | 57 | ||||
-rw-r--r-- | openmp/runtime/cmake/LibompHandleFlags.cmake | 316 | ||||
-rw-r--r-- | openmp/runtime/cmake/LibompMicroTests.cmake | 292 | ||||
-rw-r--r-- | openmp/runtime/cmake/LibompUtils.cmake | 188 | ||||
-rw-r--r-- | openmp/runtime/cmake/config-ix.cmake | 168 |
9 files changed, 713 insertions, 714 deletions
diff --git a/openmp/runtime/cmake/LibompCheckFortranFlag.cmake b/openmp/runtime/cmake/LibompCheckFortranFlag.cmake index e0913bf5a5e..c37b3ad24a1 100644 --- a/openmp/runtime/cmake/LibompCheckFortranFlag.cmake +++ b/openmp/runtime/cmake/LibompCheckFortranFlag.cmake @@ -20,54 +20,54 @@ function(libomp_check_fortran_flag flag boolean) print *, \"Hello World!\" end program hello") - set(failed_regexes "[Ee]rror;[Uu]nknown;[Ss]kipping") - if(CMAKE_VERSION VERSION_GREATER 3.1 OR CMAKE_VERSION VERSION_EQUAL 3.1) - include(CheckFortranSourceCompiles) - check_fortran_source_compiles("${fortran_source}" ${boolean} FAIL_REGEX "${failed_regexes}") - set(${boolean} ${${boolean}} PARENT_SCOPE) - return() - else() - # Our manual check for cmake versions that don't have CheckFortranSourceCompiles - set(base_dir ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/fortran_flag_check) - file(MAKE_DIRECTORY ${base_dir}) - file(WRITE ${base_dir}/fortran_source.f "${fortran_source}") + set(failed_regexes "[Ee]rror;[Uu]nknown;[Ss]kipping") + if(CMAKE_VERSION VERSION_GREATER 3.1 OR CMAKE_VERSION VERSION_EQUAL 3.1) + include(CheckFortranSourceCompiles) + check_fortran_source_compiles("${fortran_source}" ${boolean} FAIL_REGEX "${failed_regexes}") + set(${boolean} ${${boolean}} PARENT_SCOPE) + return() + else() + # Our manual check for cmake versions that don't have CheckFortranSourceCompiles + set(base_dir ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/fortran_flag_check) + file(MAKE_DIRECTORY ${base_dir}) + file(WRITE ${base_dir}/fortran_source.f "${fortran_source}") - message(STATUS "Performing Test ${boolean}") - execute_process( - COMMAND ${CMAKE_Fortran_COMPILER} "${flag}" ${base_dir}/fortran_source.f - WORKING_DIRECTORY ${base_dir} - RESULT_VARIABLE exit_code - OUTPUT_VARIABLE OUTPUT - ERROR_VARIABLE OUTPUT - ) + message(STATUS "Performing Test ${boolean}") + execute_process( + COMMAND ${CMAKE_Fortran_COMPILER} "${flag}" ${base_dir}/fortran_source.f + WORKING_DIRECTORY ${base_dir} + RESULT_VARIABLE exit_code + OUTPUT_VARIABLE OUTPUT + ERROR_VARIABLE OUTPUT + ) - if(${exit_code} EQUAL 0) - foreach(regex IN LISTS failed_regexes) - if("${OUTPUT}" MATCHES ${regex}) - set(retval FALSE) - endif() - endforeach() - else() - set(retval FALSE) + if(${exit_code} EQUAL 0) + foreach(regex IN LISTS failed_regexes) + if("${OUTPUT}" MATCHES ${regex}) + set(retval FALSE) endif() + endforeach() + else() + set(retval FALSE) + endif() - if(${retval}) - set(${boolean} 1 CACHE INTERNAL "Test ${boolean}") - message(STATUS "Performing Test ${boolean} - Success") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Performing Fortran Compiler Flag test ${boolean} succeeded with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${fortran_source}\n") - else() - set(${boolean} "" CACHE INTERNAL "Test ${boolean}") - message(STATUS "Performing Test ${boolean} - Failed") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Performing Fortran Compiler Flag test ${boolean} failed with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${fortran_source}\n") - endif() + if(${retval}) + set(${boolean} 1 CACHE INTERNAL "Test ${boolean}") + message(STATUS "Performing Test ${boolean} - Success") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Performing Fortran Compiler Flag test ${boolean} succeeded with the following output:\n" + "${OUTPUT}\n" + "Source file was:\n${fortran_source}\n") + else() + set(${boolean} "" CACHE INTERNAL "Test ${boolean}") + message(STATUS "Performing Test ${boolean} - Failed") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing Fortran Compiler Flag test ${boolean} failed with the following output:\n" + "${OUTPUT}\n" + "Source file was:\n${fortran_source}\n") endif() + endif() - set(${boolean} ${retval} PARENT_SCOPE) + set(${boolean} ${retval} PARENT_SCOPE) endif() endfunction() diff --git a/openmp/runtime/cmake/LibompCheckLinkerFlag.cmake b/openmp/runtime/cmake/LibompCheckLinkerFlag.cmake index c5a38367f5f..1c4a085d101 100644 --- a/openmp/runtime/cmake/LibompCheckLinkerFlag.cmake +++ b/openmp/runtime/cmake/LibompCheckLinkerFlag.cmake @@ -14,55 +14,55 @@ # this will have ${boolean} = TRUE if the flag succeeds, otherwise FALSE. function(libomp_check_linker_flag flag boolean) if(NOT DEFINED "${boolean}") - set(retval TRUE) - set(library_source - "int foo(int a) { return a*a; }") - set(cmake_source - "cmake_minimum_required(VERSION 2.8) - project(foo C) - set(CMAKE_SHARED_LINKER_FLAGS \"${flag}\") - add_library(foo SHARED src_to_link.c)") - set(failed_regexes "[Ee]rror;[Uu]nknown;[Ss]kipping;LINK : warning") - set(base_dir ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/link_flag_check) - file(MAKE_DIRECTORY ${base_dir}) - file(MAKE_DIRECTORY ${base_dir}/build) - file(WRITE ${base_dir}/src_to_link.c "${library_source}") - file(WRITE ${base_dir}/CMakeLists.txt "${cmake_source}") + set(retval TRUE) + set(library_source + "int foo(int a) { return a*a; }") + set(cmake_source + "cmake_minimum_required(VERSION 2.8) + project(foo C) + set(CMAKE_SHARED_LINKER_FLAGS \"${flag}\") + add_library(foo SHARED src_to_link.c)") + set(failed_regexes "[Ee]rror;[Uu]nknown;[Ss]kipping;LINK : warning") + set(base_dir ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/link_flag_check) + file(MAKE_DIRECTORY ${base_dir}) + file(MAKE_DIRECTORY ${base_dir}/build) + file(WRITE ${base_dir}/src_to_link.c "${library_source}") + file(WRITE ${base_dir}/CMakeLists.txt "${cmake_source}") - message(STATUS "Performing Test ${boolean}") - try_compile( - try_compile_result - ${base_dir}/build - ${base_dir} - foo - OUTPUT_VARIABLE OUTPUT) + message(STATUS "Performing Test ${boolean}") + try_compile( + try_compile_result + ${base_dir}/build + ${base_dir} + foo + OUTPUT_VARIABLE OUTPUT) - if(try_compile_result) - foreach(regex IN LISTS failed_regexes) - if("${OUTPUT}" MATCHES ${regex}) - set(retval FALSE) - endif() - endforeach() - else() + if(try_compile_result) + foreach(regex IN LISTS failed_regexes) + if("${OUTPUT}" MATCHES ${regex}) set(retval FALSE) - endif() + endif() + endforeach() + else() + set(retval FALSE) + endif() - if(${retval}) - set(${boolean} 1 CACHE INTERNAL "Test ${boolean}") - message(STATUS "Performing Test ${boolean} - Success") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Performing C Linker Flag test ${boolean} succeeded with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${library_source}\n") - else() - set(${boolean} "" CACHE INTERNAL "Test ${boolean}") - message(STATUS "Performing Test ${boolean} - Failed") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Performing C Linker Flag test ${boolean} failed with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${library_source}\n") - endif() + if(${retval}) + set(${boolean} 1 CACHE INTERNAL "Test ${boolean}") + message(STATUS "Performing Test ${boolean} - Success") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Performing C Linker Flag test ${boolean} succeeded with the following output:\n" + "${OUTPUT}\n" + "Source file was:\n${library_source}\n") + else() + set(${boolean} "" CACHE INTERNAL "Test ${boolean}") + message(STATUS "Performing Test ${boolean} - Failed") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing C Linker Flag test ${boolean} failed with the following output:\n" + "${OUTPUT}\n" + "Source file was:\n${library_source}\n") + endif() - set(${boolean} ${retval} PARENT_SCOPE) + set(${boolean} ${retval} PARENT_SCOPE) endif() endfunction() diff --git a/openmp/runtime/cmake/LibompDefinitions.cmake b/openmp/runtime/cmake/LibompDefinitions.cmake index 5663340e2f1..667110ead56 100644 --- a/openmp/runtime/cmake/LibompDefinitions.cmake +++ b/openmp/runtime/cmake/LibompDefinitions.cmake @@ -10,91 +10,91 @@ # function(libomp_get_definitions_flags cppflags) - set(cppflags_local) - libomp_append(cppflags_local "-D USE_ITT_BUILD") - # yes... you need 5 backslashes... - libomp_append(cppflags_local "-D KMP_ARCH_STR=\"\\\\\"${LIBOMP_LEGAL_ARCH}\\\\\"\"") - libomp_append(cppflags_local "-D BUILD_I8") - libomp_append(cppflags_local "-D KMP_LIBRARY_FILE=\\\\\"${LIBOMP_LIB_FILE}\\\\\"") - libomp_append(cppflags_local "-D KMP_VERSION_MAJOR=${LIBOMP_VERSION}") - libomp_append(cppflags_local "-D KMP_NESTED_HOT_TEAMS") + set(cppflags_local) + libomp_append(cppflags_local "-D USE_ITT_BUILD") + # yes... you need 5 backslashes... + libomp_append(cppflags_local "-D KMP_ARCH_STR=\"\\\\\"${LIBOMP_LEGAL_ARCH}\\\\\"\"") + libomp_append(cppflags_local "-D BUILD_I8") + libomp_append(cppflags_local "-D KMP_LIBRARY_FILE=\\\\\"${LIBOMP_LIB_FILE}\\\\\"") + libomp_append(cppflags_local "-D KMP_VERSION_MAJOR=${LIBOMP_VERSION}") + libomp_append(cppflags_local "-D KMP_NESTED_HOT_TEAMS") - # customize to 128 bytes for ppc64 - if(${PPC64}) - libomp_append(cppflags_local "-D CACHE_LINE=128") - else() - libomp_append(cppflags_local "-D CACHE_LINE=64") - endif() + # customize to 128 bytes for ppc64 + if(${PPC64}) + libomp_append(cppflags_local "-D CACHE_LINE=128") + else() + libomp_append(cppflags_local "-D CACHE_LINE=64") + endif() - libomp_append(cppflags_local "-D KMP_ADJUST_BLOCKTIME=1") - libomp_append(cppflags_local "-D BUILD_PARALLEL_ORDERED") - libomp_append(cppflags_local "-D KMP_ASM_INTRINS") - libomp_append(cppflags_local "-D USE_ITT_NOTIFY" IF_TRUE_1_0 LIBOMP_USE_ITT_NOTIFY) - libomp_append(cppflags_local "-D INTEL_NO_ITTNOTIFY_API" IF_FALSE LIBOMP_USE_ITT_NOTIFY) - libomp_append(cppflags_local "-D INTEL_ITTNOTIFY_PREFIX=__kmp_itt_") - libomp_append(cppflags_local "-D KMP_USE_VERSION_SYMBOLS" IF_TRUE LIBOMP_USE_VERSION_SYMBOLS) + libomp_append(cppflags_local "-D KMP_ADJUST_BLOCKTIME=1") + libomp_append(cppflags_local "-D BUILD_PARALLEL_ORDERED") + libomp_append(cppflags_local "-D KMP_ASM_INTRINS") + libomp_append(cppflags_local "-D USE_ITT_NOTIFY" IF_TRUE_1_0 LIBOMP_USE_ITT_NOTIFY) + libomp_append(cppflags_local "-D INTEL_NO_ITTNOTIFY_API" IF_FALSE LIBOMP_USE_ITT_NOTIFY) + libomp_append(cppflags_local "-D INTEL_ITTNOTIFY_PREFIX=__kmp_itt_") + libomp_append(cppflags_local "-D KMP_USE_VERSION_SYMBOLS" IF_TRUE LIBOMP_USE_VERSION_SYMBOLS) - if(WIN32) - libomp_append(cppflags_local "-D _CRT_SECURE_NO_WARNINGS") - libomp_append(cppflags_local "-D _CRT_SECURE_NO_DEPRECATE") - libomp_append(cppflags_local "-D _WINDOWS") - libomp_append(cppflags_local "-D _WINNT") - libomp_append(cppflags_local "-D _WIN32_WINNT=0x0501") - libomp_append(cppflags_local "-D KMP_WIN_CDECL") - libomp_append(cppflags_local "-D _USRDLL") - libomp_append(cppflags_local "-D _ITERATOR_DEBUG_LEVEL=0" IF_TRUE DEBUG_BUILD) - else() - libomp_append(cppflags_local "-D _GNU_SOURCE") - libomp_append(cppflags_local "-D _REENTRANT") - libomp_append(cppflags_local "-D BUILD_TV") - libomp_append(cppflags_local "-D USE_CBLKDATA") - libomp_append(cppflags_local "-D KMP_GOMP_COMPAT") - endif() + if(WIN32) + libomp_append(cppflags_local "-D _CRT_SECURE_NO_WARNINGS") + libomp_append(cppflags_local "-D _CRT_SECURE_NO_DEPRECATE") + libomp_append(cppflags_local "-D _WINDOWS") + libomp_append(cppflags_local "-D _WINNT") + libomp_append(cppflags_local "-D _WIN32_WINNT=0x0501") + libomp_append(cppflags_local "-D KMP_WIN_CDECL") + libomp_append(cppflags_local "-D _USRDLL") + libomp_append(cppflags_local "-D _ITERATOR_DEBUG_LEVEL=0" IF_TRUE DEBUG_BUILD) + else() + libomp_append(cppflags_local "-D _GNU_SOURCE") + libomp_append(cppflags_local "-D _REENTRANT") + libomp_append(cppflags_local "-D BUILD_TV") + libomp_append(cppflags_local "-D USE_CBLKDATA") + libomp_append(cppflags_local "-D KMP_GOMP_COMPAT") + endif() - libomp_append(cppflags_local "-D USE_LOAD_BALANCE" IF_FALSE MIC) - if(NOT WIN32 AND NOT APPLE) - libomp_append(cppflags_local "-D KMP_TDATA_GTID") - endif() - libomp_append(cppflags_local "-D KMP_USE_ASSERT" IF_TRUE LIBOMP_ENABLE_ASSERTIONS) - libomp_append(cppflags_local "-D KMP_DYNAMIC_LIB") - libomp_append(cppflags_local "-D KMP_STUB" IF_TRUE STUBS_LIBRARY) + libomp_append(cppflags_local "-D USE_LOAD_BALANCE" IF_FALSE MIC) + if(NOT WIN32 AND NOT APPLE) + libomp_append(cppflags_local "-D KMP_TDATA_GTID") + endif() + libomp_append(cppflags_local "-D KMP_USE_ASSERT" IF_TRUE LIBOMP_ENABLE_ASSERTIONS) + libomp_append(cppflags_local "-D KMP_DYNAMIC_LIB") + libomp_append(cppflags_local "-D KMP_STUB" IF_TRUE STUBS_LIBRARY) - if(${DEBUG_BUILD} OR ${RELWITHDEBINFO_BUILD}) - libomp_append(cppflags_local "-D KMP_DEBUG") - endif() - libomp_append(cppflags_local "-D _DEBUG" IF_TRUE DEBUG_BUILD) - libomp_append(cppflags_local "-D BUILD_DEBUG" IF_TRUE DEBUG_BUILD) - libomp_append(cppflags_local "-D KMP_STATS_ENABLED" IF_TRUE_1_0 LIBOMP_STATS) - libomp_append(cppflags_local "-D USE_DEBUGGER" IF_TRUE_1_0 LIBOMP_USE_DEBUGGER) - libomp_append(cppflags_local "-D OMPT_SUPPORT" IF_TRUE_1_0 LIBOMP_OMPT_SUPPORT) - libomp_append(cppflags_local "-D OMPT_BLAME" IF_TRUE_1_0 LIBOMP_OMPT_BLAME) - libomp_append(cppflags_local "-D OMPT_TRACE" IF_TRUE_1_0 LIBOMP_OMPT_TRACE) + if(${DEBUG_BUILD} OR ${RELWITHDEBINFO_BUILD}) + libomp_append(cppflags_local "-D KMP_DEBUG") + endif() + libomp_append(cppflags_local "-D _DEBUG" IF_TRUE DEBUG_BUILD) + libomp_append(cppflags_local "-D BUILD_DEBUG" IF_TRUE DEBUG_BUILD) + libomp_append(cppflags_local "-D KMP_STATS_ENABLED" IF_TRUE_1_0 LIBOMP_STATS) + libomp_append(cppflags_local "-D USE_DEBUGGER" IF_TRUE_1_0 LIBOMP_USE_DEBUGGER) + libomp_append(cppflags_local "-D OMPT_SUPPORT" IF_TRUE_1_0 LIBOMP_OMPT_SUPPORT) + libomp_append(cppflags_local "-D OMPT_BLAME" IF_TRUE_1_0 LIBOMP_OMPT_BLAME) + libomp_append(cppflags_local "-D OMPT_TRACE" IF_TRUE_1_0 LIBOMP_OMPT_TRACE) - # OpenMP version flags - set(libomp_have_omp_50 0) - set(libomp_have_omp_41 0) - set(libomp_have_omp_40 0) - set(libomp_have_omp_30 0) - if(${LIBOMP_OMP_VERSION} EQUAL 50 OR ${LIBOMP_OMP_VERSION} GREATER 50) - set(libomp_have_omp_50 1) - endif() - if(${LIBOMP_OMP_VERSION} EQUAL 41 OR ${LIBOMP_OMP_VERSION} GREATER 41) - set(libomp_have_omp_41 1) - endif() - if(${LIBOMP_OMP_VERSION} EQUAL 40 OR ${LIBOMP_OMP_VERSION} GREATER 40) - set(libomp_have_omp_40 1) - endif() - if(${LIBOMP_OMP_VERSION} EQUAL 30 OR ${LIBOMP_OMP_VERSION} GREATER 30) - set(libomp_have_omp_30 1) - endif() - libomp_append(cppflags_local "-D OMP_50_ENABLED=${libomp_have_omp_50}") - libomp_append(cppflags_local "-D OMP_41_ENABLED=${libomp_have_omp_41}") - libomp_append(cppflags_local "-D OMP_40_ENABLED=${libomp_have_omp_40}") - libomp_append(cppflags_local "-D OMP_30_ENABLED=${libomp_have_omp_30}") - libomp_append(cppflags_local "-D KMP_USE_ADAPTIVE_LOCKS" IF_TRUE_1_0 LIBOMP_USE_ADAPTIVE_LOCKS) - libomp_append(cppflags_local "-D KMP_DEBUG_ADAPTIVE_LOCKS=0") - libomp_append(cppflags_local "-D KMP_USE_INTERNODE_ALIGNMENT" IF_TRUE_1_0 LIBOMP_USE_INTERNODE_ALIGNMENT) - # CMake doesn't include CPPFLAGS from environment, but we will. - set(${cppflags} ${cppflags_local} ${LIBOMP_CPPFLAGS} $ENV{CPPFLAGS} PARENT_SCOPE) + # OpenMP version flags + set(libomp_have_omp_50 0) + set(libomp_have_omp_41 0) + set(libomp_have_omp_40 0) + set(libomp_have_omp_30 0) + if(${LIBOMP_OMP_VERSION} EQUAL 50 OR ${LIBOMP_OMP_VERSION} GREATER 50) + set(libomp_have_omp_50 1) + endif() + if(${LIBOMP_OMP_VERSION} EQUAL 41 OR ${LIBOMP_OMP_VERSION} GREATER 41) + set(libomp_have_omp_41 1) + endif() + if(${LIBOMP_OMP_VERSION} EQUAL 40 OR ${LIBOMP_OMP_VERSION} GREATER 40) + set(libomp_have_omp_40 1) + endif() + if(${LIBOMP_OMP_VERSION} EQUAL 30 OR ${LIBOMP_OMP_VERSION} GREATER 30) + set(libomp_have_omp_30 1) + endif() + libomp_append(cppflags_local "-D OMP_50_ENABLED=${libomp_have_omp_50}") + libomp_append(cppflags_local "-D OMP_41_ENABLED=${libomp_have_omp_41}") + libomp_append(cppflags_local "-D OMP_40_ENABLED=${libomp_have_omp_40}") + libomp_append(cppflags_local "-D OMP_30_ENABLED=${libomp_have_omp_30}") + libomp_append(cppflags_local "-D KMP_USE_ADAPTIVE_LOCKS" IF_TRUE_1_0 LIBOMP_USE_ADAPTIVE_LOCKS) + libomp_append(cppflags_local "-D KMP_DEBUG_ADAPTIVE_LOCKS=0") + libomp_append(cppflags_local "-D KMP_USE_INTERNODE_ALIGNMENT" IF_TRUE_1_0 LIBOMP_USE_INTERNODE_ALIGNMENT) + # CMake doesn't include CPPFLAGS from environment, but we will. + set(${cppflags} ${cppflags_local} ${LIBOMP_CPPFLAGS} $ENV{CPPFLAGS} PARENT_SCOPE) endfunction() diff --git a/openmp/runtime/cmake/LibompExports.cmake b/openmp/runtime/cmake/LibompExports.cmake index 3a4191a6e8c..16fcb20ca71 100644 --- a/openmp/runtime/cmake/LibompExports.cmake +++ b/openmp/runtime/cmake/LibompExports.cmake @@ -22,27 +22,27 @@ libomp_append(libomp_suffix .deb DEBUG_BUILD) libomp_append(libomp_suffix .dia RELWITHDEBINFO_BUILD) libomp_append(libomp_suffix .min MINSIZEREL_BUILD) if(NOT "${LIBOMP_OMP_VERSION}" STREQUAL "41") - libomp_append(libomp_suffix .${LIBOMP_OMP_VERSION}) + libomp_append(libomp_suffix .${LIBOMP_OMP_VERSION}) endif() libomp_append(libomp_suffix .s1 LIBOMP_STATS) libomp_append(libomp_suffix .ompt LIBOMP_OMPT_SUPPORT) if(${LIBOMP_OMPT_SUPPORT}) - libomp_append(libomp_suffix .no-ompt-blame IF_FALSE LIBOMP_OMPT_BLAME) - libomp_append(libomp_suffix .no-ompt-trace IF_FALSE LIBOMP_OMPT_TRACE) + libomp_append(libomp_suffix .no-ompt-blame IF_FALSE LIBOMP_OMPT_BLAME) + libomp_append(libomp_suffix .no-ompt-trace IF_FALSE LIBOMP_OMPT_TRACE) endif() string(REPLACE ";" "" libomp_suffix "${libomp_suffix}") # Set exports locations if(${MIC}) - set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_${LIBOMP_MIC_ARCH}") # e.g., lin_knf, lin_knc + set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_${LIBOMP_MIC_ARCH}") # e.g., lin_knf, lin_knc else() - if(${IA32}) - set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_32") - elseif(${INTEL64}) - set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_32e") - else() - set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_${LIBOMP_ARCH}") # e.g., lin_arm, lin_ppc64 - endif() + if(${IA32}) + set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_32") + elseif(${INTEL64}) + set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_32e") + else() + set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_${LIBOMP_ARCH}") # e.g., lin_arm, lin_ppc64 + endif() endif() set(LIBOMP_EXPORTS_DIR "${LIBOMP_BASE_DIR}/exports") set(LIBOMP_EXPORTS_PLATFORM_DIR "${LIBOMP_EXPORTS_DIR}/${libomp_platform}${libomp_suffix}") @@ -53,46 +53,46 @@ set(LIBOMP_EXPORTS_LIB_DIR "${LIBOMP_EXPORTS_DIR}/${libomp_platform}${libomp_suf # Put headers in exports/ directory post build add_custom_command(TARGET omp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_CMN_DIR} - COMMAND ${CMAKE_COMMAND} -E copy omp.h ${LIBOMP_EXPORTS_CMN_DIR} + COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_CMN_DIR} + COMMAND ${CMAKE_COMMAND} -E copy omp.h ${LIBOMP_EXPORTS_CMN_DIR} ) if(${LIBOMP_OMPT_SUPPORT}) - add_custom_command(TARGET omp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ompt.h ${LIBOMP_EXPORTS_CMN_DIR} - ) + add_custom_command(TARGET omp POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ompt.h ${LIBOMP_EXPORTS_CMN_DIR} + ) endif() if(${LIBOMP_FORTRAN_MODULES}) - add_custom_command(TARGET libomp-mod POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_MOD_DIR} - COMMAND ${CMAKE_COMMAND} -E copy omp_lib.h ${LIBOMP_EXPORTS_CMN_DIR} - COMMAND ${CMAKE_COMMAND} -E copy omp_lib.mod ${LIBOMP_EXPORTS_MOD_DIR} - COMMAND ${CMAKE_COMMAND} -E copy omp_lib_kinds.mod ${LIBOMP_EXPORTS_MOD_DIR} - ) + add_custom_command(TARGET libomp-mod POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_MOD_DIR} + COMMAND ${CMAKE_COMMAND} -E copy omp_lib.h ${LIBOMP_EXPORTS_CMN_DIR} + COMMAND ${CMAKE_COMMAND} -E copy omp_lib.mod ${LIBOMP_EXPORTS_MOD_DIR} + COMMAND ${CMAKE_COMMAND} -E copy omp_lib_kinds.mod ${LIBOMP_EXPORTS_MOD_DIR} + ) endif() # Copy OpenMP library into exports/ directory post build if(WIN32) - get_target_property(LIBOMP_OUTPUT_DIRECTORY omp RUNTIME_OUTPUT_DIRECTORY) + get_target_property(LIBOMP_OUTPUT_DIRECTORY omp RUNTIME_OUTPUT_DIRECTORY) else() - get_target_property(LIBOMP_OUTPUT_DIRECTORY omp LIBRARY_OUTPUT_DIRECTORY) + get_target_property(LIBOMP_OUTPUT_DIRECTORY omp LIBRARY_OUTPUT_DIRECTORY) endif() if(NOT LIBOMP_OUTPUT_DIRECTORY) - set(LIBOMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set(LIBOMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif() add_custom_command(TARGET omp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_LIB_DIR} - COMMAND ${CMAKE_COMMAND} -E copy ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} ${LIBOMP_EXPORTS_LIB_DIR} + COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_LIB_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} ${LIBOMP_EXPORTS_LIB_DIR} ) # Copy Windows import library into exports/ directory post build if(WIN32) - get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY ompimp ARCHIVE_OUTPUT_DIRECTORY) - if(NOT LIBOMPIMP_OUTPUT_DIRECTORY) - set(LIBOMPIMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - endif() - add_custom_command(TARGET ompimp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_LIB_DIR} - COMMAND ${CMAKE_COMMAND} -E copy ${LIBOMPIMP_OUTPUT_DIRECTORY}/${LIBOMP_IMP_LIB_FILE} ${LIBOMP_EXPORTS_LIB_DIR} - ) + get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY ompimp ARCHIVE_OUTPUT_DIRECTORY) + if(NOT LIBOMPIMP_OUTPUT_DIRECTORY) + set(LIBOMPIMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() + add_custom_command(TARGET ompimp POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_LIB_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${LIBOMPIMP_OUTPUT_DIRECTORY}/${LIBOMP_IMP_LIB_FILE} ${LIBOMP_EXPORTS_LIB_DIR} + ) endif() diff --git a/openmp/runtime/cmake/LibompGetArchitecture.cmake b/openmp/runtime/cmake/LibompGetArchitecture.cmake index 1773330de4c..8f3c4c6565d 100644 --- a/openmp/runtime/cmake/LibompGetArchitecture.cmake +++ b/openmp/runtime/cmake/LibompGetArchitecture.cmake @@ -15,53 +15,52 @@ # void get_architecture(string* return_arch) # - Returns the architecture in return_arch function(libomp_get_architecture return_arch) - set(detect_arch_src_txt " + set(detect_arch_src_txt " #if defined(__KNC__) - #error ARCHITECTURE=mic + #error ARCHITECTURE=mic #elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) - #error ARCHITECTURE=x86_64 + #error ARCHITECTURE=x86_64 #elif defined(__i386) || defined(__i386__) || defined(__IA32__) || defined(_M_I86) || defined(_M_IX86) || defined(__X86__) || defined(_X86_) - #error ARCHITECTURE=i386 + #error ARCHITECTURE=i386 #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) - #error ARCHITECTURE=arm + #error ARCHITECTURE=arm #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6ZK__) - #error ARCHITECTURE=arm + #error ARCHITECTURE=arm #elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__) - #error ARCHITECTURE=arm + #error ARCHITECTURE=arm #elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) - #error ARCHITECTURE=arm + #error ARCHITECTURE=arm #elif defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__) - #error ARCHITECTURE=arm + #error ARCHITECTURE=arm #elif defined(__ARM_ARCH_2__) - #error ARCHITECTURE=arm + #error ARCHITECTURE=arm #elif defined(__arm__) || defined(_M_ARM) || defined(_ARM) - #error ARCHITECTURE=arm + #error ARCHITECTURE=arm #elif defined(__aarch64__) - #error ARCHITECTURE=aarch64 + #error ARCHITECTURE=aarch64 #elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) - #error ARCHITECTURE=ppc64le + #error ARCHITECTURE=ppc64le #elif defined(__powerpc64__) - #error ARCHITECTURE=ppc64 + #error ARCHITECTURE=ppc64 #else - #error ARCHITECTURE=UnknownArchitecture + #error ARCHITECTURE=UnknownArchitecture #endif - " - ) - # Write out ${detect_arch_src_txt} to a file within the cmake/ subdirectory - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" ${detect_arch_src_txt}) + ") + # Write out ${detect_arch_src_txt} to a file within the cmake/ subdirectory + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" ${detect_arch_src_txt}) - # Try to compile using the C Compiler. It will always error out with an #error directive, so store error output to ${local_architecture} - try_run(run_dummy compile_dummy "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" COMPILE_OUTPUT_VARIABLE local_architecture) + # Try to compile using the C Compiler. It will always error out with an #error directive, so store error output to ${local_architecture} + try_run(run_dummy compile_dummy "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" COMPILE_OUTPUT_VARIABLE local_architecture) - # Match the important architecture line and store only that matching string in ${local_architecture} - string(REGEX MATCH "ARCHITECTURE=([a-zA-Z0-9_]+)" local_architecture "${local_architecture}") + # Match the important architecture line and store only that matching string in ${local_architecture} + string(REGEX MATCH "ARCHITECTURE=([a-zA-Z0-9_]+)" local_architecture "${local_architecture}") - # Get rid of the ARCHITECTURE= part of the string - string(REPLACE "ARCHITECTURE=" "" local_architecture "${local_architecture}") + # Get rid of the ARCHITECTURE= part of the string + string(REPLACE "ARCHITECTURE=" "" local_architecture "${local_architecture}") - # set the return value to the architecture detected (e.g., 32e, 32, arm, ppc64, etc.) - set(${return_arch} "${local_architecture}" PARENT_SCOPE) + # set the return value to the architecture detected (e.g., 32e, 32, arm, ppc64, etc.) + set(${return_arch} "${local_architecture}" PARENT_SCOPE) - # Remove ${detect_arch_src_txt} from cmake/ subdirectory - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c") + # Remove ${detect_arch_src_txt} from cmake/ subdirectory + file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c") endfunction() diff --git a/openmp/runtime/cmake/LibompHandleFlags.cmake b/openmp/runtime/cmake/LibompHandleFlags.cmake index 196c733d400..4e3d96efec7 100644 --- a/openmp/runtime/cmake/LibompHandleFlags.cmake +++ b/openmp/runtime/cmake/LibompHandleFlags.cmake @@ -13,201 +13,201 @@ # Pretty them up (STRIP any beginning and trailing whitespace, # remove duplicates, remove empty entries) macro(libomp_setup_flags flags) - if(NOT "${${flags}}" STREQUAL "") # if flags are empty, don't do anything - set(flags_local) - list(REMOVE_DUPLICATES ${flags}) # remove duplicates - list(REMOVE_ITEM ${flags} "") # remove empty items - libomp_list_to_string("${${flags}}" flags_local) - string(STRIP "${flags_local}" flags_local) - set(${flags} "${flags_local}") - endif() + if(NOT "${${flags}}" STREQUAL "") # if flags are empty, don't do anything + set(flags_local) + list(REMOVE_DUPLICATES ${flags}) # remove duplicates + list(REMOVE_ITEM ${flags} "") # remove empty items + libomp_list_to_string("${${flags}}" flags_local) + string(STRIP "${flags_local}" flags_local) + set(${flags} "${flags_local}") + endif() endmacro() # Gets flags common to both the C and C++ compiler function(libomp_get_c_and_cxxflags_common flags) - set(flags_local) - libomp_append(flags_local -std=c++11 LIBOMP_HAVE_STD_CPP11_FLAG) - libomp_append(flags_local -fno-exceptions LIBOMP_HAVE_FNO_EXCEPTIONS_FLAG) - libomp_append(flags_local -Wsign-compare LIBOMP_HAVE_WSIGN_COMPARE_FLAG) - libomp_append(flags_local -Wno-unused-value LIBOMP_HAVE_WNO_UNUSED_VALUE_FLAG) - libomp_append(flags_local -Wno-switch LIBOMP_HAVE_WNO_SWITCH_FLAG) - libomp_append(flags_local -Wno-deprecated-register LIBOMP_HAVE_WNO_DEPRECATED_REGISTER_FLAG) - libomp_append(flags_local /GS LIBOMP_HAVE_GS_FLAG) - libomp_append(flags_local /EHsc LIBOMP_HAVE_EHSC_FLAG) - libomp_append(flags_local /Oy- LIBOMP_HAVE_OY__FLAG) - # Intel(R) C Compiler flags - libomp_append(flags_local /Qsafeseh LIBOMP_HAVE_QSAFESEH_FLAG) - libomp_append(flags_local -Qoption,cpp,--extended_float_types LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG) - libomp_append(flags_local -Qlong_double LIBOMP_HAVE_LONG_DOUBLE_FLAG) - libomp_append(flags_local -Qdiag-disable:177 LIBOMP_HAVE_DIAG_DISABLE_177_FLAG) - if(${RELEASE_BUILD} OR ${RELWITHDEBINFO_BUILD}) - libomp_append(flags_local -Qinline-min-size=1 LIBOMP_HAVE_INLINE_MIN_SIZE_FLAG) - endif() - # Architectural C and C++ flags - if(${IA32}) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - libomp_append(flags_local -m32 LIBOMP_HAVE_M32_FLAG) - endif() - libomp_append(flags_local /arch:SSE2 LIBOMP_HAVE_ARCH_SSE2_FLAG) - libomp_append(flags_local -msse2 LIBOMP_HAVE_MSSE2_FLAG) - libomp_append(flags_local -falign-stack=maintain-16-byte LIBOMP_HAVE_FALIGN_STACK_FLAG) - elseif(${MIC}) - libomp_append(flags_local -mmic LIBOMP_HAVE_MMIC_FLAG) - libomp_append(flags_local -ftls-model=initial-exec LIBOMP_HAVE_FTLS_MODEL_FLAG) - libomp_append(flags_local "-opt-streaming-stores never" LIBOMP_HAVE_OPT_STREAMING_STORES_FLAG) + set(flags_local) + libomp_append(flags_local -std=c++11 LIBOMP_HAVE_STD_CPP11_FLAG) + libomp_append(flags_local -fno-exceptions LIBOMP_HAVE_FNO_EXCEPTIONS_FLAG) + libomp_append(flags_local -Wsign-compare LIBOMP_HAVE_WSIGN_COMPARE_FLAG) + libomp_append(flags_local -Wno-unused-value LIBOMP_HAVE_WNO_UNUSED_VALUE_FLAG) + libomp_append(flags_local -Wno-switch LIBOMP_HAVE_WNO_SWITCH_FLAG) + libomp_append(flags_local -Wno-deprecated-register LIBOMP_HAVE_WNO_DEPRECATED_REGISTER_FLAG) + libomp_append(flags_local /GS LIBOMP_HAVE_GS_FLAG) + libomp_append(flags_local /EHsc LIBOMP_HAVE_EHSC_FLAG) + libomp_append(flags_local /Oy- LIBOMP_HAVE_OY__FLAG) + # Intel(R) C Compiler flags + libomp_append(flags_local /Qsafeseh LIBOMP_HAVE_QSAFESEH_FLAG) + libomp_append(flags_local -Qoption,cpp,--extended_float_types LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG) + libomp_append(flags_local -Qlong_double LIBOMP_HAVE_LONG_DOUBLE_FLAG) + libomp_append(flags_local -Qdiag-disable:177 LIBOMP_HAVE_DIAG_DISABLE_177_FLAG) + if(${RELEASE_BUILD} OR ${RELWITHDEBINFO_BUILD}) + libomp_append(flags_local -Qinline-min-size=1 LIBOMP_HAVE_INLINE_MIN_SIZE_FLAG) + endif() + # Architectural C and C++ flags + if(${IA32}) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + libomp_append(flags_local -m32 LIBOMP_HAVE_M32_FLAG) endif() - set(${flags} ${flags_local} PARENT_SCOPE) + libomp_append(flags_local /arch:SSE2 LIBOMP_HAVE_ARCH_SSE2_FLAG) + libomp_append(flags_local -msse2 LIBOMP_HAVE_MSSE2_FLAG) + libomp_append(flags_local -falign-stack=maintain-16-byte LIBOMP_HAVE_FALIGN_STACK_FLAG) + elseif(${MIC}) + libomp_append(flags_local -mmic LIBOMP_HAVE_MMIC_FLAG) + libomp_append(flags_local -ftls-model=initial-exec LIBOMP_HAVE_FTLS_MODEL_FLAG) + libomp_append(flags_local "-opt-streaming-stores never" LIBOMP_HAVE_OPT_STREAMING_STORES_FLAG) + endif() + set(${flags} ${flags_local} PARENT_SCOPE) endfunction() # C compiler flags function(libomp_get_cflags cflags) - set(cflags_local) - libomp_get_c_and_cxxflags_common(cflags_local) - # flags only for the C Compiler - libomp_append(cflags_local /TP LIBOMP_HAVE_TP_FLAG) - libomp_append(cflags_local "-x c++" LIBOMP_HAVE_X_CPP_FLAG) - set(cflags_local ${cflags_local} ${LIBOMP_CFLAGS}) - libomp_setup_flags(cflags_local) - set(${cflags} ${cflags_local} PARENT_SCOPE) + set(cflags_local) + libomp_get_c_and_cxxflags_common(cflags_local) + # flags only for the C Compiler + libomp_append(cflags_local /TP LIBOMP_HAVE_TP_FLAG) + libomp_append(cflags_local "-x c++" LIBOMP_HAVE_X_CPP_FLAG) + set(cflags_local ${cflags_local} ${LIBOMP_CFLAGS}) + libomp_setup_flags(cflags_local) + set(${cflags} ${cflags_local} PARENT_SCOPE) endfunction() # C++ compiler flags function(libomp_get_cxxflags cxxflags) - set(cxxflags_local) - libomp_get_c_and_cxxflags_common(cxxflags_local) - set(cxxflags_local ${cxxflags_local} ${LIBOMP_CXXFLAGS}) - libomp_setup_flags(cxxflags_local) - set(${cxxflags} ${cxxflags_local} PARENT_SCOPE) + set(cxxflags_local) + libomp_get_c_and_cxxflags_common(cxxflags_local) + set(cxxflags_local ${cxxflags_local} ${LIBOMP_CXXFLAGS}) + libomp_setup_flags(cxxflags_local) + set(${cxxflags} ${cxxflags_local} PARENT_SCOPE) endfunction() # Assembler flags function(libomp_get_asmflags asmflags) - set(asmflags_local) - libomp_append(asmflags_local "-x assembler-with-cpp" LIBOMP_HAVE_X_ASSEMBLER_WITH_CPP_FLAG) - # Architectural assembler flags - if(${IA32}) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - libomp_append(asmflags_local -m32 LIBOMP_HAVE_M32_FLAG) - endif() - libomp_append(asmflags_local /safeseh LIBOMP_HAVE_SAFESEH_MASM_FLAG) - libomp_append(asmflags_local /coff LIBOMP_HAVE_COFF_MASM_FLAG) - elseif(${MIC}) - libomp_append(asmflags_local -mmic LIBOMP_HAVE_MMIC_FLAG) + set(asmflags_local) + libomp_append(asmflags_local "-x assembler-with-cpp" LIBOMP_HAVE_X_ASSEMBLER_WITH_CPP_FLAG) + # Architectural assembler flags + if(${IA32}) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + libomp_append(asmflags_local -m32 LIBOMP_HAVE_M32_FLAG) endif() - set(asmflags_local ${asmflags_local} ${LIBOMP_ASMFLAGS}) - libomp_setup_flags(asmflags_local) - set(${asmflags} ${asmflags_local} PARENT_SCOPE) + libomp_append(asmflags_local /safeseh LIBOMP_HAVE_SAFESEH_MASM_FLAG) + libomp_append(asmflags_local /coff LIBOMP_HAVE_COFF_MASM_FLAG) + elseif(${MIC}) + libomp_append(asmflags_local -mmic LIBOMP_HAVE_MMIC_FLAG) + endif() + set(asmflags_local ${asmflags_local} ${LIBOMP_ASMFLAGS}) + libomp_setup_flags(asmflags_local) + set(${asmflags} ${asmflags_local} PARENT_SCOPE) endfunction() # Linker flags function(libomp_get_ldflags ldflags) - set(ldflags_local) - libomp_append(ldflags_local "${CMAKE_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_LIB_NAME}.def" - IF_DEFINED CMAKE_LINK_DEF_FILE_FLAG) - libomp_append(ldflags_local "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}${LIBOMP_VERSION}.0" - IF_DEFINED CMAKE_C_OSX_CURRENT_VERSION_FLAG) - libomp_append(ldflags_local "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}${LIBOMP_VERSION}.0" - IF_DEFINED CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG) - libomp_append(ldflags_local -Wl,--warn-shared-textrel LIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG) - libomp_append(ldflags_local -Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG) - libomp_append(ldflags_local "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG) - libomp_append(ldflags_local -static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG) - libomp_append(ldflags_local -Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG) - libomp_append(ldflags_local -Wl,-fini=__kmp_internal_end_fini LIBOMP_HAVE_FINI_FLAG) - libomp_append(ldflags_local -no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG) - libomp_append(ldflags_local -static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG) - libomp_append(ldflags_local /SAFESEH LIBOMP_HAVE_SAFESEH_FLAG) - # Architectural linker flags - if(${IA32}) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - libomp_append(ldflags_local -m32 LIBOMP_HAVE_M32_FLAG) - endif() - libomp_append(ldflags_local -msse2 LIBOMP_HAVE_MSSE2_FLAG) - elseif(${MIC}) - libomp_append(ldflags_local -mmic LIBOMP_HAVE_MMIC_FLAG) - libomp_append(ldflags_local -Wl,-x LIBOMP_HAVE_X_FLAG) + set(ldflags_local) + libomp_append(ldflags_local "${CMAKE_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_LIB_NAME}.def" + IF_DEFINED CMAKE_LINK_DEF_FILE_FLAG) + libomp_append(ldflags_local "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}${LIBOMP_VERSION}.0" + IF_DEFINED CMAKE_C_OSX_CURRENT_VERSION_FLAG) + libomp_append(ldflags_local "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}${LIBOMP_VERSION}.0" + IF_DEFINED CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG) + libomp_append(ldflags_local -Wl,--warn-shared-textrel LIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG) + libomp_append(ldflags_local -Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG) + libomp_append(ldflags_local "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG) + libomp_append(ldflags_local -static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG) + libomp_append(ldflags_local -Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG) + libomp_append(ldflags_local -Wl,-fini=__kmp_internal_end_fini LIBOMP_HAVE_FINI_FLAG) + libomp_append(ldflags_local -no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG) + libomp_append(ldflags_local -static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG) + libomp_append(ldflags_local /SAFESEH LIBOMP_HAVE_SAFESEH_FLAG) + # Architectural linker flags + if(${IA32}) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + libomp_append(ldflags_local -m32 LIBOMP_HAVE_M32_FLAG) endif() - set(ldflags_local ${ldflags_local} ${LIBOMP_LDFLAGS}) - libomp_setup_flags(ldflags_local) - set(${ldflags} ${ldflags_local} PARENT_SCOPE) + libomp_append(ldflags_local -msse2 LIBOMP_HAVE_MSSE2_FLAG) + elseif(${MIC}) + libomp_append(ldflags_local -mmic LIBOMP_HAVE_MMIC_FLAG) + libomp_append(ldflags_local -Wl,-x LIBOMP_HAVE_X_FLAG) + endif() + set(ldflags_local ${ldflags_local} ${LIBOMP_LDFLAGS}) + libomp_setup_flags(ldflags_local) + set(${ldflags} ${ldflags_local} PARENT_SCOPE) endfunction() # Library flags function(libomp_get_libflags libflags) - set(libflags_local) - libomp_append(libflags_local "${CMAKE_THREAD_LIBS_INIT}") - if(${IA32}) - libomp_append(libflags_local -lirc_pic LIBOMP_HAVE_IRC_PIC_LIBRARY) - endif() - set(libflags_local ${libflags_local} ${LIBOMP_LIBFLAGS}) - libomp_setup_flags(libflags_local) - set(${libflags} ${libflags_local} PARENT_SCOPE) + set(libflags_local) + libomp_append(libflags_local "${CMAKE_THREAD_LIBS_INIT}") + if(${IA32}) + libomp_append(libflags_local -lirc_pic LIBOMP_HAVE_IRC_PIC_LIBRARY) + endif() + set(libflags_local ${libflags_local} ${LIBOMP_LIBFLAGS}) + libomp_setup_flags(libflags_local) + set(${libflags} ${libflags_local} PARENT_SCOPE) endfunction() # Fortran flags function(libomp_get_fflags fflags) - set(fflags_local) - if(${IA32}) - libomp_append(fflags_local -m32 LIBOMP_HAVE_M32_FORTRAN_FLAG) - endif() - set(fflags_local ${fflags_local} ${LIBOMP_FFLAGS}) - libomp_setup_flags(fflags_local) - set(${fflags} ${fflags_local} PARENT_SCOPE) + set(fflags_local) + if(${IA32}) + libomp_append(fflags_local -m32 LIBOMP_HAVE_M32_FORTRAN_FLAG) + endif() + set(fflags_local ${fflags_local} ${LIBOMP_FFLAGS}) + libomp_setup_flags(fflags_local) + set(${fflags} ${fflags_local} PARENT_SCOPE) endfunction() # Perl expand-vars.pl flags function(libomp_get_evflags evflags) - set(evflags_local) - libomp_append(evflags_local "-D KMP_TYPE=\"${LIBOMP_LEGAL_TYPE}\"") - libomp_append(evflags_local "-D KMP_ARCH=\"${LIBOMP_LEGAL_ARCH}\"") - libomp_append(evflags_local "-D KMP_VERSION_MAJOR=${LIBOMP_VERSION}") - libomp_append(evflags_local "-D KMP_VERSION_MINOR=0") - libomp_append(evflags_local "-D KMP_VERSION_BUILD=${LIBOMP_BUILD_NUMBER}") - libomp_append(evflags_local "-D KMP_BUILD_DATE=\"${LIBOMP_DATE}\"") - if(${DEBUG_BUILD} OR ${RELWITHDEBINFO_BUILD}) - libomp_append(evflags_local "-D KMP_DIAG=1") - libomp_append(evflags_local "-D KMP_DEBUG_INFO=1") - else() - libomp_append(evflags_local "-D KMP_DIAG=0") - libomp_append(evflags_local "-D KMP_DEBUG_INFO=0") - endif() - if(${LIBOMP_OMP_VERSION} EQUAL 40 OR ${LIBOMP_OMP_VERSION} GREATER 40) - libomp_append(evflags_local "-D OMP_VERSION=201307") - elseif(${LIBOMP_OMP_VERSION} EQUAL 30 OR ${LIBOMP_OMP_VERSION} GREATER 30) - libomp_append(evflags_local "-D OMP_VERSION=201107") - else() - libomp_append(evflags_local "-D OMP_VERSION=200505") - endif() - set(${evflags} ${evflags_local} PARENT_SCOPE) + set(evflags_local) + libomp_append(evflags_local "-D KMP_TYPE=\"${LIBOMP_LEGAL_TYPE}\"") + libomp_append(evflags_local "-D KMP_ARCH=\"${LIBOMP_LEGAL_ARCH}\"") + libomp_append(evflags_local "-D KMP_VERSION_MAJOR=${LIBOMP_VERSION}") + libomp_append(evflags_local "-D KMP_VERSION_MINOR=0") + libomp_append(evflags_local "-D KMP_VERSION_BUILD=${LIBOMP_BUILD_NUMBER}") + libomp_append(evflags_local "-D KMP_BUILD_DATE=\"${LIBOMP_DATE}\"") + if(${DEBUG_BUILD} OR ${RELWITHDEBINFO_BUILD}) + libomp_append(evflags_local "-D KMP_DIAG=1") + libomp_append(evflags_local "-D KMP_DEBUG_INFO=1") + else() + libomp_append(evflags_local "-D KMP_DIAG=0") + libomp_append(evflags_local "-D KMP_DEBUG_INFO=0") + endif() + if(${LIBOMP_OMP_VERSION} EQUAL 40 OR ${LIBOMP_OMP_VERSION} GREATER 40) + libomp_append(evflags_local "-D OMP_VERSION=201307") + elseif(${LIBOMP_OMP_VERSION} EQUAL 30 OR ${LIBOMP_OMP_VERSION} GREATER 30) + libomp_append(evflags_local "-D OMP_VERSION=201107") + else() + libomp_append(evflags_local "-D OMP_VERSION=200505") + endif() + set(${evflags} ${evflags_local} PARENT_SCOPE) endfunction() # Perl generate-defs.pl flags (For Windows only) function(libomp_get_gdflags gdflags) - set(gdflags_local) - if(${IA32}) - set(libomp_gdflag_arch arch_32) - elseif(${INTEL64}) - set(libomp_gdflag_arch arch_32e) - else() - set(libomp_gdflag_arch arch_${LIBOMP_ARCH}) - endif() - libomp_append(gdflags_local "-D ${libomp_gdflag_arch}") - libomp_append(gdflags_local "-D msvc_compat") - libomp_append(gdflags_local "-D norm" NORMAL_LIBRARY) - libomp_append(gdflags_local "-D prof" PROFILE_LIBRARY) - libomp_append(gdflags_local "-D stub" STUBS_LIBRARY) - libomp_append(gdflags_local "-D HAVE_QUAD" LIBOMP_USE_QUAD_PRECISION) - if(${LIBOMP_OMP_VERSION} GREATER 41 OR ${LIBOMP_OMP_VERSION} EQUAL 41) - libomp_append(gdflags_local "-D OMP_41") - endif() - if(${LIBOMP_OMP_VERSION} GREATER 40 OR ${LIBOMP_OMP_VERSION} EQUAL 40) - libomp_append(gdflags_local "-D OMP_40") - endif() - if(${LIBOMP_OMP_VERSION} GREATER 30 OR ${LIBOMP_OMP_VERSION} EQUAL 30) - libomp_append(gdflags_local "-D OMP_30") - endif() - if(${DEBUG_BUILD} OR ${RELWITHDEBINFO_BUILD}) - libomp_append(gdflags_local "-D KMP_DEBUG") - endif() - set(${gdflags} ${gdflags_local} PARENT_SCOPE) + set(gdflags_local) + if(${IA32}) + set(libomp_gdflag_arch arch_32) + elseif(${INTEL64}) + set(libomp_gdflag_arch arch_32e) + else() + set(libomp_gdflag_arch arch_${LIBOMP_ARCH}) + endif() + libomp_append(gdflags_local "-D ${libomp_gdflag_arch}") + libomp_append(gdflags_local "-D msvc_compat") + libomp_append(gdflags_local "-D norm" NORMAL_LIBRARY) + libomp_append(gdflags_local "-D prof" PROFILE_LIBRARY) + libomp_append(gdflags_local "-D stub" STUBS_LIBRARY) + libomp_append(gdflags_local "-D HAVE_QUAD" LIBOMP_USE_QUAD_PRECISION) + if(${LIBOMP_OMP_VERSION} GREATER 41 OR ${LIBOMP_OMP_VERSION} EQUAL 41) + libomp_append(gdflags_local "-D OMP_41") + endif() + if(${LIBOMP_OMP_VERSION} GREATER 40 OR ${LIBOMP_OMP_VERSION} EQUAL 40) + libomp_append(gdflags_local "-D OMP_40") + endif() + if(${LIBOMP_OMP_VERSION} GREATER 30 OR ${LIBOMP_OMP_VERSION} EQUAL 30) + libomp_append(gdflags_local "-D OMP_30") + endif() + if(${DEBUG_BUILD} OR ${RELWITHDEBINFO_BUILD}) + libomp_append(gdflags_local "-D KMP_DEBUG") + endif() + set(${gdflags} ${gdflags_local} PARENT_SCOPE) endfunction() diff --git a/openmp/runtime/cmake/LibompMicroTests.cmake b/openmp/runtime/cmake/LibompMicroTests.cmake index fbe48fc33ae..300422bbfca 100644 --- a/openmp/runtime/cmake/LibompMicroTests.cmake +++ b/openmp/runtime/cmake/LibompMicroTests.cmake @@ -12,204 +12,204 @@ # The following micro-tests are small tests to perform on the library just created. # There are currently five micro-tests: # (1) test-touch -# - Compile and run a small program using newly created libomp library -# - Fails if test-touch.c does not compile or if test-touch.c does not run after compilation -# - Program dependencies: gcc or g++, grep, bourne shell -# - Available for all Unix,Mac,Windows builds. Not available on Intel(R) MIC Architecture builds. +# - Compile and run a small program using newly created libomp library +# - Fails if test-touch.c does not compile or if test-touch.c does not run after compilation +# - Program dependencies: gcc or g++, grep, bourne shell +# - Available for all Unix,Mac,Windows builds. Not available on Intel(R) MIC Architecture builds. # (2) test-relo -# - Tests dynamic libraries for position-dependent code (can not have any position dependent code) -# - Fails if TEXTREL is in output of readelf -d libomp.so command -# - Program dependencies: readelf, grep, bourne shell -# - Available for Unix, Intel(R) MIC Architecture dynamic library builds. Not available otherwise. +# - Tests dynamic libraries for position-dependent code (can not have any position dependent code) +# - Fails if TEXTREL is in output of readelf -d libomp.so command +# - Program dependencies: readelf, grep, bourne shell +# - Available for Unix, Intel(R) MIC Architecture dynamic library builds. Not available otherwise. # (3) test-execstack -# - Tests if stack is executable -# - Fails if stack is executable. Should only be readable and writable. Not exectuable. -# - Program dependencies: perl, readelf -# - Available for Unix dynamic library builds. Not available otherwise. +# - Tests if stack is executable +# - Fails if stack is executable. Should only be readable and writable. Not exectuable. +# - Program dependencies: perl, readelf +# - Available for Unix dynamic library builds. Not available otherwise. # (4) test-instr (Intel(R) MIC Architecutre only) -# - Tests Intel(R) MIC Architecture libraries for valid instruction set -# - Fails if finds invalid instruction for Intel(R) MIC Architecture (wasn't compiled with correct flags) -# - Program dependencies: perl, objdump -# - Available for Intel(R) MIC Architecture and i386 builds. Not available otherwise. +# - Tests Intel(R) MIC Architecture libraries for valid instruction set +# - Fails if finds invalid instruction for Intel(R) MIC Architecture (wasn't compiled with correct flags) +# - Program dependencies: perl, objdump +# - Available for Intel(R) MIC Architecture and i386 builds. Not available otherwise. # (5) test-deps -# - Tests newly created libomp for library dependencies -# - Fails if sees a dependence not listed in td_exp variable below -# - Program dependencies: perl, (unix)readelf, (mac)otool[64], (windows)link.exe -# - Available for Unix,Mac,Windows, Intel(R) MIC Architecture dynamic builds and Windows -# static builds. Not available otherwise. +# - Tests newly created libomp for library dependencies +# - Fails if sees a dependence not listed in td_exp variable below +# - Program dependencies: perl, (unix)readelf, (mac)otool[64], (windows)link.exe +# - Available for Unix,Mac,Windows, Intel(R) MIC Architecture dynamic builds and Windows +# static builds. Not available otherwise. # get library location if(WIN32) - get_target_property(LIBOMP_OUTPUT_DIRECTORY omp RUNTIME_OUTPUT_DIRECTORY) - get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY ompimp ARCHIVE_OUTPUT_DIRECTORY) - if(NOT LIBOMPIMP_OUTPUT_DIRECTORY) - set(LIBOMPIMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - endif() + get_target_property(LIBOMP_OUTPUT_DIRECTORY omp RUNTIME_OUTPUT_DIRECTORY) + get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY ompimp ARCHIVE_OUTPUT_DIRECTORY) + if(NOT LIBOMPIMP_OUTPUT_DIRECTORY) + set(LIBOMPIMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() else() - get_target_property(LIBOMP_OUTPUT_DIRECTORY omp LIBRARY_OUTPUT_DIRECTORY) + get_target_property(LIBOMP_OUTPUT_DIRECTORY omp LIBRARY_OUTPUT_DIRECTORY) endif() if(NOT LIBOMP_OUTPUT_DIRECTORY) - set(LIBOMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set(LIBOMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif() # test-touch find_program(LIBOMP_SHELL sh) if(WIN32) - if(LIBOMP_SHELL) - set(libomp_test_touch_targets test-touch-md/.success test-touch-mt/.success) - endif() - # pick test-touch compiler - set(libomp_test_touch_compiler ${CMAKE_C_COMPILER}) - # test-touch compilation flags - libomp_append(libomp_test_touch_cflags /nologo) - libomp_append(libomp_test_touch_libs ${LIBOMPIMP_OUTPUT_DIRECTORY}/${LIBOMP_IMP_LIB_FILE}) - if(${IA32}) - libomp_append(libomp_test_touch_ldflags /safeseh) - endif() + if(LIBOMP_SHELL) + set(libomp_test_touch_targets test-touch-md/.success test-touch-mt/.success) + endif() + # pick test-touch compiler + set(libomp_test_touch_compiler ${CMAKE_C_COMPILER}) + # test-touch compilation flags + libomp_append(libomp_test_touch_cflags /nologo) + libomp_append(libomp_test_touch_libs ${LIBOMPIMP_OUTPUT_DIRECTORY}/${LIBOMP_IMP_LIB_FILE}) + if(${IA32}) + libomp_append(libomp_test_touch_ldflags /safeseh) + endif() else() # (Unix based systems, Intel(R) MIC Architecture, and Mac) - if(LIBOMP_SHELL) - set(libomp_test_touch_targets test-touch-rt/.success) - endif() - # pick test-touch compiler - if(${LIBOMP_USE_STDCPPLIB}) - set(libomp_test_touch_compiler ${CMAKE_CXX_COMPILER}) - else() - set(libomp_test_touch_compiler ${CMAKE_C_COMPILER}) - endif() - # test-touch compilation flags - libomp_append(libomp_test_touch_libs "${CMAKE_THREAD_LIBS_INIT}") - if(${IA32}) - libomp_append(libomp_test_touch_cflags -m32 LIBOMP_HAVE_M32_FLAG) - endif() - libomp_append(libomp_test_touch_libs ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE}) - if(APPLE) - set(libomp_test_touch_env "DYLD_LIBRARY_PATH=.:${LIBOMP_OUTPUT_DIRECTORY}:$ENV{DYLD_LIBRARY_PATH}") - else() - set(libomp_test_touch_env "LD_LIBRARY_PATH=.:${LIBOMP_OUTPUT_DIRECTORY}:$ENV{LD_LIBRARY_PATH}") - endif() + if(LIBOMP_SHELL) + set(libomp_test_touch_targets test-touch-rt/.success) + endif() + # pick test-touch compiler + if(${LIBOMP_USE_STDCPPLIB}) + set(libomp_test_touch_compiler ${CMAKE_CXX_COMPILER}) + else() + set(libomp_test_touch_compiler ${CMAKE_C_COMPILER}) + endif() + # test-touch compilation flags + libomp_append(libomp_test_touch_libs "${CMAKE_THREAD_LIBS_INIT}") + if(${IA32}) + libomp_append(libomp_test_touch_cflags -m32 LIBOMP_HAVE_M32_FLAG) + endif() + libomp_append(libomp_test_touch_libs ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE}) + if(APPLE) + set(libomp_test_touch_env "DYLD_LIBRARY_PATH=.:${LIBOMP_OUTPUT_DIRECTORY}:$ENV{DYLD_LIBRARY_PATH}") + else() + set(libomp_test_touch_env "LD_LIBRARY_PATH=.:${LIBOMP_OUTPUT_DIRECTORY}:$ENV{LD_LIBRARY_PATH}") + endif() endif() macro(libomp_test_touch_recipe test_touch_dir) - set(libomp_test_touch_dependencies ${LIBOMP_SRC_DIR}/test-touch.c omp) - set(libomp_test_touch_exe ${test_touch_dir}/test-touch${CMAKE_EXECUTABLE_SUFFIX}) - set(libomp_test_touch_obj ${test_touch_dir}/test-touch${CMAKE_C_OUTPUT_EXTENSION}) - if(WIN32) - if(${RELEASE_BUILD} OR ${RELWITHDEBINFO_BUILD}) - if(${test_touch_dir} MATCHES "test-touch-mt") - libomp_append(libomp_test_touch_cflags /MT) - else() - libomp_append(libomp_test_touch_cflags /MD) - endif() - else() - if(${test_touch_dir} MATCHES "test-touch-mt") - libomp_append(libomp_test_touch_cflags /MTd) - else() - libomp_append(libomp_test_touch_cflags /MDd) - endif() - endif() - set(libomp_test_touch_out_flags -Fe${libomp_test_touch_exe} -Fo${libomp_test_touch_obj}) - list(APPEND libomp_test_touch_dependencies ompimp) + set(libomp_test_touch_dependencies ${LIBOMP_SRC_DIR}/test-touch.c omp) + set(libomp_test_touch_exe ${test_touch_dir}/test-touch${CMAKE_EXECUTABLE_SUFFIX}) + set(libomp_test_touch_obj ${test_touch_dir}/test-touch${CMAKE_C_OUTPUT_EXTENSION}) + if(WIN32) + if(${RELEASE_BUILD} OR ${RELWITHDEBINFO_BUILD}) + if(${test_touch_dir} MATCHES "test-touch-mt") + libomp_append(libomp_test_touch_cflags /MT) + else() + libomp_append(libomp_test_touch_cflags /MD) + endif() else() - set(libomp_test_touch_out_flags -o ${libomp_test_touch_exe}) + if(${test_touch_dir} MATCHES "test-touch-mt") + libomp_append(libomp_test_touch_cflags /MTd) + else() + libomp_append(libomp_test_touch_cflags /MDd) + endif() endif() - add_custom_command( - OUTPUT ${test_touch_dir}/.success ${libomp_test_touch_exe} ${libomp_test_touch_obj} - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${test_touch_dir} - COMMAND ${CMAKE_COMMAND} -E remove -f ${test_touch_dir}/* - COMMAND ${libomp_test_touch_compiler} ${libomp_test_touch_out_flags} ${libomp_test_touch_cflags} - ${LIBOMP_SRC_DIR}/test-touch.c ${libomp_test_touch_ldflags} ${libomp_test_touch_libs} - COMMAND ${LIBOMP_SHELL} -c \"${libomp_test_touch_env} ${libomp_test_touch_exe}\" - COMMAND ${CMAKE_COMMAND} -E touch ${test_touch_dir}/.success - DEPENDS ${libomp_test_touch_dependencies} - ) + set(libomp_test_touch_out_flags -Fe${libomp_test_touch_exe} -Fo${libomp_test_touch_obj}) + list(APPEND libomp_test_touch_dependencies ompimp) + else() + set(libomp_test_touch_out_flags -o ${libomp_test_touch_exe}) + endif() + add_custom_command( + OUTPUT ${test_touch_dir}/.success ${libomp_test_touch_exe} ${libomp_test_touch_obj} + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${test_touch_dir} + COMMAND ${CMAKE_COMMAND} -E remove -f ${test_touch_dir}/* + COMMAND ${libomp_test_touch_compiler} ${libomp_test_touch_out_flags} ${libomp_test_touch_cflags} + ${LIBOMP_SRC_DIR}/test-touch.c ${libomp_test_touch_ldflags} ${libomp_test_touch_libs} + COMMAND ${LIBOMP_SHELL} -c \"${libomp_test_touch_env} ${libomp_test_touch_exe}\" + COMMAND ${CMAKE_COMMAND} -E touch ${test_touch_dir}/.success + DEPENDS ${libomp_test_touch_dependencies} + ) endmacro() libomp_append(libomp_test_touch_env "KMP_VERSION=1") add_custom_target(libomp-test-touch DEPENDS ${libomp_test_touch_targets}) if(WIN32) - libomp_test_touch_recipe(test-touch-mt) - libomp_test_touch_recipe(test-touch-md) + libomp_test_touch_recipe(test-touch-mt) + libomp_test_touch_recipe(test-touch-md) else() - libomp_test_touch_recipe(test-touch-rt) + libomp_test_touch_recipe(test-touch-rt) endif() # test-relo add_custom_target(libomp-test-relo DEPENDS test-relo/.success) add_custom_command( - OUTPUT test-relo/.success test-relo/readelf.log - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-relo - COMMAND readelf -d ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} > test-relo/readelf.log - COMMAND grep -e TEXTREL test-relo/readelf.log \; [ $$? -eq 1 ] - COMMAND ${CMAKE_COMMAND} -E touch test-relo/.success - DEPENDS omp + OUTPUT test-relo/.success test-relo/readelf.log + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-relo + COMMAND readelf -d ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} > test-relo/readelf.log + COMMAND grep -e TEXTREL test-relo/readelf.log \; [ $$? -eq 1 ] + COMMAND ${CMAKE_COMMAND} -E touch test-relo/.success + DEPENDS omp ) # test-execstack add_custom_target(libomp-test-execstack DEPENDS test-execstack/.success) add_custom_command( - OUTPUT test-execstack/.success - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-execstack - COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/check-execstack.pl --os=${LIBOMP_PERL_SCRIPT_OS} - --arch=${LIBOMP_ARCH} ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} - COMMAND ${CMAKE_COMMAND} -E touch test-execstack/.success - DEPENDS omp + OUTPUT test-execstack/.success + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-execstack + COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/check-execstack.pl --os=${LIBOMP_PERL_SCRIPT_OS} + --arch=${LIBOMP_ARCH} ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} + COMMAND ${CMAKE_COMMAND} -E touch test-execstack/.success + DEPENDS omp ) # test-instr add_custom_target(libomp-test-instr DEPENDS test-instr/.success) add_custom_command( - OUTPUT test-instr/.success - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-instr - COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/check-instruction-set.pl --os=${LIBOMP_PERL_SCRIPT_OS} - --arch=${LIBOMP_ARCH} --show --mic-arch=${LIBOMP_MIC_ARCH} ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} - COMMAND ${CMAKE_COMMAND} -E touch test-instr/.success - DEPENDS omp ${LIBOMP_TOOLS_DIR}/check-instruction-set.pl + OUTPUT test-instr/.success + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-instr + COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/check-instruction-set.pl --os=${LIBOMP_PERL_SCRIPT_OS} + --arch=${LIBOMP_ARCH} --show --mic-arch=${LIBOMP_MIC_ARCH} ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} + COMMAND ${CMAKE_COMMAND} -E touch test-instr/.success + DEPENDS omp ${LIBOMP_TOOLS_DIR}/check-instruction-set.pl ) # test-deps add_custom_target(libomp-test-deps DEPENDS test-deps/.success) set(libomp_expected_library_deps) if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - set(libomp_expected_library_deps libc.so.7 libthr.so.3) + set(libomp_expected_library_deps libc.so.7 libthr.so.3) elseif(APPLE) - set(libomp_expected_library_deps /usr/lib/libSystem.B.dylib) + set(libomp_expected_library_deps /usr/lib/libSystem.B.dylib) elseif(WIN32) - set(libomp_expected_library_deps kernel32.dll) + set(libomp_expected_library_deps kernel32.dll) else() - if(${MIC}) - set(libomp_expected_library_deps libc.so.6 libpthread.so.0 libdl.so.2) - if("${LIBOMP_MIC_ARCH}" STREQUAL "knf") - libomp_append(libomp_expected_library_deps ld-linux-l1om.so.2) - libomp_append(libomp_expected_library_deps libgcc_s.so.1) - elseif("${LIBOMP_MIC_ARCH}" STREQUAL "knc") - libomp_append(libomp_expected_library_deps ld-linux-k1om.so.2) - endif() - else() - set(libomp_expected_library_deps libdl.so.2 libgcc_s.so.1) - if(${IA32}) - libomp_append(libomp_expected_library_deps libc.so.6) - libomp_append(libomp_expected_library_deps ld-linux.so.2) - elseif(${INTEL64}) - libomp_append(libomp_expected_library_deps libc.so.6) - libomp_append(libomp_expected_library_deps ld-linux-x86-64.so.2) - elseif(${ARM}) - libomp_append(libomp_expected_library_deps libc.so.6) - libomp_append(libomp_expected_library_deps libffi.so.6) - libomp_append(libomp_expected_library_deps libffi.so.5) - libomp_append(libomp_expected_library_deps ld-linux-armhf.so.3) - elseif(${PPC64}) - libomp_append(libomp_expected_library_deps libc.so.6) - libomp_append(libomp_expected_library_deps ld64.so.1) - endif() - libomp_append(libomp_expected_library_deps libpthread.so.0 IF_FALSE STUBS_LIBRARY) + if(${MIC}) + set(libomp_expected_library_deps libc.so.6 libpthread.so.0 libdl.so.2) + if("${LIBOMP_MIC_ARCH}" STREQUAL "knf") + libomp_append(libomp_expected_library_deps ld-linux-l1om.so.2) + libomp_append(libomp_expected_library_deps libgcc_s.so.1) + elseif("${LIBOMP_MIC_ARCH}" STREQUAL "knc") + libomp_append(libomp_expected_library_deps ld-linux-k1om.so.2) + endif() + else() + set(libomp_expected_library_deps libdl.so.2 libgcc_s.so.1) + if(${IA32}) + libomp_append(libomp_expected_library_deps libc.so.6) + libomp_append(libomp_expected_library_deps ld-linux.so.2) + elseif(${INTEL64}) + libomp_append(libomp_expected_library_deps libc.so.6) + libomp_append(libomp_expected_library_deps ld-linux-x86-64.so.2) + elseif(${ARM}) + libomp_append(libomp_expected_library_deps libc.so.6) + libomp_append(libomp_expected_library_deps libffi.so.6) + libomp_append(libomp_expected_library_deps libffi.so.5) + libomp_append(libomp_expected_library_deps ld-linux-armhf.so.3) + elseif(${PPC64}) + libomp_append(libomp_expected_library_deps libc.so.6) + libomp_append(libomp_expected_library_deps ld64.so.1) endif() - libomp_append(libomp_expected_library_deps libstdc++.so.6 LIBOMP_USE_STDCPPLIB) + libomp_append(libomp_expected_library_deps libpthread.so.0 IF_FALSE STUBS_LIBRARY) + endif() + libomp_append(libomp_expected_library_deps libstdc++.so.6 LIBOMP_USE_STDCPPLIB) endif() # Perl script expects comma separated list string(REPLACE ";" "," libomp_expected_library_deps "${libomp_expected_library_deps}") add_custom_command( - OUTPUT test-deps/.success - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-deps - COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/check-depends.pl --os=${LIBOMP_PERL_SCRIPT_OS} - --arch=${LIBOMP_ARCH} --expected="${libomp_expected_library_deps}" ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} - COMMAND ${CMAKE_COMMAND} -E touch test-deps/.success - DEPENDS omp ${LIBOMP_TOOLS_DIR}/check-depends.pl + OUTPUT test-deps/.success + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test-deps + COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/check-depends.pl --os=${LIBOMP_PERL_SCRIPT_OS} + --arch=${LIBOMP_ARCH} --expected="${libomp_expected_library_deps}" ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} + COMMAND ${CMAKE_COMMAND} -E touch test-deps/.success + DEPENDS omp ${LIBOMP_TOOLS_DIR}/check-depends.pl ) diff --git a/openmp/runtime/cmake/LibompUtils.cmake b/openmp/runtime/cmake/LibompUtils.cmake index 1a9cc06722d..ba81a6c79e2 100644 --- a/openmp/runtime/cmake/LibompUtils.cmake +++ b/openmp/runtime/cmake/LibompUtils.cmake @@ -12,19 +12,19 @@ # void libomp_say(string message_to_user); # - prints out message_to_user macro(libomp_say message_to_user) - message(STATUS "LIBOMP: ${message_to_user}") + message(STATUS "LIBOMP: ${message_to_user}") endmacro() # void libomp_warning_say(string message_to_user); # - prints out message_to_user with a warning macro(libomp_warning_say message_to_user) - message(WARNING "LIBOMP: ${message_to_user}") + message(WARNING "LIBOMP: ${message_to_user}") endmacro() # void libomp_error_say(string message_to_user); # - prints out message_to_user with an error and exits cmake macro(libomp_error_say message_to_user) - message(FATAL_ERROR "LIBOMP: ${message_to_user}") + message(FATAL_ERROR "LIBOMP: ${message_to_user}") endmacro() # libomp_append(<flag> <flags_list> [(IF_TRUE | IF_FALSE | IF_TRUE_1_0 ) BOOLEAN]) @@ -47,65 +47,65 @@ endmacro() # libomp_append(<flag> <flags_list> IF_TRUE_1_0 <BOOLEAN>) # - appends <flag>=1 to the list of definitions if <BOOLEAN> is true, <flag>=0 otherwise # e.g., libomp_append("-D USE_FEATURE" IF_TRUE_1_0 HAVE_FEATURE) -# appends "-D USE_FEATURE=1" if HAVE_FEATURE is true -# or "-D USE_FEATURE=0" if HAVE_FEATURE is false +# appends "-D USE_FEATURE=1" if HAVE_FEATURE is true +# or "-D USE_FEATURE=0" if HAVE_FEATURE is false macro(libomp_append flags flag) - if(NOT (${ARGC} EQUAL 2 OR ${ARGC} EQUAL 3 OR ${ARGC} EQUAL 4)) - libomp_error_say("libomp_append: takes 2, 3, or 4 arguments") + if(NOT (${ARGC} EQUAL 2 OR ${ARGC} EQUAL 3 OR ${ARGC} EQUAL 4)) + libomp_error_say("libomp_append: takes 2, 3, or 4 arguments") + endif() + if(${ARGC} EQUAL 2) + list(APPEND ${flags} "${flag}") + elseif(${ARGC} EQUAL 3) + if(${ARGV2}) + list(APPEND ${flags} "${flag}") endif() - if(${ARGC} EQUAL 2) + else() + if(${ARGV2} STREQUAL "IF_TRUE") + if(${ARGV3}) list(APPEND ${flags} "${flag}") - elseif(${ARGC} EQUAL 3) - if(${ARGV2}) - list(APPEND ${flags} "${flag}") - endif() + endif() + elseif(${ARGV2} STREQUAL "IF_FALSE") + if(NOT ${ARGV3}) + list(APPEND ${flags} "${flag}") + endif() + elseif(${ARGV2} STREQUAL "IF_DEFINED") + if(DEFINED ${ARGV3}) + list(APPEND ${flags} "${flag}") + endif() + elseif(${ARGV2} STREQUAL "IF_TRUE_1_0") + if(${ARGV3}) + list(APPEND ${flags} "${flag}=1") + else() + list(APPEND ${flags} "${flag}=0") + endif() else() - if(${ARGV2} STREQUAL "IF_TRUE") - if(${ARGV3}) - list(APPEND ${flags} "${flag}") - endif() - elseif(${ARGV2} STREQUAL "IF_FALSE") - if(NOT ${ARGV3}) - list(APPEND ${flags} "${flag}") - endif() - elseif(${ARGV2} STREQUAL "IF_DEFINED") - if(DEFINED ${ARGV3}) - list(APPEND ${flags} "${flag}") - endif() - elseif(${ARGV2} STREQUAL "IF_TRUE_1_0") - if(${ARGV3}) - list(APPEND ${flags} "${flag}=1") - else() - list(APPEND ${flags} "${flag}=0") - endif() - else() - libomp_error_say("libomp_append: third argument must be one of IF_TRUE, IF_FALSE, IF_DEFINED, IF_TRUE_1_0") - endif() + libomp_error_say("libomp_append: third argument must be one of IF_TRUE, IF_FALSE, IF_DEFINED, IF_TRUE_1_0") endif() + endif() endmacro() # void libomp_get_legal_arch(string* return_arch_string); # - returns (through return_arch_string) the formal architecture # string or warns user of unknown architecture function(libomp_get_legal_arch return_arch_string) - if(${IA32}) - set(${return_arch_string} "IA-32" PARENT_SCOPE) - elseif(${INTEL64}) - set(${return_arch_string} "Intel(R) 64" PARENT_SCOPE) - elseif(${MIC}) - set(${return_arch_string} "Intel(R) Many Integrated Core Architecture" PARENT_SCOPE) - elseif(${ARM}) - set(${return_arch_string} "ARM" PARENT_SCOPE) - elseif(${PPC64BE}) - set(${return_arch_string} "PPC64BE" PARENT_SCOPE) - elseif(${PPC64LE}) - set(${return_arch_string} "PPC64LE" PARENT_SCOPE) - elseif(${AARCH64}) - set(${return_arch_string} "AARCH64" PARENT_SCOPE) - else() - set(${return_arch_string} "${LIBOMP_ARCH}" PARENT_SCOPE) - libomp_warning_say("libomp_get_legal_arch(): Warning: Unknown architecture: Using ${LIBOMP_ARCH}") - endif() + if(${IA32}) + set(${return_arch_string} "IA-32" PARENT_SCOPE) + elseif(${INTEL64}) + set(${return_arch_string} "Intel(R) 64" PARENT_SCOPE) + elseif(${MIC}) + set(${return_arch_string} "Intel(R) Many Integrated Core Architecture" PARENT_SCOPE) + elseif(${ARM}) + set(${return_arch_string} "ARM" PARENT_SCOPE) + elseif(${PPC64BE}) + set(${return_arch_string} "PPC64BE" PARENT_SCOPE) + elseif(${PPC64LE}) + set(${return_arch_string} "PPC64LE" PARENT_SCOPE) + elseif(${AARCH64}) + set(${return_arch_string} "AARCH64" PARENT_SCOPE) + else() + set(${return_arch_string} "${LIBOMP_ARCH}" PARENT_SCOPE) + libomp_warning_say("libomp_get_legal_arch(): Warning: Unknown architecture: Using ${LIBOMP_ARCH}") + endif() endfunction() # void libomp_check_variable(string var, ...); @@ -114,69 +114,69 @@ endfunction() # - if the var is found, then just print it out # - if the var is not found, then error out function(libomp_check_variable var) - set(valid_flag 0) - string(TOLOWER "${${var}}" var_lower) - foreach(value IN LISTS ARGN) - string(TOLOWER "${value}" value_lower) - if("${var_lower}" STREQUAL "${value_lower}") - set(valid_flag 1) - set(the_value "${value}") - endif() - endforeach() - if(${valid_flag} EQUAL 0) - libomp_error_say("libomp_check_variable(): ${var} = ${${var}} is unknown") + set(valid_flag 0) + string(TOLOWER "${${var}}" var_lower) + foreach(value IN LISTS ARGN) + string(TOLOWER "${value}" value_lower) + if("${var_lower}" STREQUAL "${value_lower}") + set(valid_flag 1) + set(the_value "${value}") endif() + endforeach() + if(${valid_flag} EQUAL 0) + libomp_error_say("libomp_check_variable(): ${var} = ${${var}} is unknown") + endif() endfunction() # void libomp_get_build_number(string src_dir, string* return_build_number); # - grab the eight digit build number (or 00000000) from kmp_version.c function(libomp_get_build_number src_dir return_build_number) - # sets file_lines_list to a list of all lines in kmp_version.c - file(STRINGS "${src_dir}/src/kmp_version.c" file_lines_list) + # sets file_lines_list to a list of all lines in kmp_version.c + file(STRINGS "${src_dir}/src/kmp_version.c" file_lines_list) - # runs through each line in kmp_version.c - foreach(line IN LISTS file_lines_list) - # if the line begins with "#define KMP_VERSION_BUILD" then we take not of the build number - string(REGEX MATCH "^[ \t]*#define[ \t]+KMP_VERSION_BUILD" valid "${line}") - if(NOT "${valid}" STREQUAL "") # if we matched "#define KMP_VERSION_BUILD", then grab the build number - string(REGEX REPLACE "^[ \t]*#define[ \t]+KMP_VERSION_BUILD[ \t]+([0-9]+)" "\\1" - build_number "${line}" - ) - endif() - endforeach() - set(${return_build_number} "${build_number}" PARENT_SCOPE) # return build number + # runs through each line in kmp_version.c + foreach(line IN LISTS file_lines_list) + # if the line begins with "#define KMP_VERSION_BUILD" then we take not of the build number + string(REGEX MATCH "^[ \t]*#define[ \t]+KMP_VERSION_BUILD" valid "${line}") + if(NOT "${valid}" STREQUAL "") # if we matched "#define KMP_VERSION_BUILD", then grab the build number + string(REGEX REPLACE "^[ \t]*#define[ \t]+KMP_VERSION_BUILD[ \t]+([0-9]+)" "\\1" + build_number "${line}" + ) + endif() + endforeach() + set(${return_build_number} "${build_number}" PARENT_SCOPE) # return build number endfunction() # void libomp_get_legal_type(string* return_legal_type); # - set the legal type name Performance/Profiling/Stub function(libomp_get_legal_type return_legal_type) - if(${NORMAL_LIBRARY}) - set(${return_legal_type} "Performance" PARENT_SCOPE) - elseif(${PROFILE_LIBRARY}) - set(${return_legal_type} "Profiling" PARENT_SCOPE) - elseif(${STUBS_LIBRARY}) - set(${return_legal_type} "Stub" PARENT_SCOPE) - endif() + if(${NORMAL_LIBRARY}) + set(${return_legal_type} "Performance" PARENT_SCOPE) + elseif(${PROFILE_LIBRARY}) + set(${return_legal_type} "Profiling" PARENT_SCOPE) + elseif(${STUBS_LIBRARY}) + set(${return_legal_type} "Stub" PARENT_SCOPE) + endif() endfunction() # void libomp_add_suffix(string suffix, list<string>* list_of_items); # - returns list_of_items with suffix appended to all items # - original list is modified function(libomp_add_suffix suffix list_of_items) - set(local_list "") - foreach(item IN LISTS "${list_of_items}") - if(NOT "${item}" STREQUAL "") - list(APPEND local_list "${item}${suffix}") - endif() - endforeach() - set(${list_of_items} "${local_list}" PARENT_SCOPE) + set(local_list "") + foreach(item IN LISTS "${list_of_items}") + if(NOT "${item}" STREQUAL "") + list(APPEND local_list "${item}${suffix}") + endif() + endforeach() + set(${list_of_items} "${local_list}" PARENT_SCOPE) endfunction() # void libomp_list_to_string(list<string> list_of_things, string* return_string); # - converts a list to a space separated string function(libomp_list_to_string list_of_things return_string) - string(REPLACE ";" " " output_variable "${list_of_things}") - set(${return_string} "${output_variable}" PARENT_SCOPE) + string(REPLACE ";" " " output_variable "${list_of_things}") + set(${return_string} "${output_variable}" PARENT_SCOPE) endfunction() # void libomp_string_to_list(string str, list<string>* return_list); @@ -184,8 +184,8 @@ endfunction() # - what it really does is just string_replace all running whitespace to a semicolon # - in cmake, a list is strings separated by semicolons: i.e., list of four items, list = "item1;item2;item3;item4" function(libomp_string_to_list str return_list) - set(outstr) - string(REGEX REPLACE "[ \t]+" ";" outstr "${str}") - set(${return_list} "${outstr}" PARENT_SCOPE) + set(outstr) + string(REGEX REPLACE "[ \t]+" ";" outstr "${str}") + set(${return_list} "${outstr}" PARENT_SCOPE) endfunction() diff --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake index bc4604ffda9..bd798d6070b 100644 --- a/openmp/runtime/cmake/config-ix.cmake +++ b/openmp/runtime/cmake/config-ix.cmake @@ -18,30 +18,30 @@ include(LibompCheckFortranFlag) # Check for versioned symbols function(libomp_check_version_symbols retval) - set(source_code -"#include <stdio.h> -void func1() { printf(\"Hello\"); } -void func2() { printf(\"World\"); } -__asm__(\".symver func1, func@VER1\"); -__asm__(\".symver func2, func@VER2\"); -int main() { - func1(); - func2(); - return 0; -}") - set(version_script_source "VER1 { }; VER2 { } VER1;") - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt "${version_script_source}") - set(CMAKE_REQUIRED_FLAGS -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt) - check_c_source_compiles("${source_code}" ${retval}) - set(${retval} ${${retval}} PARENT_SCOPE) - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt) + set(source_code + "#include <stdio.h> + void func1() { printf(\"Hello\"); } + void func2() { printf(\"World\"); } + __asm__(\".symver func1, func@VER1\"); + __asm__(\".symver func2, func@VER2\"); + int main() { + func1(); + func2(); + return 0; + }") + set(version_script_source "VER1 { }; VER2 { } VER1;") + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt "${version_script_source}") + set(CMAKE_REQUIRED_FLAGS -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt) + check_c_source_compiles("${source_code}" ${retval}) + set(${retval} ${${retval}} PARENT_SCOPE) + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt) endfunction() # Includes the architecture flag in both compile and link phase function(libomp_check_architecture_flag flag retval) - set(CMAKE_REQUIRED_FLAGS "${flag}") - check_c_compiler_flag("${flag}" ${retval}) - set(${retval} ${${retval}} PARENT_SCOPE) + set(CMAKE_REQUIRED_FLAGS "${flag}") + check_c_compiler_flag("${flag}" ${retval}) + set(${retval} ${${retval}} PARENT_SCOPE) endfunction() # Checking C, CXX, Linker Flags @@ -57,73 +57,73 @@ check_cxx_compiler_flag(-ftls-model=initial-exec LIBOMP_HAVE_FTLS_MODEL_FLAG) libomp_check_architecture_flag(-mmic LIBOMP_HAVE_MMIC_FLAG) libomp_check_architecture_flag(-m32 LIBOMP_HAVE_M32_FLAG) if(WIN32) - # Check Windows MSVC style flags. - check_c_compiler_flag(/TP LIBOMP_HAVE_TP_FLAG) - check_cxx_compiler_flag(/EHsc LIBOMP_HAVE_EHSC_FLAG) - check_cxx_compiler_flag(/GS LIBOMP_HAVE_GS_FLAG) - check_cxx_compiler_flag(/Oy- LIBOMP_HAVE_Oy__FLAG) - check_cxx_compiler_flag(/arch:SSE2 LIBOMP_HAVE_ARCH_SSE2_FLAG) - check_cxx_compiler_flag(/Qsafeseh LIBOMP_HAVE_QSAFESEH_FLAG) - # It is difficult to create a dummy masm assembly file - # and then check the MASM assembler to see if these flags exist and work, - # so we assume they do for Windows. - set(LIBOMP_HAVE_SAFESEH_MASM_FLAG TRUE) - set(LIBOMP_HAVE_COFF_MASM_FLAG TRUE) - # Change Windows flags /MDx to /MTx - foreach(libomp_lang IN ITEMS C CXX) - foreach(libomp_btype IN ITEMS DEBUG RELWITHDEBINFO RELEASE MINSIZEREL) - string(REPLACE "/MD" "/MT" - CMAKE_${libomp_lang}_FLAGS_${libomp_btype} - "${CMAKE_${libomp_lang}_FLAGS_${libomp_btype}}" - ) - endforeach() + # Check Windows MSVC style flags. + check_c_compiler_flag(/TP LIBOMP_HAVE_TP_FLAG) + check_cxx_compiler_flag(/EHsc LIBOMP_HAVE_EHSC_FLAG) + check_cxx_compiler_flag(/GS LIBOMP_HAVE_GS_FLAG) + check_cxx_compiler_flag(/Oy- LIBOMP_HAVE_Oy__FLAG) + check_cxx_compiler_flag(/arch:SSE2 LIBOMP_HAVE_ARCH_SSE2_FLAG) + check_cxx_compiler_flag(/Qsafeseh LIBOMP_HAVE_QSAFESEH_FLAG) + # It is difficult to create a dummy masm assembly file + # and then check the MASM assembler to see if these flags exist and work, + # so we assume they do for Windows. + set(LIBOMP_HAVE_SAFESEH_MASM_FLAG TRUE) + set(LIBOMP_HAVE_COFF_MASM_FLAG TRUE) + # Change Windows flags /MDx to /MTx + foreach(libomp_lang IN ITEMS C CXX) + foreach(libomp_btype IN ITEMS DEBUG RELWITHDEBINFO RELEASE MINSIZEREL) + string(REPLACE "/MD" "/MT" + CMAKE_${libomp_lang}_FLAGS_${libomp_btype} + "${CMAKE_${libomp_lang}_FLAGS_${libomp_btype}}" + ) endforeach() + endforeach() else() - # It is difficult to create a dummy assembly file that compiles into an - # exectuable for every architecture and then check the C compiler to - # see if -x assembler-with-cpp exists and works, so we assume it does for non-Windows. - set(LIBOMP_HAVE_X_ASSEMBLER_WITH_CPP_FLAG TRUE) + # It is difficult to create a dummy assembly file that compiles into an + # exectuable for every architecture and then check the C compiler to + # see if -x assembler-with-cpp exists and works, so we assume it does for non-Windows. + set(LIBOMP_HAVE_X_ASSEMBLER_WITH_CPP_FLAG TRUE) endif() if(${LIBOMP_FORTRAN_MODULES}) - libomp_check_fortran_flag(-m32 LIBOMP_HAVE_M32_FORTRAN_FLAG) + libomp_check_fortran_flag(-m32 LIBOMP_HAVE_M32_FORTRAN_FLAG) endif() # Check linker flags if(WIN32) - libomp_check_linker_flag(/SAFESEH LIBOMP_HAVE_SAFESEH_FLAG) + libomp_check_linker_flag(/SAFESEH LIBOMP_HAVE_SAFESEH_FLAG) elseif(NOT APPLE) - libomp_check_linker_flag(-Wl,-x LIBOMP_HAVE_X_FLAG) - libomp_check_linker_flag(-Wl,--warn-shared-textrel LIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG) - libomp_check_linker_flag(-Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG) - libomp_check_linker_flag("-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG) - libomp_check_linker_flag(-static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG) - libomp_check_linker_flag(-Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG) - libomp_check_linker_flag(-Wl,-fini=__kmp_internal_end_fini LIBOMP_HAVE_FINI_FLAG) + libomp_check_linker_flag(-Wl,-x LIBOMP_HAVE_X_FLAG) + libomp_check_linker_flag(-Wl,--warn-shared-textrel LIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG) + libomp_check_linker_flag(-Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG) + libomp_check_linker_flag("-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG) + libomp_check_linker_flag(-static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG) + libomp_check_linker_flag(-Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG) + libomp_check_linker_flag(-Wl,-fini=__kmp_internal_end_fini LIBOMP_HAVE_FINI_FLAG) endif() # Check Intel(R) C Compiler specific flags if(CMAKE_C_COMPILER_ID STREQUAL "Intel") - check_cxx_compiler_flag(/Qlong_double LIBOMP_HAVE_LONG_DOUBLE_FLAG) - check_cxx_compiler_flag(/Qdiag-disable:177 LIBOMP_HAVE_DIAG_DISABLE_177_FLAG) - check_cxx_compiler_flag(/Qinline-min-size=1 LIBOMP_HAVE_INLINE_MIN_SIZE_FLAG) - check_cxx_compiler_flag(-Qoption,cpp,--extended_float_types LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG) - check_cxx_compiler_flag(-falign-stack=maintain-16-byte LIBOMP_HAVE_FALIGN_STACK_FLAG) - check_cxx_compiler_flag("-opt-streaming-stores never" LIBOMP_HAVE_OPT_STREAMING_STORES_FLAG) - libomp_check_linker_flag(-static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG) - libomp_check_linker_flag(-no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG) - check_library_exists(irc_pic _intel_fast_memcpy "" LIBOMP_HAVE_IRC_PIC_LIBRARY) + check_cxx_compiler_flag(/Qlong_double LIBOMP_HAVE_LONG_DOUBLE_FLAG) + check_cxx_compiler_flag(/Qdiag-disable:177 LIBOMP_HAVE_DIAG_DISABLE_177_FLAG) + check_cxx_compiler_flag(/Qinline-min-size=1 LIBOMP_HAVE_INLINE_MIN_SIZE_FLAG) + check_cxx_compiler_flag(-Qoption,cpp,--extended_float_types LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG) + check_cxx_compiler_flag(-falign-stack=maintain-16-byte LIBOMP_HAVE_FALIGN_STACK_FLAG) + check_cxx_compiler_flag("-opt-streaming-stores never" LIBOMP_HAVE_OPT_STREAMING_STORES_FLAG) + libomp_check_linker_flag(-static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG) + libomp_check_linker_flag(-no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG) + check_library_exists(irc_pic _intel_fast_memcpy "" LIBOMP_HAVE_IRC_PIC_LIBRARY) endif() # Checking Threading requirements find_package(Threads REQUIRED) if(WIN32) - if(NOT CMAKE_USE_WIN32_THREADS_INIT) - libomp_error_say("Need Win32 thread interface on Windows.") - endif() + if(NOT CMAKE_USE_WIN32_THREADS_INIT) + libomp_error_say("Need Win32 thread interface on Windows.") + endif() else() - if(NOT CMAKE_USE_PTHREADS_INIT) - libomp_error_say("Need pthread interface on Unix-like systems.") - endif() + if(NOT CMAKE_USE_PTHREADS_INIT) + libomp_error_say("Need pthread interface on Unix-like systems.") + endif() endif() # Find perl executable @@ -135,11 +135,11 @@ find_package(Perl REQUIRED) # in that all the Perl scripts check the operating system and will fail if it isn't "valid". This # temporary solution lets us avoid trying to enumerate all the possible OS values inside the Perl modules. if(WIN32) - set(LIBOMP_PERL_SCRIPT_OS win) + set(LIBOMP_PERL_SCRIPT_OS win) elseif(APPLE) - set(LIBOMP_PERL_SCRIPT_OS mac) + set(LIBOMP_PERL_SCRIPT_OS mac) else() - set(LIBOMP_PERL_SCRIPT_OS lin) + set(LIBOMP_PERL_SCRIPT_OS lin) endif() # Checking features @@ -148,34 +148,34 @@ libomp_check_version_symbols(LIBOMP_HAVE_VERSION_SYMBOLS) # Check if quad precision types are available if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - set(LIBOMP_HAVE_QUAD_PRECISION TRUE) + set(LIBOMP_HAVE_QUAD_PRECISION TRUE) elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel") - if(LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG) - set(LIBOMP_HAVE_QUAD_PRECISION TRUE) - else() - set(LIBOMP_HAVE_QUAD_PRECISION TRUE) - endif() + if(LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG) + set(LIBOMP_HAVE_QUAD_PRECISION TRUE) + else() + set(LIBOMP_HAVE_QUAD_PRECISION TRUE) + endif() else() - set(LIBOMP_HAVE_QUAD_PRECISION FALSE) + set(LIBOMP_HAVE_QUAD_PRECISION FALSE) endif() # Check if adaptive locks are available if((${IA32} OR ${INTEL64}) AND NOT MSVC) - set(LIBOMP_HAVE_ADAPTIVE_LOCKS TRUE) + set(LIBOMP_HAVE_ADAPTIVE_LOCKS TRUE) else() - set(LIBOMP_HAVE_ADAPTIVE_LOCKS FALSE) + set(LIBOMP_HAVE_ADAPTIVE_LOCKS FALSE) endif() # Check if stats-gathering is available if(NOT (WIN32 OR APPLE) AND (${IA32} OR ${INTEL64} OR ${MIC})) - set(LIBOMP_HAVE_STATS TRUE) + set(LIBOMP_HAVE_STATS TRUE) else() - set(LIBOMP_HAVE_STATS FALSE) + set(LIBOMP_HAVE_STATS FALSE) endif() # Check if OMPT support is available if(NOT WIN32) - set(LIBOMP_HAVE_OMPT_SUPPORT TRUE) + set(LIBOMP_HAVE_OMPT_SUPPORT TRUE) else() - set(LIBOMP_HAVE_OMPT_SUPPORT FALSE) + set(LIBOMP_HAVE_OMPT_SUPPORT FALSE) endif() |