Skip to content

Commit

Permalink
build(xcode.mk): set default macOS build enviroment variables
Browse files Browse the repository at this point in the history
set default values for envvars SDKROOT, MACOSX_DEPLOYMENT_TARGET if not set.
set CMAKE_OSX_ARCHITECTURES if building universal macOS binary.
these variables are used transparently in `make xcode/thirdparty`.
  • Loading branch information
kuoruan authored and lotem committed Jan 15, 2021
1 parent bb8c263 commit 99b0033
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
7 changes: 0 additions & 7 deletions thirdparty.mk
Expand Up @@ -33,7 +33,6 @@ capnproto:
-DBUILD_TESTING:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(THIRD_PARTY_DIR)" \
$(CMAKE_OSX_ARCHS) \
&& cmake --build $(build) --target install

glog:
Expand All @@ -43,7 +42,6 @@ glog:
-DWITH_GFLAGS:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(THIRD_PARTY_DIR)" \
$(CMAKE_OSX_ARCHS) \
&& cmake --build $(build) --target install

gtest:
Expand All @@ -52,7 +50,6 @@ gtest:
-DBUILD_GMOCK:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(THIRD_PARTY_DIR)" \
$(CMAKE_OSX_ARCHS) \
&& cmake --build $(build) --target install

leveldb:
Expand All @@ -62,15 +59,13 @@ leveldb:
-DLEVELDB_BUILD_TESTS:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(THIRD_PARTY_DIR)" \
$(CMAKE_OSX_ARCHS) \
&& cmake --build $(build) --target install

marisa:
cd $(SRC_DIR)/marisa-trie; \
cmake $(SRC_DIR) -B$(build) \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(THIRD_PARTY_DIR)" \
$(CMAKE_OSX_ARCHS) \
&& cmake --build $(build) --target install

opencc:
Expand All @@ -79,7 +74,6 @@ opencc:
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(THIRD_PARTY_DIR)" \
$(CMAKE_OSX_ARCHS) \
&& cmake --build $(build) --target install

yaml-cpp:
Expand All @@ -90,5 +84,4 @@ yaml-cpp:
-DYAML_CPP_BUILD_TOOLS:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(THIRD_PARTY_DIR)" \
$(CMAKE_OSX_ARCHS) \
&& cmake --build $(build) --target install
15 changes: 10 additions & 5 deletions xcode.mk
Expand Up @@ -7,8 +7,15 @@ CMAKE_BOOST_OPTIONS = -DBoost_NO_BOOST_CMAKE=TRUE \
-DBOOST_ROOT="$(BOOST_ROOT)"
endif

# https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html
export SDKROOT ?= $(shell xcrun --sdk macosx --show-sdk-path)

# https://cmake.org/cmake/help/latest/envvar/MACOSX_DEPLOYMENT_TARGET.html
export MACOSX_DEPLOYMENT_TARGET ?= 10.9

ifdef BUILD_UNIVERSAL
export CMAKE_OSX_ARCHS = -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
# https://cmake.org/cmake/help/latest/envvar/CMAKE_OSX_ARCHITECTURES.html
export CMAKE_OSX_ARCHITECTURES = arm64;x86_64
endif

ICU_PREFIX = $(shell brew --prefix)/opt/icu4c
Expand All @@ -26,8 +33,7 @@ release:
-DBUILD_STATIC=ON \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_INSTALL_PREFIX="$(RIME_DIST_DIR)" \
$(CMAKE_BOOST_OPTIONS) \
$(CMAKE_OSX_ARCHS)
$(CMAKE_BOOST_OPTIONS)
cmake --build $(build) --config Release

release-with-icu:
Expand All @@ -37,8 +43,7 @@ release-with-icu:
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_INSTALL_PREFIX="$(RIME_DIST_DIR)" \
-DCMAKE_PREFIX_PATH="$(ICU_PREFIX)" \
$(CMAKE_BOOST_OPTIONS) \
$(CMAKE_OSX_ARCHS)
$(CMAKE_BOOST_OPTIONS)
cmake --build $(build) --config Release

debug:
Expand Down

0 comments on commit 99b0033

Please sign in to comment.