diff --git a/.gitmodules b/.gitmodules index ee35645b1fd3edcf5dac204224637285000ba687..5749e2a293886fb7409b37f01b3fb1457d81a8a8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "doc/rtd_theme"] path = doc/rtd_theme url = https://github.com/rtfd/sphinx_rtd_theme.git +[submodule "tbb"] + path = tbb + url = https://github.com/wjakob/tbb.git diff --git a/.travis.yml b/.travis.yml index 538543949c53897cc695190b5ccd064e3fed9453..3cb473553e0b9b7a5cc3fb34c7863144e2cc763d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,10 +17,10 @@ env: # test single node/rank with different threading back ends - BUILD_NAME=serial WITH_THREAD=serial WITH_DISTRIBUTED=serial - BUILD_NAME=cthread WITH_THREAD=cthread WITH_DISTRIBUTED=serial - # The tbb backend sometimes fails to build because CMake. Turn it off until our CMake TBB support is stable. - #- BUILD_NAME=tbb WITH_THREAD=tbb WITH_DISTRIBUTED=serial + - BUILD_NAME=tbb WITH_THREAD=tbb WITH_DISTRIBUTED=serial # test mpi - BUILD_NAME=mpi WITH_THREAD=cthread WITH_DISTRIBUTED=mpi + - BUILD_NAME=mpitbb WITH_THREAD=tbb WITH_DISTRIBUTED=mpi before_install: - CC=gcc-5 diff --git a/CMakeLists.txt b/CMakeLists.txt index 99b5d3cf0fb015fca5b0e355c3b9c4f13efc5c86..df3894c1e5be285c896c3073385bc4a1be31786b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,40 +66,46 @@ set(ARB_THREADING_MODEL "cthread" CACHE STRING "set the threading model, one of set_property(CACHE ARB_THREADING_MODEL PROPERTY STRINGS cthread tbb serial ) if(ARB_THREADING_MODEL MATCHES "tbb") - # download and build TBB - include(${CMAKE_SOURCE_DIR}/cmake/tbb/TBBGet.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/tbb/TBBBuild.cmake) - tbb_get(TBB_ROOT tbb_root SOURCE_CODE) - tbb_build(TBB_ROOT ${tbb_root} CONFIG_DIR TBB_DIR) + # TODO: update to use built-in support for detecting git submodules. + if(NOT EXISTS "${CMAKE_SOURCE_DIR}/tbb/.git") + message(FATAL_ERROR + "\nThe git submodule for tbb must be checked out to use TBB.\n" + " git submodule init\n" + " git submodule update\n") + endif() + + # turn off proxy malloc library and test compilation + option(TBB_BUILD_TBBMALLOC_PROXY OFF) + option(TBB_BUILD_TESTS OFF) - # configure TBB - find_package(TBB REQUIRED tbb tbbmalloc) + # Use the CMake configuration in the TBB submodule + # Reset the CXX flags, to avoid the litany of warnings that -Wall + # gives when compiling TBB. + set(CMAKE_CXX_FLAGS_TBB_BACK "${CMAKE_CXX_FLAGS}") + unset(CMAKE_CXX_FLAGS) + add_subdirectory(tbb) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_TBB_BACK}") + # set flags for TBB add_definitions(-DARB_HAVE_TBB) set(ARB_WITH_TBB TRUE) - # The TBB CMake package creates the TBB::tbb and TBB:tbbmalloc targets. - # The following should be sufficient, however on some systems (e.g. Cray PE), - # they don't work (because CMake is fragile): - # list(APPEND EXTERNAL_LIBRARIES TBB::tbb) - # list(APPEND EXTERNAL_LIBRARIES TBB::tbbmalloc) - # So, instead, manually add the library links: - set(TBB_LIB_PATH ${CMAKE_BINARY_DIR}/tbb_cmake_build/tbb_cmake_build_subdir_release) - list(APPEND EXTERNAL_LIBRARIES ${TBB_LIB_PATH}/libtbb.so) - list(APPEND EXTERNAL_LIBRARIES ${TBB_LIB_PATH}/libtbbmalloc.so) + include_directories(${CMAKE_SOURCE_DIR}/tbb/include) - # The TBB headers are in the downloaded TBB source - list(APPEND EXTERNAL_INCLUDES ${tbb_root}/include) + list(APPEND EXTERNAL_LIBRARIES tbb_static tbbmalloc_static) + list(APPEND EXTERNAL_LIBRARIES pthread dl) -elseif(ARB_THREADING_MODEL MATCHES "cthread") + # TODO add support for user-supplied tbb implementation, + # e.g. using an TBB_ROOT variable. +elseif(ARB_THREADING_MODEL MATCHES "cthread") find_package(Threads REQUIRED) add_definitions(-DARB_HAVE_CTHREAD) set(ARB_WITH_CTHREAD TRUE) list(APPEND EXTERNAL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) if(CMAKE_USE_PTHREADS_INIT) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") endif() endif() diff --git a/cmake/tbb/TBBBuild.cmake b/cmake/tbb/TBBBuild.cmake deleted file mode 100644 index bcf04c87bf23755911d5955ec844fb1eff9b0a5b..0000000000000000000000000000000000000000 --- a/cmake/tbb/TBBBuild.cmake +++ /dev/null @@ -1,197 +0,0 @@ -# Copyright (c) 2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# -# - -# -# Usage: -# include(TBBBuild.cmake) -# tbb_build(ROOT <tbb_root> MAKE_ARGS <arg1> [... <argN>]) -# find_package(TBB <options>) -# - -include(CMakeParseArguments) - -# Save the location of Intel TBB CMake modules here, as it will not be possible to do inside functions, -# see for details: https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_LIST_DIR.html -set(_tbb_cmake_module_path ${CMAKE_CURRENT_LIST_DIR}) - -## -# Builds Intel TBB. -# -# Parameters: -# TBB_ROOT <directory> - path to Intel TBB root directory (with sources); -# MAKE_ARGS <list> - user-defined arguments to be passed to make-tool; -# CONFIG_DIR <variable> - store location of the created TBBConfig if the build was ok, store <variable>-NOTFOUND otherwise. -# -function(tbb_build) - # NOTE: internal function are used to hide them from user. - - ## - # Provides arguments for make-command to build Intel TBB. - # - # Following arguments are provided automatically if they are not defined by user: - # compiler=<value> - # tbb_build_dir=<value> - # tbb_build_prefix=<value> - # -j<n> - # - # Parameters: - # USER_DEFINED_ARGS <list> - list of user-defined arguments; - # RESULT <variable> - resulting list of 'make' arguments. - # - function(tbb_get_make_args) - set(oneValueArgs RESULT) - set(multiValueArgs USER_DEFINED_ARGS) - cmake_parse_arguments(tbb_GMA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - set(result ${tbb_GMA_USER_DEFINED_ARGS}) - - if (NOT tbb_GMA_USER_DEFINED_ARGS MATCHES "compiler=") - # TODO: add other supported compilers. - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(compiler gcc) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set(compiler icc) - if (CMAKE_SYSTEM_NAME MATCHES "Windows") - set(compiler icl) - endif() - elseif (MSVC) - set(compiler cl) - elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(compiler clang) - endif() - - set(result "compiler=${compiler}" ${result}) - endif() - - if (NOT tbb_GMA_USER_DEFINED_ARGS MATCHES "tbb_build_dir=") - set(result "tbb_build_dir=${CMAKE_CURRENT_BINARY_DIR}/tbb_cmake_build" ${result}) - endif() - - if (NOT tbb_GMA_USER_DEFINED_ARGS MATCHES "tbb_build_prefix=") - set(result "tbb_build_prefix=tbb_cmake_build_subdir" ${result}) - endif() - - if (NOT tbb_GMA_USER_DEFINED_ARGS MATCHES "(;|^) *\\-j[0-9]* *(;|$)") - include(ProcessorCount) - ProcessorCount(num_of_cores) - if (NOT num_of_cores EQUAL 0) - set(result "-j${num_of_cores}" ${result}) - endif() - endif() - - if (CMAKE_SYSTEM_NAME MATCHES "Android") - set(result target=android ${result}) - endif() - - set(${tbb_GMA_RESULT} ${result} PARENT_SCOPE) - endfunction() - - ## - # Provides release and debug directories basing on 'make' arguments. - # - # Following 'make' arguments are parsed: tbb_build_dir, tbb_build_prefix - # - # Parameters: - # MAKE_ARGS <list> - 'make' arguments (tbb_build_dir and tbb_build_prefix are required) - # RELEASE_DIR <variable> - store normalized (CMake) path to release directory - # DEBUG_DIR <variable> - store normalized (CMake) path to debug directory - # - function(tbb_get_build_paths_from_make_args) - set(oneValueArgs RELEASE_DIR DEBUG_DIR) - set(multiValueArgs MAKE_ARGS) - cmake_parse_arguments(tbb_GBPFMA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - foreach(arg ${tbb_GBPFMA_MAKE_ARGS}) - if (arg MATCHES "tbb_build_dir=") - string(REPLACE "tbb_build_dir=" "" tbb_build_dir "${arg}") - elseif (arg MATCHES "tbb_build_prefix=") - string(REPLACE "tbb_build_prefix=" "" tbb_build_prefix "${arg}") - endif() - endforeach() - - set(tbb_release_dir "${tbb_build_dir}/${tbb_build_prefix}_release") - set(tbb_debug_dir "${tbb_build_dir}/${tbb_build_prefix}_debug") - - file(TO_CMAKE_PATH "${tbb_release_dir}" tbb_release_dir) - file(TO_CMAKE_PATH "${tbb_debug_dir}" tbb_debug_dir) - - set(${tbb_GBPFMA_RELEASE_DIR} ${tbb_release_dir} PARENT_SCOPE) - set(${tbb_GBPFMA_DEBUG_DIR} ${tbb_debug_dir} PARENT_SCOPE) - endfunction() - - # -------------------- # - # Function entry point # - # -------------------- # - set(oneValueArgs TBB_ROOT CONFIG_DIR) - set(multiValueArgs MAKE_ARGS) - cmake_parse_arguments(tbb_build "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (NOT EXISTS "${tbb_build_TBB_ROOT}/Makefile" OR NOT EXISTS "${tbb_build_TBB_ROOT}/src") - message(STATUS "Intel TBB can not be built: Makefile or src directory was not found in ${tbb_build_TBB_ROOT}") - set(${tbb_build_CONFIG_DIR} ${tbb_build_CONFIG_DIR}-NOTFOUND PARENT_SCOPE) - return() - endif() - - set(make_tool_name make) - if (CMAKE_SYSTEM_NAME MATCHES "Windows") - set(make_tool_name gmake) - elseif (CMAKE_SYSTEM_NAME MATCHES "Android") - set(make_tool_name ndk-build) - endif() - - find_program(TBB_MAKE_TOOL ${make_tool_name} DOC "Make-tool to build Intel TBB.") - mark_as_advanced(TBB_MAKE_TOOL) - - if (NOT TBB_MAKE_TOOL) - message(STATUS "Intel TBB can not be built: required make-tool (${make_tool_name}) was not found") - set(${tbb_build_CONFIG_DIR} ${tbb_build_CONFIG_DIR}-NOTFOUND PARENT_SCOPE) - return() - endif() - - tbb_get_make_args(USER_DEFINED_ARGS ${tbb_build_MAKE_ARGS} RESULT tbb_make_args) - - set(tbb_build_cmd ${TBB_MAKE_TOOL} ${tbb_make_args}) - - string(REPLACE ";" " " tbb_build_cmd_str "${tbb_build_cmd}") - message(STATUS "Building Intel TBB: ${tbb_build_cmd_str}") - execute_process(COMMAND ${tbb_build_cmd} - WORKING_DIRECTORY ${tbb_build_TBB_ROOT} - RESULT_VARIABLE tbb_build_result - ERROR_VARIABLE tbb_build_error_output - OUTPUT_QUIET) - - if (NOT tbb_build_result EQUAL 0) - message(STATUS "Building is unsuccessful (${tbb_build_result}): ${tbb_build_error_output}") - set(${tbb_build_CONFIG_DIR} ${tbb_build_CONFIG_DIR}-NOTFOUND PARENT_SCOPE) - return() - endif() - - tbb_get_build_paths_from_make_args(MAKE_ARGS ${tbb_make_args} - RELEASE_DIR tbb_release_dir - DEBUG_DIR tbb_debug_dir) - - include(${_tbb_cmake_module_path}/TBBMakeConfig.cmake) - tbb_make_config(TBB_ROOT ${tbb_build_TBB_ROOT} - SYSTEM_NAME ${CMAKE_SYSTEM_NAME} - CONFIG_DIR tbb_config_dir - CONFIG_FOR_SOURCE - TBB_RELEASE_DIR ${tbb_release_dir} - TBB_DEBUG_DIR ${tbb_debug_dir}) - - set(${tbb_build_CONFIG_DIR} ${tbb_config_dir} PARENT_SCOPE) -endfunction() diff --git a/cmake/tbb/TBBGet.cmake b/cmake/tbb/TBBGet.cmake deleted file mode 100644 index 4f595d2399913cb1eda1768395bc3bdcc98629b1..0000000000000000000000000000000000000000 --- a/cmake/tbb/TBBGet.cmake +++ /dev/null @@ -1,298 +0,0 @@ -# Copyright (c) 2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# -# - -include(CMakeParseArguments) - -# Save the location of Intel TBB CMake modules here, as it will not be possible to do inside functions, -# see for details: https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_LIST_DIR.html -set(_tbb_cmake_module_path ${CMAKE_CURRENT_LIST_DIR}) - -## -# Downloads file. -# -# Parameters: -# URL <url> - URL to download data from; -# SAVE_AS <filename> - filename there to save downloaded data; -# INFO <string> - text description of content to be downloaded; -# will be printed as message in format is "Downloading <INFO>: <URL>; -# FORCE - option to delete local file from SAVE_AS if it exists; -# -function(_tbb_download_file) - set(options FORCE) - set(oneValueArgs URL RELEASE SAVE_AS INFO) - cmake_parse_arguments(tbb_df "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (tbb_df_FORCE AND EXISTS "${tbb_df_SAVE_AS}") - file(REMOVE ${tbb_df_SAVE_AS}) - endif() - - if (NOT EXISTS "${tbb_df_SAVE_AS}") - set(_show_progress) - if (TBB_DOWNLOADING_PROGRESS) - set(_show_progress SHOW_PROGRESS) - endif() - - message(STATUS "Downloading ${tbb_df_INFO}: ${tbb_df_URL}") - file(DOWNLOAD ${tbb_df_URL} ${tbb_df_SAVE_AS} ${_show_progress} STATUS download_status) - - list(GET download_status 0 download_status_num) - if (NOT download_status_num EQUAL 0) - message(STATUS "Unsuccessful downloading: ${download_status}") - file(REMOVE ${tbb_df_SAVE_AS}) - return() - endif() - else() - message(STATUS "Needed file was found locally ${tbb_df_SAVE_AS}. Remove it if you still want to download a new one") - endif() -endfunction() - -## -# Checks if specified Intel TBB release is available on GitHub. -# -# tbb_check_git_release(<release> <result>) -# Parameters: -# <release_tag> - release to be checked; -# <result> - store result (TRUE/FALSE). -# -function(_tbb_check_git_release_tag _tbb_release_tag _tbb_release_tag_avail) - if (_tbb_release_tag STREQUAL LATEST) - set(${_tbb_release_tag_avail} TRUE PARENT_SCOPE) - return() - endif() - - set(tbb_releases_file "${CMAKE_CURRENT_BINARY_DIR}/tbb_releases.json") - - _tbb_download_file(URL "${tbb_github_api}/releases" - SAVE_AS ${tbb_releases_file} - INFO "information from GitHub about Intel TBB releases" - FORCE) - - if (NOT EXISTS "${tbb_releases_file}") - set(${_tbb_release_tag_avail} FALSE PARENT_SCOPE) - return() - endif() - - file(READ ${tbb_releases_file} tbb_releases) - - string(REPLACE "\"" "" tbb_releases ${tbb_releases}) - string(REGEX MATCHALL "tag_name: *([A-Za-z0-9_\\.]+)" tbb_releases ${tbb_releases}) - - set(_release_available FALSE) - foreach(tbb_rel ${tbb_releases}) - string(REGEX REPLACE "tag_name: *" "" tbb_rel_cut ${tbb_rel}) - list(REMOVE_ITEM tbb_releases ${tbb_rel}) - list(APPEND tbb_releases ${tbb_rel_cut}) - if (_tbb_release_tag STREQUAL tbb_rel_cut) - set(_release_available TRUE) - break() - endif() - endforeach() - - if (NOT _release_available) - string(REPLACE ";" ", " tbb_releases_str "${tbb_releases}") - message(STATUS "Requested release tag ${_tbb_release_tag} is not available. Available Intel TBB release tags: ${tbb_releases_str}") - endif() - - set(${_tbb_release_tag_avail} ${_release_available} PARENT_SCOPE) -endfunction() - -## -# Compares two Intel TBB releases and provides result -# TRUE if the first release is less than the second, FALSE otherwise. -# -# tbb_is_release_less(<rel1> <rel2> <result>) -# -function(_tbb_is_release_less rel1 rel2 result) - # Convert release to numeric representation to compare it using "if" with VERSION_LESS. - string(REGEX REPLACE "[A-Za-z]" "" rel1 "${rel1}") - string(REPLACE "_" "." rel1 "${rel1}") - string(REGEX REPLACE "[A-Za-z]" "" rel2 "${rel2}") - string(REPLACE "_" "." rel2 "${rel2}") - - if (${rel1} VERSION_LESS ${rel2}) - set(${result} TRUE PARENT_SCOPE) - return() - endif() - - set(${result} FALSE PARENT_SCOPE) -endfunction() - -## -# Finds exact URL to download Intel TBB basing on provided parameters. -# -# Usage: -# _tbb_get_url(URL <var_to_save_url> RELEASE_TAG <release_tag|LATEST> OS <os> [SOURCE_CODE]) -# -function(_tbb_get_url) - set(oneValueArgs URL RELEASE_TAG OS) - set(options SOURCE_CODE) - cmake_parse_arguments(tbb_get_url "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - set(tbb_github_api "https://api.github.com/repos/01org/tbb") - - _tbb_check_git_release_tag(${tbb_get_url_RELEASE_TAG} tbb_release_available) - if (NOT tbb_release_available) - set(${tbb_download_FULL_PATH} ${tbb_download_FULL_PATH}-NOTFOUND PARENT_SCOPE) - return() - endif() - - if (tbb_get_url_RELEASE_TAG STREQUAL LATEST) - set(tbb_rel_info_api_url "${tbb_github_api}/releases/latest") - else() - set(tbb_rel_info_api_url "${tbb_github_api}/releases/tags/${tbb_get_url_RELEASE_TAG}") - endif() - - set(tbb_release_info_file "${CMAKE_CURRENT_BINARY_DIR}/tbb_${tbb_get_url_RELEASE_TAG}_info.json") - - _tbb_download_file(URL ${tbb_rel_info_api_url} - SAVE_AS ${tbb_release_info_file} - INFO "information from GitHub about packages for Intel TBB ${tbb_get_url_RELEASE_TAG}" - FORCE) - - if (NOT EXISTS "${tbb_release_info_file}") - set(${tbb_get_url_URL} ${tbb_get_url_URL}-NOTFOUND PARENT_SCOPE) - return() - endif() - - file(STRINGS ${tbb_release_info_file} tbb_release_info) - - if (tbb_get_url_SOURCE_CODE) - # Find name of the latest release to get link to source archive. - if (tbb_get_url_RELEASE_TAG STREQUAL LATEST) - string(REPLACE "\"" "" tbb_release_info ${tbb_release_info}) - string(REGEX REPLACE ".*tag_name: *([A-Za-z0-9_\\.]+).*" "\\1" tbb_get_url_RELEASE_TAG "${tbb_release_info}") - endif() - - set(${tbb_get_url_URL} "https://github.com/01org/tbb/archive/${tbb_get_url_RELEASE_TAG}.tar.gz" PARENT_SCOPE) - else() - if (tbb_get_url_OS MATCHES "Linux") - set(tbb_lib_archive_suffix lin.tgz) - elseif (tbb_get_url_OS MATCHES "Windows") - set(tbb_lib_archive_suffix win.zip) - elseif (tbb_get_url_OS MATCHES "Darwin") - set(tbb_lib_archive_suffix mac.tgz) - - # Since 2017_U4 release archive for Apple has suffix "mac.tgz" instead of "osx.tgz". - if (NOT tbb_get_url_RELEASE_TAG STREQUAL "LATEST") - _tbb_is_release_less(${tbb_get_url_RELEASE_TAG} 2017_U4 release_less) - if (release_less) - set(tbb_lib_archive_suffix osx.tgz) - endif() - endif() - elseif (tbb_get_url_OS MATCHES "Android") - set(tbb_lib_archive_suffix and.tgz) - else() - message(STATUS "Currently prebuilt Intel TBB is not available for your OS (${tbb_get_url_OS})") - set(${tbb_get_url_URL} ${tbb_get_url_URL}-NOTFOUND PARENT_SCOPE) - return() - endif() - - string(REGEX REPLACE ".*(https.*oss_${tbb_lib_archive_suffix}).*" "\\1" tbb_bin_url "${tbb_release_info}") - - set(${tbb_get_url_URL} ${tbb_bin_url} PARENT_SCOPE) - endif() -endfunction() - -function(tbb_get) - set(oneValueArgs RELEASE_TAG SYSTEM_NAME SAVE_TO TBB_ROOT CONFIG_DIR) - set(options SOURCE_CODE) - cmake_parse_arguments(tbb_get "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - set(tbb_os ${CMAKE_SYSTEM_NAME}) - if (tbb_get_SYSTEM_NAME) - set(tbb_os ${tbb_get_SYSTEM_NAME}) - endif() - - set(tbb_release_tag LATEST) - if (tbb_get_RELEASE_TAG) - set(tbb_release_tag ${tbb_get_RELEASE_TAG}) - endif() - - set(tbb_save_to ${CMAKE_CURRENT_BINARY_DIR}/tbb_downloaded) - if (tbb_get_SAVE_TO) - set(tbb_save_to ${tbb_get_SAVE_TO}) - endif() - - if (tbb_get_SOURCE_CODE) - _tbb_get_url(URL tbb_url RELEASE_TAG ${tbb_release_tag} OS ${tbb_os} SOURCE_CODE) - else() - _tbb_get_url(URL tbb_url RELEASE_TAG ${tbb_release_tag} OS ${tbb_os}) - endif() - - if (NOT tbb_url) - message(STATUS "URL to download Intel TBB has not been found") - set(${tbb_get_TBB_ROOT} ${tbb_get_TBB_ROOT}-NOTFOUND PARENT_SCOPE) - return() - endif() - - get_filename_component(filename ${tbb_url} NAME) - set(local_file "${CMAKE_CURRENT_BINARY_DIR}/${filename}") - - _tbb_download_file(URL ${tbb_url} - SAVE_AS ${local_file} - INFO "Intel TBB library") - - if (NOT EXISTS "${local_file}") - set(${tbb_get_TBB_ROOT} ${tbb_get_TBB_ROOT}-NOTFOUND PARENT_SCOPE) - return() - endif() - - get_filename_component(subdir_name ${filename} NAME_WE) - file(MAKE_DIRECTORY ${tbb_save_to}/${subdir_name}) - if (NOT EXISTS "${tbb_save_to}/${subdir_name}") - message(STATUS "${tbb_save_to}/${subdir_name} can not be created") - set(${tbb_get_TBB_ROOT} ${tbb_get_TBB_ROOT}-NOTFOUND PARENT_SCOPE) - return() - endif() - - message(STATUS "Unpacking ${local_file} to ${tbb_save_to}/${subdir_name}") - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${local_file} - WORKING_DIRECTORY ${tbb_save_to}/${subdir_name} - RESULT_VARIABLE unpacking_result) - - if (NOT unpacking_result EQUAL 0) - message(STATUS "Unsuccessful unpacking: ${unpacking_result}") - set(${tbb_get_TBB_ROOT} ${tbb_get_TBB_ROOT}-NOTFOUND PARENT_SCOPE) - return() - endif() - - file(GLOB_RECURSE tbb_h ${tbb_save_to}/${subdir_name}/*/include/tbb/tbb.h) - list(GET tbb_h 0 tbb_h) - - if (NOT EXISTS "${tbb_h}") - message(STATUS "tbb/tbb.h has not been found in the downloaded package") - set(${tbb_get_TBB_ROOT} ${tbb_get_TBB_ROOT}-NOTFOUND PARENT_SCOPE) - return() - endif() - - get_filename_component(tbb_root "${tbb_h}" PATH) - get_filename_component(tbb_root "${tbb_root}" PATH) - get_filename_component(tbb_root "${tbb_root}" PATH) - - if (NOT tbb_get_SOURCE_CODE) - set(tbb_config_dir ${tbb_root}/cmake) - - if (NOT EXISTS "${tbb_config_dir}") - tbb_make_config(TBB_ROOT ${tbb_root} CONFIG_DIR tbb_config_dir) - endif() - - set(${tbb_get_CONFIG_DIR} ${tbb_config_dir} PARENT_SCOPE) - endif() - - set(${tbb_get_TBB_ROOT} ${tbb_root} PARENT_SCOPE) -endfunction() diff --git a/cmake/tbb/TBBMakeConfig.cmake b/cmake/tbb/TBBMakeConfig.cmake deleted file mode 100644 index 6d25db0c94e1357a00f656a03c59a34b1c308f1a..0000000000000000000000000000000000000000 --- a/cmake/tbb/TBBMakeConfig.cmake +++ /dev/null @@ -1,162 +0,0 @@ -# Copyright (c) 2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# -# - -# -# Usage: -# include(TBBMakeConfig.cmake) -# tbb_make_config(TBB_ROOT <tbb_root> SYSTEM_NAME <system_name> CONFIG_DIR <var_to_store_config_dir> [CONFIG_FOR_SOURCE TBB_RELEASE_DIR <tbb_release_dir> TBB_DEBUG_DIR <tbb_debug_dir>]) -# - -include(CMakeParseArguments) - -# Save the location of Intel TBB CMake modules here, as it will not be possible to do inside functions, -# see for details: https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_LIST_DIR.html -set(_tbb_cmake_module_path ${CMAKE_CURRENT_LIST_DIR}) - -function(tbb_make_config) - set(oneValueArgs TBB_ROOT SYSTEM_NAME CONFIG_DIR TBB_RELEASE_DIR TBB_DEBUG_DIR) - set(options CONFIG_FOR_SOURCE) - cmake_parse_arguments(tbb_MK "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - set(tbb_system_name ${CMAKE_SYSTEM_NAME}) - if (tbb_MK_SYSTEM_NAME) - set(tbb_system_name ${tbb_MK_SYSTEM_NAME}) - endif() - - file(MAKE_DIRECTORY ${tbb_MK_TBB_ROOT}/cmake) - - set(TBB_DEFAULT_COMPONENTS tbb tbbmalloc tbbmalloc_proxy) - - if (tbb_MK_CONFIG_FOR_SOURCE) - set(TBB_RELEASE_DIR ${tbb_MK_TBB_RELEASE_DIR}) - set(TBB_DEBUG_DIR ${tbb_MK_TBB_DEBUG_DIR}) - endif() - - if (tbb_system_name STREQUAL "Linux") - set(TBB_SHARED_LIB_DIR "lib") - set(TBB_X32_SUBDIR "ia32") - set(TBB_X64_SUBDIR "intel64") - set(TBB_LIB_PREFIX "lib") - set(TBB_LIB_EXT "so.2") - - # Note: multiline variable - set(TBB_CHOOSE_COMPILER_SUBDIR "if (CMAKE_CXX_COMPILER_LOADED) - set(_tbb_compiler_id \${CMAKE_CXX_COMPILER_ID}) - set(_tbb_compiler_ver \${CMAKE_CXX_COMPILER_VERSION}) -elseif (CMAKE_C_COMPILER_LOADED) - set(_tbb_compiler_id \${CMAKE_C_COMPILER_ID}) - set(_tbb_compiler_ver \${CMAKE_C_COMPILER_VERSION}) -endif() - -# For non-GCC compilers try to find version of system GCC to choose right compiler subdirectory. -if (NOT _tbb_compiler_id STREQUAL \"GNU\") - execute_process(COMMAND gcc --version OUTPUT_VARIABLE _tbb_gcc_ver_output ERROR_QUIET) - string(REGEX REPLACE \".*gcc.*([0-9]+\\\\.[0-9]+)\\\\.[0-9]+.*\" \"\\\\1\" _tbb_compiler_ver \"\${_tbb_gcc_ver_output}\") - if (NOT _tbb_compiler_ver) - message(FATAL_ERROR \"This Intel TBB package is intended to be used only environment with available 'gcc'\") - endif() - unset(_tbb_gcc_ver_output) -endif() - -set(_tbb_compiler_subdir gcc4.1) -foreach (_tbb_gcc_version 4.1 4.4 4.7) - if (NOT _tbb_compiler_ver VERSION_LESS \${_tbb_gcc_version}) - set(_tbb_compiler_subdir gcc\${_tbb_gcc_version}) - endif() -endforeach() - -unset(_tbb_compiler_id) -unset(_tbb_compiler_ver)") - - elseif (tbb_system_name STREQUAL "Windows") - set(TBB_SHARED_LIB_DIR "bin") - set(TBB_X32_SUBDIR "ia32") - set(TBB_X64_SUBDIR "intel64") - set(TBB_LIB_PREFIX "") - set(TBB_LIB_EXT "dll") - - # Note: multiline variable - set(TBB_CHOOSE_COMPILER_SUBDIR "if (NOT MSVC) - message(FATAL_ERROR \"This Intel TBB package is intended to be used only in the project with MSVC\") -endif() - -# Detect the most relevant MSVC subdirectory -set(_tbb_msvc_1700_subdir vc11) -set(_tbb_msvc_1800_subdir vc12) -set(_tbb_msvc_1900_subdir vc14) -set(_tbb_msvc_ver \${MSVC_VERSION}) -if (MSVC_VERSION VERSION_LESS 1700) - message(FATAL_ERROR \"This Intel TBB package is intended to be used only in the project with MSVC version 1700 (vc11) or higher\") -elseif (MSVC_VERSION VERSION_GREATER 1900) - set(_tbb_msvc_ver 1900) -endif() -set(_tbb_compiler_subdir \${_tbb_msvc_\${_tbb_msvc_ver}_subdir}) -unset(_tbb_msvc_1700_subdir) -unset(_tbb_msvc_1800_subdir) -unset(_tbb_msvc_1900_subdir) - -if (WINDOWS_STORE) - set(_tbb_compiler_subdir \${_tbb_compiler_subdir}_ui) -endif()") - - if (tbb_MK_CONFIG_FOR_SOURCE) - set(TBB_IMPLIB_RELEASE "\nIMPORTED_IMPLIB_RELEASE \"${tbb_MK_TBB_RELEASE_DIR}/\${_tbb_component}.lib\"") - set(TBB_IMPLIB_DEBUG "\nIMPORTED_IMPLIB_DEBUG \"${tbb_MK_TBB_DEBUG_DIR}/\${_tbb_component}_debug.lib\"") - else() - # Note: multiline variable - set(TBB_IMPLIB " - IMPORTED_IMPLIB_RELEASE \"\${_tbb_root}/lib/\${_tbb_arch_subdir}/\${_tbb_compiler_subdir}/\${_tbb_component}.lib\" - IMPORTED_IMPLIB_DEBUG \"\${_tbb_root}/lib/\${_tbb_arch_subdir}/\${_tbb_compiler_subdir}/\${_tbb_component}_debug.lib\"") - endif() - - # Note: multiline variable - # tbb/internal/_tbb_windef.h (included via tbb/tbb_stddef.h) does implicit linkage of some .lib files, use a special define to avoid it - set(TBB_COMPILE_DEFINITIONS " - INTERFACE_COMPILE_DEFINITIONS \"__TBB_NO_IMPLICIT_LINKAGE=1\"") - elseif (tbb_system_name STREQUAL "Darwin") - set(TBB_SHARED_LIB_DIR "lib") - set(TBB_X32_SUBDIR ".") - set(TBB_X64_SUBDIR ".") - set(TBB_LIB_PREFIX "lib") - set(TBB_LIB_EXT "dylib") - set(TBB_CHOOSE_COMPILER_SUBDIR "set(_tbb_compiler_subdir .)") - elseif (tbb_system_name STREQUAL "Android") - set(TBB_SHARED_LIB_DIR "lib") - set(TBB_X32_SUBDIR ".") - set(TBB_X64_SUBDIR "x86_64") - set(TBB_LIB_PREFIX "lib") - set(TBB_LIB_EXT "so") - set(TBB_CHOOSE_COMPILER_SUBDIR "set(_tbb_compiler_subdir .)") - endif() - - file(READ "${tbb_MK_TBB_ROOT}/include/tbb/tbb_stddef.h" _tbb_stddef) - string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" _tbb_ver_major "${_tbb_stddef}") - string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" _tbb_ver_minor "${_tbb_stddef}") - string(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" TBB_INTERFACE_VERSION "${_tbb_stddef}") - set(TBB_VERSION "${_tbb_ver_major}.${_tbb_ver_minor}") - - if (tbb_MK_CONFIG_FOR_SOURCE) - set(_tbb_config_template TBBConfigForSource.cmake.in) - else() - set(_tbb_config_template TBBConfig.cmake.in) - endif() - configure_file(${_tbb_cmake_module_path}/templates/${_tbb_config_template} ${tbb_MK_TBB_ROOT}/cmake/TBBConfig.cmake @ONLY) - configure_file(${_tbb_cmake_module_path}/templates/TBBConfigVersion.cmake.in ${tbb_MK_TBB_ROOT}/cmake/TBBConfigVersion.cmake @ONLY) - - set(${tbb_MK_CONFIG_DIR} ${tbb_MK_TBB_ROOT}/cmake PARENT_SCOPE) -endfunction() diff --git a/cmake/tbb/templates/TBBConfig.cmake.in b/cmake/tbb/templates/TBBConfig.cmake.in deleted file mode 100644 index 19bc1fca89b97f8387286899d27a73e1a4a87b3c..0000000000000000000000000000000000000000 --- a/cmake/tbb/templates/TBBConfig.cmake.in +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright (c) 2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# -# - -# TBB_FOUND should not be set explicitly. It is defined automatically by CMake. -# Handling of TBB_VERSION is in TBBConfigVersion.cmake. - -if (NOT TBB_FIND_COMPONENTS) - set(TBB_FIND_COMPONENTS "@TBB_DEFAULT_COMPONENTS@") - foreach (_tbb_component ${TBB_FIND_COMPONENTS}) - set(TBB_FIND_REQUIRED_${_tbb_component} 1) - endforeach() -endif() - -# Add components with internal dependencies: tbbmalloc_proxy -> tbbmalloc -list(FIND TBB_FIND_COMPONENTS tbbmalloc_proxy _tbbmalloc_proxy_ix) -if (NOT _tbbmalloc_proxy_ix EQUAL -1) - list(FIND TBB_FIND_COMPONENTS tbbmalloc _tbbmalloc_ix) - if (_tbbmalloc_ix EQUAL -1) - list(APPEND TBB_FIND_COMPONENTS tbbmalloc) - set(TBB_FIND_REQUIRED_tbbmalloc ${TBB_FIND_REQUIRED_tbbmalloc_proxy}) - endif() -endif() - -set(TBB_INTERFACE_VERSION @TBB_INTERFACE_VERSION@) - -get_filename_component(_tbb_root "${CMAKE_CURRENT_LIST_FILE}" PATH) -get_filename_component(_tbb_root "${_tbb_root}" PATH) - -set(_tbb_x32_subdir @TBB_X32_SUBDIR@) -set(_tbb_x64_subdir @TBB_X64_SUBDIR@) - -if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set(_tbb_arch_subdir ${_tbb_x64_subdir}) -else() - set(_tbb_arch_subdir ${_tbb_x32_subdir}) -endif() - -@TBB_CHOOSE_COMPILER_SUBDIR@ - -get_filename_component(_tbb_lib_path "${_tbb_root}/@TBB_SHARED_LIB_DIR@/${_tbb_arch_subdir}/${_tbb_compiler_subdir}" ABSOLUTE) - -foreach (_tbb_component ${TBB_FIND_COMPONENTS}) - set(_tbb_release_lib "${_tbb_lib_path}/@TBB_LIB_PREFIX@${_tbb_component}.@TBB_LIB_EXT@") - set(_tbb_debug_lib "${_tbb_lib_path}/@TBB_LIB_PREFIX@${_tbb_component}_debug.@TBB_LIB_EXT@") - - if (EXISTS "${_tbb_release_lib}" AND EXISTS "${_tbb_debug_lib}") - add_library(TBB::${_tbb_component} SHARED IMPORTED) - set_target_properties(TBB::${_tbb_component} PROPERTIES - IMPORTED_CONFIGURATIONS "RELEASE;DEBUG" - IMPORTED_LOCATION_RELEASE "${_tbb_release_lib}" - IMPORTED_LOCATION_DEBUG "${_tbb_debug_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${_tbb_root}/include"@TBB_IMPLIB@@TBB_COMPILE_DEFINITIONS@) - - # Add internal dependencies for imported targets: TBB::tbbmalloc_proxy -> TBB::tbbmalloc - if (_tbb_component STREQUAL tbbmalloc_proxy) - set_target_properties(TBB::tbbmalloc_proxy PROPERTIES INTERFACE_LINK_LIBRARIES TBB::tbbmalloc) - endif() - - list(APPEND TBB_IMPORTED_TARGETS TBB::${_tbb_component}) - set(TBB_${_tbb_component}_FOUND 1) - elseif (TBB_FIND_REQUIRED AND TBB_FIND_REQUIRED_${_tbb_component}) - message(FATAL_ERROR "Missed required Intel TBB component: ${_tbb_component}") - endif() -endforeach() - -unset(_tbb_x32_subdir) -unset(_tbb_x64_subdir) -unset(_tbb_arch_subdir) -unset(_tbb_compiler_subdir) -unset(_tbbmalloc_proxy_ix) -unset(_tbbmalloc_ix) -unset(_tbb_lib_path) -unset(_tbb_release_lib) -unset(_tbb_debug_lib) diff --git a/cmake/tbb/templates/TBBConfigForSource.cmake.in b/cmake/tbb/templates/TBBConfigForSource.cmake.in deleted file mode 100644 index e708a9b8f09f9b460ae5f1911deb3c11d0e5e7be..0000000000000000000000000000000000000000 --- a/cmake/tbb/templates/TBBConfigForSource.cmake.in +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (c) 2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# -# - -# TBB_FOUND should not be set explicitly. It is defined automatically by CMake. -# Handling of TBB_VERSION is in TBBConfigVersion.cmake. - -if (NOT TBB_FIND_COMPONENTS) - set(TBB_FIND_COMPONENTS "@TBB_DEFAULT_COMPONENTS@") - foreach (_tbb_component ${TBB_FIND_COMPONENTS}) - set(TBB_FIND_REQUIRED_${_tbb_component} 1) - endforeach() -endif() - -# Add components with internal dependencies: tbbmalloc_proxy -> tbbmalloc -list(FIND TBB_FIND_COMPONENTS tbbmalloc_proxy _tbbmalloc_proxy_ix) -if (NOT _tbbmalloc_proxy_ix EQUAL -1) - list(FIND TBB_FIND_COMPONENTS tbbmalloc _tbbmalloc_ix) - if (_tbbmalloc_ix EQUAL -1) - list(APPEND TBB_FIND_COMPONENTS tbbmalloc) - set(TBB_FIND_REQUIRED_tbbmalloc ${TBB_FIND_REQUIRED_tbbmalloc_proxy}) - endif() -endif() - -set(TBB_INTERFACE_VERSION @TBB_INTERFACE_VERSION@) - -get_filename_component(_tbb_root "${CMAKE_CURRENT_LIST_FILE}" PATH) -get_filename_component(_tbb_root "${_tbb_root}" PATH) - -foreach (_tbb_component ${TBB_FIND_COMPONENTS}) - set(_tbb_release_lib "@TBB_RELEASE_DIR@/@TBB_LIB_PREFIX@${_tbb_component}.@TBB_LIB_EXT@") - set(_tbb_debug_lib "@TBB_DEBUG_DIR@/@TBB_LIB_PREFIX@${_tbb_component}_debug.@TBB_LIB_EXT@") - - if (EXISTS "${_tbb_release_lib}" OR EXISTS "${_tbb_debug_lib}") - add_library(TBB::${_tbb_component} SHARED IMPORTED) - set_target_properties(TBB::${_tbb_component} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_tbb_root}/include"@TBB_COMPILE_DEFINITIONS@) - - - if (EXISTS "${_tbb_release_lib}") - set_target_properties(TBB::${_tbb_component} PROPERTIES - IMPORTED_LOCATION_RELEASE "${_tbb_release_lib}"@TBB_IMPLIB_RELEASE@) - set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) - endif() - - if (EXISTS "${_tbb_debug_lib}") - set_target_properties(TBB::${_tbb_component} PROPERTIES - IMPORTED_LOCATION_DEBUG "${_tbb_debug_lib}"@TBB_IMPLIB_DEBUG@) - set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) - endif() - - # Add internal dependencies for imported targets: TBB::tbbmalloc_proxy -> TBB::tbbmalloc - if (_tbb_component STREQUAL tbbmalloc_proxy) - set_target_properties(TBB::tbbmalloc_proxy PROPERTIES INTERFACE_LINK_LIBRARIES TBB::tbbmalloc) - endif() - - list(APPEND TBB_IMPORTED_TARGETS TBB::${_tbb_component}) - set(TBB_${_tbb_component}_FOUND 1) - elseif (TBB_FIND_REQUIRED AND TBB_FIND_REQUIRED_${_tbb_component}) - message(FATAL_ERROR "Missed required Intel TBB component: ${_tbb_component}") - endif() -endforeach() - -unset(_tbbmalloc_proxy_ix) -unset(_tbbmalloc_ix) -unset(_tbb_lib_path) -unset(_tbb_release_lib) -unset(_tbb_debug_lib) diff --git a/cmake/tbb/templates/TBBConfigVersion.cmake.in b/cmake/tbb/templates/TBBConfigVersion.cmake.in deleted file mode 100644 index 69d16cf09cafe2dd20bf82e7b4e0f194db477a84..0000000000000000000000000000000000000000 --- a/cmake/tbb/templates/TBBConfigVersion.cmake.in +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) 2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# -# - -set(PACKAGE_VERSION @TBB_VERSION@) - -if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) - endif() -endif() diff --git a/tbb b/tbb new file mode 160000 index 0000000000000000000000000000000000000000..a0dc9bf76d0120f917b641ed095360448cabc85b --- /dev/null +++ b/tbb @@ -0,0 +1 @@ +Subproject commit a0dc9bf76d0120f917b641ed095360448cabc85b