Skip to content

Commit

Permalink
macOS: update linking (#1288)
Browse files Browse the repository at this point in the history
* macOS: update linking

* fix

* minimize diff

* minimize diff

* rm gtest_main
  • Loading branch information
MaxRayskiy authored Jun 5, 2023
1 parent cfc8836 commit da584c2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ IF(APPLE)
LINK_DIRECTORIES(${HOMEBREW_PREFIX}/lib)
set(CPPFLAGS "-I${HOMEBREW_PREFIX}/opt/llvm/include -I${HOMEBREW_PREFIX}/include")
set(LDFLAGS "-L${HOMEBREW_PREFIX}/opt/llvm/lib -Wl,-rpath,${HOMEBREW_PREFIX}/opt/llvm/lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -std=c++20-stdlib=libc++ -undefined dynamic_lookup -framework Cocoa -framework IOKit") # https://github.com/pybind/pybind11/issues/382
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -std=c++20-stdlib=libc++ -framework Cocoa -framework IOKit") # https://github.com/pybind/pybind11/issues/382

set(BUILD_SHARED_LIBS ON)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib")
ELSE()
# uncomment to print compile time of each translation unit,
# such print format is selected to simplify load in Excel with fields (user time, system time, command) subdivision by commas
Expand Down Expand Up @@ -78,6 +81,10 @@ IF(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/..;@loader_path/../lib;@loader_path/../lib/lib;@loader_path/meshlib;${THIRDPARTY_LIB_DIR};${CMAKE_BINARY_DIR}/bin")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(MR_PLATFORM "APPLE_${CMAKE_HOST_SYSTEM_PROCESSOR}")

set(GTest_DIR ${THIRDPARTY_LIB_DIR}/cmake/GTest)
find_package(GTest REQUIRED CONFIG)
include_directories(${GTEST_INCLUDE_DIRS})
ELSE()
# set platform dependent flags
file(STRINGS /etc/os-release distro REGEX "^NAME=")
Expand Down
1 change: 0 additions & 1 deletion requirements/macos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ cpr
fmt
gdcm
glfw
googletest
gtkmm3
hidapi
ilmbase
Expand Down
10 changes: 5 additions & 5 deletions source/MRMesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ IF(APPLE OR MR_EMSCRIPTEN)
#include_directories(/opt/homebrew/opt/jpeg-turbo/include)
#link_directories(/opt/homebrew/opt/jpeg-turbo/lib)

IF (NOT MR_EMSCRIPTEN)
find_library(COCOA_LIBRARY Cocoa ONLY)
IF (APPLE)
find_library(COCOA_LIBRARY Cocoa ONLY)
target_compile_definitions(${PROJECT_NAME} PRIVATE _GNU_SOURCE)
target_link_libraries(${PROJECT_NAME} PRIVATE
spdlog
gtest gtest_main
GTest::gtest
zip
pthread
Boost::boost
Expand All @@ -161,7 +161,7 @@ IF(APPLE OR MR_EMSCRIPTEN)
)
ELSE()
target_link_libraries(${PROJECT_NAME} PRIVATE
gtest gtest_main
gtest
zip
freetype
pthread
Expand All @@ -177,7 +177,7 @@ ELSE()
fmt
spdlog
tinyxml2
gtest gtest_main
gtest
zip
pthread
Boost::boost
Expand Down
4 changes: 3 additions & 1 deletion source/MRTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ IF(MR_EMSCRIPTEN)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --emrun")
ENDIF()

IF(NOT ${MR_FEDORA} AND NOT ${MR_UBUNTU22} AND NOT ${MR_EMSCRIPTEN})
IF(APPLE)
target_link_libraries(${PROJECT_NAME} PRIVATE
MRMesh
MRViewer
fmt
GTest::gtest
spdlog
mrmeshpy
)
Expand Down
1 change: 1 addition & 0 deletions source/MRViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ IF(APPLE)
target_compile_definitions(${PROJECT_NAME} PRIVATE _GNU_SOURCE)
target_link_libraries(${PROJECT_NAME} PRIVATE
MRMesh
GTest::gtest
fmt
tbb
OpenVDB
Expand Down
2 changes: 2 additions & 0 deletions thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ ELSE()
include_directories(${FREETYPE_INCLUDE_DIRS})
IF(APPLE)
target_link_libraries(imgui PRIVATE ${FREETYPE_LIBRARIES} glfw)
set(INSTALL_GTEST ON)
add_subdirectory(./googletest)
ELSE()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")
ENDIF()
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/googletest
Submodule googletest updated 237 files

0 comments on commit da584c2

Please sign in to comment.