]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: enable crosscompile of boost
authorKefu Chai <kchai@redhat.com>
Sat, 29 Apr 2017 18:01:33 +0000 (02:01 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 29 Apr 2017 18:01:33 +0000 (02:01 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt

index f19fc2c054f690a8c8e8e615c4b279a1c2dce5bf..34d2c93a495c1b29f3835ee6a12df9b7cd7bf3e2 100644 (file)
@@ -548,6 +548,24 @@ else()
   endif()
   list(APPEND b2
     variant=release link=static threading=multi cxxflags=${BOOST_CFLAGS})
+  if(NOT CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL CMAKE_SYSTEM_PROCESSOR)
+    # we are crosscompiling
+    if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
+      set(b2_cc gcc)
+    elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
+      set(b2_cc clang)
+    else()
+      message(SEND_ERROR "unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
+    endif()
+    # edit the config.jam so, b2 will be able to use the specified toolset
+    execute_process(
+      COMMAND
+      sed -i
+      "s|using ${b2_cc} ;|using ${b2_cc} : ${CMAKE_SYSTEM_PROCESSOR} : ${CMAKE_CXX_COMPILER} ;|"
+      ${PROJECT_SOURCE_DIR}/src/boost/project-config.jam)
+    # use ${CMAKE_SYSTEM_PROCESSOR} as the version identifier of compiler
+    list(APPEND b2 toolset=${b2_cc}-${CMAKE_SYSTEM_PROCESSOR})
+  endif()
   # 2. install headers
   execute_process(COMMAND
     ${b2}