Page MenuHomePhabricator

Pass selected Mac OS X SDK to subprojects
Closed, ResolvedPublic

Description

The Mac OS X SDK is not passed to sub projects during the super build.

Referring to the mail of Matt Clarkson:

Hi there,

please can I request the following addition to SuperBuild.cmake, so that these values get passed to all sub-projects. It enabled me to build MITK (2013.09....ish) using the 10.8 SDK on Mavericks.

Thanks

Matt

if(APPLE)

set(ep_common_args

     -DCMAKE_OSX_ARCHITECTURES:PATH=${CMAKE_OSX_ARCHITECTURES}

     -DCMAKE_OSX_DEPLOYMENT_TARGET:PATH=${CMAKE_OSX_DEPLOYMENT_TARGET}

     -DCMAKE_OSX_SYSROOT:PATH=${CMAKE_OSX_SYSROOT}

     ${ep_common_args}

    )

endif()

And Miklos Espak:

The Boost build command has to be adjusted as well.

macosx-version=${CMAKE_OSX_DEPLOYMENT_TARGET}
macosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}

And this would probably go to the configure command:

--sysroot ${CMAKE_OSX_SYSROOT}

This needs testing, though.

Miklos

Event Timeline

New remote branch pushed: bug-16776-pass-mac-sdk-to-subprojects

Thanks, Andreas!

I found meanwhile that the patch is not complete. You have to add the same OS X options to the MITK external project as well.

The patch that works for me:

diff --git a/SuperBuild.cmake b/SuperBuild.cmake
index 14442f2..6b81cb3 100644

  • a/SuperBuild.cmake

+++ b/SuperBuild.cmake
@@ -177,6 +177,19 @@ set(ep_common_args

-DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS}

)

+
+if(APPLE)
+ set(ARCHITECTURE_ARGS
+ -DCMAKE_OSX_ARCHITECTURES:PATH=${CMAKE_OSX_ARCHITECTURES}
+ -DCMAKE_OSX_DEPLOYMENT_TARGET:PATH=${CMAKE_OSX_DEPLOYMENT_TARGET}
+ -DCMAKE_OSX_SYSROOT:PATH=${CMAKE_OSX_SYSROOT}
+ )
+ set(ep_common_args
+ ${ARCHITECTURE_ARGS}
+ ${ep_common_args}
+ )
+endif()
+

  1. Include external projects foreach(p ${external_projects}) include(CMakeExternals/${p}.cmake)

@@ -368,6 +381,7 @@ ExternalProject_Add(${proj}

  -DQxt_DIR:PATH=${Qxt_DIR}
CMAKE_ARGS
  ${mitk_initial_cache_arg}

+ ${ARCHITECTURE_ARGS}

SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/MITK-build

Boost uses bjam, not cmake, so you need to pass over these option in a different way. The following build command worked for us:

set(_boost_build_cmd ${CMAKE_CURRENT_BINARY_DIR}/${proj}-src/bjam --sysroot=${CMAKE_OSX_SYSROOT} --builddir=${CMAKE_CURRENT_BINARY_DIR}/${proj}-build --prefix=${CMAKE_CURRENT_BINARY_DIR}/${proj}-install ${_boost_toolset} ${_boost_address_model} ${_boost_variant} ${_boost_libs} link=shared,static threading=multi runtime-link=shared toolset=clang cxxflags="-stdlib=libstdc++" linkflags="-stdlib=libstdc++" -q install)

We added --sysroot, toolset, cxxflags and linkflags. The flags are needed so that boost will be linked to the GNU C++ library (like all the other projects), not to the Clang one.

We build Boost as our own external project, so that does not need modification in MITK, but you might want to use a similar fix.

Hi Miklos. Thanks! The branch was not ready to merge yet. I will continue with it tomorrow. I am a bit surprised that you have to add the OSX option separately because the ep_common_args variable should be passed to the external project and hence the option should be set correctly for the build.
Anyway I still have to test it.

Regarding the boost build command: The command indicates that you are building with clang but at the end you wrote you are using the GNU C++. Did you experience any problems with clang on Mavericks? Also I thought on Mavericks with the latest Xcode there is no GNU++ available at all. The g++ and gcc executables in /usr/bin are just symlinks to clang.

The ep_common_args is passed to all the dependent projects that are built as an external project of MITK. That is right.

However, MITK builds itself as an external project as well, and that "ExternalProject_Add" call (in the SuperBuild.cmake) does not contain the ${ep_common_args} line.

I do not know if it is right to put it there, maybe Sascha can tell.

Anyway, the three variables have somehow to be there in that ExternalProject_Add call. It will not work without them, I tried.

About the Boost:

The compiler and the C++ library are two different things. I built MITK with the clang compiler, using the GNU C++ library (libstdc++), instead of the Clang C++ library (libc++). This is the only combination that works at the moment.

There is no GNU C++ compiler on mavericks, the 'g++' command calls the very same compiler as 'clang'.

Several dependencies do not compile with the Clang libraries, like ITK and VTK. These bugs are fixed in newer versions of these libraries, but we cannot upgrade at the moment. (We are using an MITK version from around October.)

New remote branch pushed: bug-16776-mac-sdk-test

[01d65a]: Merge branch 'bug-16776-pass-mac-sdk-to-subprojects'

Merged commits:

2014-01-15 14:54:23 Andreas Fetzer [5cb3b5]
In case of Mac OSX 10.9 use libstdc++


2014-01-14 13:56:26 Andreas Fetzer [d8bd25]
Adapted boost build command


2014-01-14 09:30:12 Andreas Fetzer [4aeb2f]
Also adding OSX_COMMANDS to mitk configure


2014-01-12 13:39:30 Andreas Fetzer [7f3f9a]
CMAKE_OSX variables are now passed to subprojects during superbuild

Hi Miklos,

as you can see I just merged the changes. If you face any more problems please feel free to reopen the bug.