From 73bbbdef83c122f64b651ed257d92ad1f66cf93f Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Mon, 26 Oct 2020 02:25:42 +0100 Subject: [PATCH] Travis: include libomp in macOS .app --- .travis/build-macos.sh | 6 ------ .travis/install-macos.sh | 2 +- CMakeLists.txt | 22 +++------------------- src/CMakeLists.txt | 7 ++++++- 4 files changed, 10 insertions(+), 27 deletions(-) diff --git a/.travis/build-macos.sh b/.travis/build-macos.sh index 48623c11..bb4c1e0c 100755 --- a/.travis/build-macos.sh +++ b/.travis/build-macos.sh @@ -4,12 +4,6 @@ mkdir build || true cd build OSX_TARGET="10.9" -LLVM_PREFIX=$(brew --prefix llvm@9) -export CC="${LLVM_PREFIX}/bin/clang" -export CXX="${CC}++" -export LDFLAGS="-L${LLVM_PREFIX}/lib -Wl,-rpath,${LLVM_PREFIX}/lib" \ -export CFLAGS="-I${LLVM_PREFIX}/include" -export CPPFLAGS="-I${LLVM_PREFIX}/include" if [ "$1" = "release" ]; then BUILD_TYPE=RelWithDebInfo diff --git a/.travis/install-macos.sh b/.travis/install-macos.sh index d4817455..457dd5d4 100755 --- a/.travis/install-macos.sh +++ b/.travis/install-macos.sh @@ -1,4 +1,4 @@ #!/bin/sh -xe -brew install llvm@9 +brew install libomp git submodule update --init \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 712c0f23..ad23d983 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,27 +115,11 @@ if(ENABLE_LTO) endif() if(ENABLE_OPENMP) - if(APPLE) - # OpenMP does not work with the default Apple llvm/clang++ - # Install a more recent version using Homebrew (version 11.0.0 which is the next available tag on homebrew at this time crashed): - # "brew install llvm@9" - # and set the right compiler flags using: - # LLVM_PREFIX=$(brew --prefix llvm@9) - # export CC="${LLVM_PREFIX}/bin/clang" - # export CXX="${CC}++" - # export LDFLAGS="-L${LLVM_PREFIX}/lib -Wl,-rpath,${LLVM_PREFIX}/lib" \ - # export CFLAGS="-I${LLVM_PREFIX}/include" - # export CPPFLAGS="-I${LLVM_PREFIX}/include" - set(OpenMP_CXX_FLAGS "-fopenmp=libomp") + find_package( OpenMP REQUIRED ) + include(FindOpenMP) + if(OPENMP_FOUND) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") message(STATUS "found OpenMP, compiling with flags: " ${OpenMP_CXX_FLAGS} ) - else() - find_package( OpenMP REQUIRED ) - include(FindOpenMP) - if(OPENMP_FOUND) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - message(STATUS "found OpenMP, compiling with flags: " ${OpenMP_CXX_FLAGS} ) - endif() endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fd8359f6..1a46e246 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -404,10 +404,15 @@ endif() if(APPLE) set(bundle SolveSpace) set(bundle_bin ${EXECUTABLE_OUTPUT_PATH}/${bundle}.app/Contents/MacOS) - + set(bundle_resources ${EXECUTABLE_OUTPUT_PATH}/${bundle}.app/Contents/Resources/lib) + execute_process( + COMMAND mkdir -p ${bundle_resources} + COMMAND cp -p /usr/local/opt/libomp/lib/libomp.dylib ${bundle_resources}/libomp.dylib + ) add_custom_command(TARGET solvespace POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${bundle_bin} COMMAND ${CMAKE_COMMAND} -E copy $ ${bundle_bin} + COMMAND install_name_tool -change /usr/local/opt/libomp/lib/libomp.dylib "@executable_path/../Resources/lib/libomp.dylib" ${bundle_bin}/${bundle} COMMENT "Bundling executable solvespace-cli" VERBATIM) endif()