build: various cmake fixes (#21902)

* build: various cmake refactors and simplifications

- Add STATUS keyword to message to ensure messages are shown in the
  correct order.
- Remove DEPS_CXX_COMPILER as we don't rely on C++ for any of our
  dependencies.
- Simplify how msgpack and luv configure options are constructed.
- Rely on the default installation for luv instead of manually passing
  configure, build and install commands.
- Simplify return code conditional.

* build: remove CMAKE_OSX_ARCHITECTURES_ALT_SEP workaround

CMAKE_OSX_ARCHITECTURES_ALT_SEP was defined as a workaround to prevent
the shell from interpreting `;`, which CMake uses as a list separator.
However, the same thing can be achieved by instead passing
CMAKE_OSX_ARCHITECTURES as a cache variable instead, which is a more
idiomatic way of achieving the same thing.

* build: define CMAKE_BUILD_TYPE before adding it to BUILD_TYPE_STRING

The problem with the current setup is that CMAKE_BUILD_TYPE is defined
after BUILD_TYPE_STRING. BUILD_TYPE_STRING will then be empty on the
first run, meaning that dependencies are built without a build type.
However, since CMAKE_BUILD_TYPE is a cache variable its value will
persist in subsequent runs. On the second run BUILD_TYPE_STRING will
have the correct value, but it's a different value from the ones the
dependencies were built with. This will force some dependencies to be
built again.

Fixes https://github.com/neovim/neovim/issues/21672.
This commit is contained in:
dundargoc
2023-01-20 23:48:46 +01:00
committed by GitHub
parent c41214c7d4
commit 4c5c6ca800
4 changed files with 27 additions and 56 deletions

View File

@@ -1,23 +1,15 @@
set(MSGPACK_CMAKE_ARGS
-DMSGPACK_BUILD_TESTS=OFF
-DMSGPACK_BUILD_EXAMPLES=OFF
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_ALT_SEP}
"-DCMAKE_C_FLAGS:STRING=-fPIC"
-DCMAKE_GENERATOR=${CMAKE_GENERATOR})
if(MSVC)
set(MSGPACK_CMAKE_ARGS
-DMSGPACK_BUILD_TESTS=OFF
-DMSGPACK_BUILD_EXAMPLES=OFF
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
${BUILD_TYPE_STRING}
# Make sure we use the same generator, otherwise we may
# accidentally end up using different MSVC runtimes
-DCMAKE_GENERATOR=${CMAKE_GENERATOR})
${BUILD_TYPE_STRING})
if(NOT MSVC)
list(APPEND MSGPACK_CMAKE_ARGS
"-DCMAKE_C_FLAGS:STRING=-fPIC")
endif()
if(USE_EXISTING_SRC_DIR)
@@ -29,6 +21,7 @@ ExternalProject_Add(msgpack
DOWNLOAD_NO_PROGRESS TRUE
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/msgpack
CMAKE_ARGS "${MSGPACK_CMAKE_ARGS}"
LIST_SEPARATOR |)
CMAKE_CACHE_ARGS
-DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES})
list(APPEND THIRD_PARTY_DEPS msgpack)