Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No /usr/include on macOS Mojave #4681

Closed
slicerbot opened this issue Mar 13, 2020 · 7 comments · Fixed by #4857 or #4883
Closed

No /usr/include on macOS Mojave #4681

slicerbot opened this issue Mar 13, 2020 · 7 comments · Fixed by #4857 or #4883
Assignees
Milestone

Comments

@slicerbot
Copy link
Collaborator

This issue was created automatically from an original Mantis Issue. Further discussion may take place here.

@slicerbot slicerbot added this to the Slicer 4.11.0 milestone Mar 13, 2020
@pieper
Copy link
Member

pieper commented Mar 26, 2020

@Slicer/slicer-developer does anyone have an idea how best to fix this? To me this seems like something to fix at the CMake level, but I guess we could just set the environment variable as part of our build.

@ihnorton
Copy link
Member

Update this to use/require CMAKE_OSX_SYSROOT instead of CMAKE_OSX_DEPLOYMENT_TARGET? Not clear to me if ExternalProject_Add automatically passes that down to the sub-project (it is not currently passed through by Slicer AFAICT).

@jcfr
Copy link
Member

jcfr commented Mar 26, 2020

Since:

  • numpy is now installed from a wheel, the numpy build problem reported in the original is obselete.
  • this issue affect only non CMake project. Indeed, having CMAKE_OSX_SYSROOT set is sufficient for CMake project.

Could you test the following patch:

