Skip to content

Commit

Permalink
Use CMAKE_xx_COMPILER when building external dependencies (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Oct 4, 2019
1 parent b69554b commit af01eab
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ set(RT_BINARY_DIR ${PROJECT_BINARY_DIR}/dyninstAPI_RT)

set (CMAKE_MODULE_PATH "${DYNINST_ROOT}/cmake" "${DYNINST_ROOT}/cmake/Modules" ${CMAKE_MODULE_PATH})

# This needs to be done first to set the global compiler flags
include(shared)

find_package(ThreadDB)
find_package(Threads)
include(Boost)
include(ThreadingBuildingBlocks)
include(ElfUtils)
include(LibIberty)
include (${DYNINST_ROOT}/cmake/shared.cmake)

configure_file(cmake/version.h.in common/h/dyninstversion.h)
include_directories(${PROJECT_BINARY_DIR})
Expand Down
2 changes: 1 addition & 1 deletion cmake/Boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ else()
PREFIX ${CMAKE_BINARY_DIR}/boost
URL http://downloads.sourceforge.net/project/boost/boost/${_boost_download_version}/boost_${_boost_download_filename}.zip
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ${BOOST_BOOTSTRAP} --prefix=${Boost_ROOT_DIR} --with-libraries=${_boost_lib_names}
CONFIGURE_COMMAND CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ${BOOST_BOOTSTRAP} --prefix=${Boost_ROOT_DIR} --with-libraries=${_boost_lib_names}
BUILD_COMMAND ${BOOST_BUILD} ${BOOST_ARGS} install
INSTALL_COMMAND ""
)
Expand Down
5 changes: 5 additions & 0 deletions cmake/ElfUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ else()
message(STATUS "${ElfUtils_ERROR_REASON}")
message( STATUS "Attempting to build elfutils(${_elfutils_download_version}) as external project")

if(NOT (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR NOT (${CMAKE_C_COMPILER_ID} STREQUAL "GNU"))
message(FATAL_ERROR "ElfUtils will only build with the GNU compiler")
endif()

include(ExternalProject)
externalproject_add(
ElfUtils
Expand All @@ -107,6 +111,7 @@ else()
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND
CFLAGS=-g
CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER}
<SOURCE_DIR>/configure
--enable-install-elfh
--prefix=${CMAKE_INSTALL_PREFIX}
Expand Down
1 change: 1 addition & 0 deletions cmake/LibIberty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ else()
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND
CFLAGS=-fPIC
CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER}
<SOURCE_DIR>/configure --prefix=${CMAKE_BINARY_DIR}/binutils
BUILD_COMMAND make
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib/libiberty
Expand Down
17 changes: 17 additions & 0 deletions cmake/ThreadingBuildingBlocks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ else()
message(FATAL_ERROR "Building TBB from source is not supported on this platform")
endif()

if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
if(${_tbb_download_version} VERSION_LESS "2019.7")
message(FATAL_ERROR "Building TBB from source with clang requires TBB 2019.7 or newer")
endif()
endif()

# Forcibly update the cache variables
set(TBB_ROOT_DIR ${CMAKE_INSTALL_PREFIX} CACHE PATH "TBB root directory" FORCE)
set(TBB_INCLUDE_DIRS ${TBB_ROOT_DIR}/include CACHE PATH "TBB include directory" FORCE)
Expand Down Expand Up @@ -143,17 +149,28 @@ else()

include(ExternalProject)
set(_tbb_prefix_dir ${CMAKE_BINARY_DIR}/tbb)

# Set the compiler for TBB
# It assumes gcc and tests for Intel, so clang is the only
# one that needs special treatment.
set(_tbb_compiler "")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(_tbb_compiler "clang")
endif()

ExternalProject_Add(
TBB
PREFIX ${_tbb_prefix_dir}
URL https://github.com/01org/tbb/archive/${_tbb_ver_major}_U${_tbb_ver_minor}.tar.gz
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ""
BUILD_COMMAND
CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER}
$(MAKE) -C src
${_tbb_components_cfg}
tbb_build_dir=${_tbb_prefix_dir}/src
tbb_build_prefix=tbb
compiler=${_tbb_compiler}
INSTALL_COMMAND
${CMAKE_COMMAND}
-DLIBDIR=${TBB_LIBRARY_DIRS}
Expand Down

0 comments on commit af01eab

Please sign in to comment.