diff --git a/CMake/ExternalProjectForNonCMakeProject.cmake b/CMake/ExternalProjectForNonCMakeProject.cmake
index efafbdfa75..a316cb30bd 100644
--- a/CMake/ExternalProjectForNonCMakeProject.cmake
+++ b/CMake/ExternalProjectForNonCMakeProject.cmake
@@ -215,6 +215,10 @@ if(APPLE)
   endif()
   set(CMAKE_OSX_FLAGS \"\${osx_arch_flags} \${osx_version_flag} \${osx_sysroot}\")
 
+  if(NOT DEFINED ENV{SDKROOT})
+    set(ENV{SDKROOT} \"\${CMAKE_OSX_SYSROOT}\")
+  endif()
+
   _ep_var_append(_ep_CFLAGS \"\${CMAKE_OSX_FLAGS}\")
   _ep_var_append(_ep_CXXFLAGS \"\${CMAKE_OSX_FLAGS}\")
   _ep_var_append(_ep_LDFLAGS \"\${CMAKE_OSX_FLAGS}\")

@pieper Based on your feedback, I will then submit a PR.

@pieper
Copy link
Member

pieper commented Apr 20, 2020

@jcfr Just tried applying that patch but it didn't solve the problem. Probably it sets the environment of the wrong process.

It seems like we need to add the variable in OpenSSL_Env.cmake. Is that generated in our SuperBuild or somewhere in CMake?

hjmjohnson added a commit to hjmjohnson/Slicer that referenced this issue Apr 21, 2020
CMake computes the value of the -isysroot flag for cmake builds.
OpenSSL does not have a mechanism for setting this directly, so
using an environmental variable allows the compiler to pick
up the correct SDKROOT path.

Allow the SDKROOT to be found on mac when building OpenSSL.
This is needed to find standard header files and avoid errors like

```
 ./cryptlib.h:62:11: fatal error: 'stdlib.h' file not found
 # include <stdlib.h>
```

Related to Slicer#4681
@jcfr
Copy link
Member

jcfr commented Apr 21, 2020

@pieper Thanks for testing

@hjmjohnson Thanks for working on a patch (for reference #4857)

It seems like we need to add the variable in OpenSSL_Env.cmake. Is that generated in our SuperBuild or somewhere in CMake?

Yes, and the proposed patch was intended to have the value set in that script. The problem was that the build command is not using a CMake wrapper script (and not including OpenSSL_Env.cmake

jcfr pushed a commit to hjmjohnson/Slicer that referenced this issue Apr 21, 2020
CMake computes the value of the -isysroot flag for cmake builds.
OpenSSL does not have a mechanism for setting this directly, so
using an environmental variable allows the compiler to pick
up the correct SDKROOT path.

Allow the SDKROOT to be found on mac when building OpenSSL.
This is needed to find standard header files and avoid errors like

```
 ./cryptlib.h:62:11: fatal error: 'stdlib.h' file not found
 # include <stdlib.h>
```

Related to Slicer#4681
jcfr pushed a commit that referenced this issue Apr 21, 2020
CMake computes the value of the -isysroot flag for cmake builds.
OpenSSL does not have a mechanism for setting this directly, so
using an environmental variable allows the compiler to pick
up the correct SDKROOT path.

Allow the SDKROOT to be found on mac when building OpenSSL.
This is needed to find standard header files and avoid errors like

```
 ./cryptlib.h:62:11: fatal error: 'stdlib.h' file not found
 # include <stdlib.h>
```

Related to #4681
@jcfr jcfr linked a pull request Apr 23, 2020 that will close this issue
jcfr added a commit to jcfr/Slicer that referenced this issue Apr 23, 2020
This commit fixes a regression introduced in  ddeb0a3 (COMP: Fix
OpenSSL build on Mac 10.15 XCode 11.4.1 (Slicer#4857)) originally intended
to fix issue Slicer#4681

Setting the SDKROOT environment variable worked as expected on a regular
developer build but failed on a dashboard build where the invocation of
"make" is wrapped using a "launcher" [1]

This commit addresses the issue by writing a CMake script that will set
the environment and then invoke make.

Last, since  file descriptors expect by the make jobserver are not kept
open by the CMake process, the build script explicitly unset MAKEFLAGS
to avoid "warning: -jN forced in submake: disabling jobserver mode."
For more details, see [2]

[1] https://cmake.org/cmake/help/latest/manual/ctest.1.html#ctest-build-step
[2] https://stackoverflow.com/questions/29910944/is-it-possible-to-pass-through-gnu-make-jobserver-environment-to-a-submake-ser
jcfr added a commit that referenced this issue Apr 23, 2020
This commit fixes a regression introduced in  ddeb0a3 (COMP: Fix
OpenSSL build on Mac 10.15 XCode 11.4.1 (#4857)) originally intended
to fix issue #4681

Setting the SDKROOT environment variable worked as expected on a regular
developer build but failed on a dashboard build where the invocation of
"make" is wrapped using a "launcher" [1]

This commit addresses the issue by writing a CMake script that will set
the environment and then invoke make.

Last, since  file descriptors expect by the make jobserver are not kept
open by the CMake process, the build script explicitly unset MAKEFLAGS
to avoid "warning: -jN forced in submake: disabling jobserver mode."
For more details, see [2]

[1] https://cmake.org/cmake/help/latest/manual/ctest.1.html#ctest-build-step
[2] https://stackoverflow.com/questions/29910944/is-it-possible-to-pass-through-gnu-make-jobserver-environment-to-a-submake-ser
@jamesobutler
Copy link
Contributor

Can this issue be closed? Is there any work that still needs to be done following all the referenced commits and PRs?

@pieper
Copy link
Member

pieper commented Jun 5, 2020

Yes, it seems to be working now. I no longer need to specify the path on the command line.

On mac I currently configure with the script below.

buildType=Debug
qtVersion=5.14

cmake \
	-DCMAKE_BUILD_TYPE:STRING=${buildType} \
	-DQt5_VERSION:STRING=${qtVersion} \
	-DSlicer_REQUIRED_QT_VERSION:STRING=${qtVersion} \
	-DQt5_DIR:PATH=/usr/local/opt/qt5/lib/cmake/Qt5 \
	-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.14 \
	/Users/pieper/slicer/latest/Slicer

@pieper pieper closed this as completed Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment