[vlc-commits] [Git][videolan/vlc][master] 3 commits: contrib: glslang: add default CXXFLAGS when add a value
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sat Oct 1 16:46:08 UTC 2022
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
52fa38eb by Steve Lhomme at 2022-10-01T15:10:16+00:00
contrib: glslang: add default CXXFLAGS when add a value
- - - - -
637b5774 by Steve Lhomme at 2022-10-01T15:10:16+00:00
contrib: disable test building for all targets
BUILD_TESTING is an option automatically used by CTest and recognized by all
projects that have some CMake-based tests
- - - - -
a6dcec33 by Steve Lhomme at 2022-10-01T15:10:16+00:00
contrib: generate the CMake toolchain file with a script
So when we update the script and the toolchain.cmake file should be modified
it's automatically updated.
- - - - -
4 changed files:
- contrib/src/flac/rules.mak
- + contrib/src/gen-cmake-toolchain.py
- contrib/src/glslang/rules.mak
- contrib/src/main.mak
Changes:
=====================================
contrib/src/flac/rules.mak
=====================================
@@ -26,7 +26,6 @@ endif
$(MOVE)
FLAC_CONF = \
- -DBUILD_TESTING=OFF \
-DINSTALL_MANPAGES=OFF \
-DBUILD_CXXLIBS=OFF \
-DBUILD_EXAMPLES=OFF \
=====================================
contrib/src/gen-cmake-toolchain.py
=====================================
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+import os
+import argparse
+
+# Argument parsing
+parser = argparse.ArgumentParser(
+ description="Generate a CMake crossfile based on environment variables")
+parser.add_argument('file', type=argparse.FileType('w', encoding='UTF-8'),
+ help="output file")
+args = parser.parse_args()
+
+# Helper to add env variable value to crossfile
+def _add_environ_val(meson_key, env_key):
+ env_value = os.environ.get(env_key)
+ if env_value != None:
+ if " " in env_value:
+ args.file.write("set({} \"{}\")\n".format(meson_key, env_value))
+ else:
+ args.file.write("set({} {})\n".format(meson_key, env_value))
+
+def _add_environ_val_not_empty(meson_key, env_key):
+ env_value = os.environ.get(env_key)
+ if env_value != None and env_value != '':
+ args.file.write("set({} {})\n".format(meson_key, env_value))
+
+
+# Generate meson crossfile
+args.file.write("# CMake toolchain automatically generated by contrib makefile\n")
+
+# Binaries section
+_add_environ_val('CMAKE_BUILD_TYPE', 'BUILD_TYPE')
+_add_environ_val('CMAKE_SYSTEM_PROCESSOR', 'HOST_ARCH')
+_add_environ_val_not_empty('CMAKE_SYSTEM_NAME', 'SYSTEM_NAME')
+_add_environ_val('CMAKE_RC_COMPILER', 'RC_COMPILER')
+_add_environ_val('CMAKE_RANLIB', 'RANLIB')
+_add_environ_val('CMAKE_AR', 'AR')
+
+_add_environ_val('CMAKE_OSX_SYSROOT', 'OSX_SYSROOT')
+
+# we should not have to set this
+_add_environ_val('_CMAKE_TOOLCHAIN_PREFIX', 'TOOLCHAIN_PREFIX')
+
+_add_environ_val('CMAKE_C_COMPILER', 'CC')
+_add_environ_val('CMAKE_CXX_COMPILER', 'CXX')
+
+_add_environ_val('CMAKE_C_SYSROOT_FLAG', 'C_SYSROOT_FLAG')
+_add_environ_val('CMAKE_CXX_SYSROOT_FLAG', 'CXX_SYSROOT_FLAG')
+
+
+_add_environ_val('CMAKE_FIND_ROOT_PATH', 'PREFIX')
+
+_add_environ_val('CMAKE_FIND_ROOT_PATH', 'FIND_ROOT_PATH')
+args.file.write("set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n")
+_add_environ_val('CMAKE_FIND_ROOT_PATH_MODE_LIBRARY', 'PATH_MODE_LIBRARY')
+_add_environ_val('CMAKE_FIND_ROOT_PATH_MODE_INCLUDE', 'PATH_MODE_INCLUDE')
+
+# final includes
+env_value = os.environ.get('EXTRA_INCLUDE')
+if env_value != None and env_value != '':
+ args.file.write("include({})\n".format(env_value))
+
=====================================
contrib/src/glslang/rules.mak
=====================================
@@ -31,7 +31,7 @@ GLSLANG_CONF := -DENABLE_GLSLANG_BINARIES=OFF -DENABLE_CTEST=OFF
.glslang: glslang toolchain.cmake
$(CMAKECLEAN)
- $(HOSTVARS_PIC) CXXFLAGS="-DYYDEBUG=0" $(CMAKE) $(GLSLANG_CONF)
+ $(HOSTVARS_PIC) CXXFLAGS="$(CXXFLAGS) -DYYDEBUG=0" $(CMAKE) $(GLSLANG_CONF)
+$(CMAKEBUILD)
+$(CMAKEBUILD) --target install
touch $@
=====================================
contrib/src/main.mak
=====================================
@@ -459,7 +459,8 @@ CMAKE = cmake -S $< -DCMAKE_TOOLCHAIN_FILE=$(abspath toolchain.cmake) \
-B $(BUILD_DIR) \
-DCMAKE_INSTALL_PREFIX:STRING=$(PREFIX) \
-DBUILD_SHARED_LIBS:BOOL=OFF \
- -DCMAKE_INSTALL_LIBDIR:STRING=lib
+ -DCMAKE_INSTALL_LIBDIR:STRING=lib \
+ -DBUILD_TESTING:BOOL=OFF
ifdef HAVE_WIN32
CMAKE += -DCMAKE_DEBUG_POSTFIX:STRING=
endif
@@ -658,59 +659,48 @@ CFLAGS += -DANDROID_NATIVE_API_LEVEL=$(ANDROID_API)
endif
# CMake toolchain
-toolchain.cmake:
- $(RM) $@
+CMAKE_TOOLCHAIN_ENV := $(HOSTTOOLS) HOST_ARCH="$(ARCH)" SYSTEM_NAME="$(CMAKE_SYSTEM_NAME)"
ifndef WITH_OPTIMIZATION
- echo "set(CMAKE_BUILD_TYPE Debug)" >> $@
+ CMAKE_TOOLCHAIN_ENV += BUILD_TYPE=Debug
else
- echo "set(CMAKE_BUILD_TYPE RelWithDebInfo)" >> $@
+ CMAKE_TOOLCHAIN_ENV += BUILD_TYPE=RelWithDebInfo
endif
- echo "set(CMAKE_SYSTEM_PROCESSOR $(ARCH))" >> $@
- if test -n "$(CMAKE_SYSTEM_NAME)"; then \
- echo "set(CMAKE_SYSTEM_NAME $(CMAKE_SYSTEM_NAME))" >> $@; \
- fi;
ifdef HAVE_WIN32
ifdef HAVE_CROSS_COMPILE
- echo "set(CMAKE_RC_COMPILER $(WINDRES))" >> $@
+ CMAKE_TOOLCHAIN_ENV += RC_COMPILER="$(WINDRES)"
endif
endif
ifdef HAVE_DARWIN_OS
- echo "set(CMAKE_C_FLAGS \"$(CFLAGS)\")" >> $@
- echo "set(CMAKE_CXX_FLAGS \"$(CXXFLAGS)\")" >> $@
- echo "set(CMAKE_LD_FLAGS \"$(LDFLAGS)\")" >> $@
ifdef HAVE_IOS
- echo "set(CMAKE_OSX_SYSROOT $(IOS_SDK))" >> $@
+ CMAKE_TOOLCHAIN_ENV += OSX_SYSROOT="$(IOS_SDK)"
else
- echo "set(CMAKE_OSX_SYSROOT $(MACOSX_SDK))" >> $@
+ CMAKE_TOOLCHAIN_ENV += OSX_SYSROOT="$(MACOSX_SDK)"
endif
endif
- echo "set(CMAKE_AR $(AR) CACHE FILEPATH \"Archiver\")" >> $@
- echo "set(CMAKE_RANLIB $(RANLIB) CACHE FILEPATH \"Add index to Archive\")" >> $@
ifdef HAVE_CROSS_COMPILE
- echo "set(_CMAKE_TOOLCHAIN_PREFIX $(HOST)-)" >> $@
+ CMAKE_TOOLCHAIN_ENV += TOOLCHAIN_PREFIX="$(HOST)-"
+ CMAKE_TOOLCHAIN_ENV += PATH_MODE_LIBRARY="ONLY"
+ CMAKE_TOOLCHAIN_ENV += PATH_MODE_INCLUDE="ONLY"
+endif
ifdef HAVE_ANDROID
# cmake will overwrite our --sysroot with a native (host) one on Darwin
# Set it to "" right away to short-circuit this behaviour
- echo "set(CMAKE_CXX_SYSROOT_FLAG \"\")" >> $@
- echo "set(CMAKE_C_SYSROOT_FLAG \"\")" >> $@
-endif
+ CMAKE_TOOLCHAIN_ENV += CXX_SYSROOT_FLAG=
+ CMAKE_TOOLCHAIN_ENV += C_SYSROOT_FLAG=
endif
- echo "set(CMAKE_C_COMPILER $(CC))" >> $@
- echo "set(CMAKE_CXX_COMPILER $(CXX))" >> $@
ifdef MSYS_BUILD
- echo "set(CMAKE_FIND_ROOT_PATH `cygpath -m $(PREFIX)`)" >> $@
+ CMAKE_TOOLCHAIN_ENV += FIND_ROOT_PATH="$(shell cygpath -m $(PREFIX))"
else
- echo "set(CMAKE_FIND_ROOT_PATH $(PREFIX))" >> $@
-endif
- echo "set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> $@
-ifdef HAVE_CROSS_COMPILE
- echo "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> $@
- echo "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> $@
+ CMAKE_TOOLCHAIN_ENV += FIND_ROOT_PATH="$(PREFIX)"
endif
ifdef HAVE_EMSCRIPTEN
- echo "include($(EMSDK_PATH)cmake/Modules/Platform/Emscripten.cmake)" >> $@
+ CMAKE_TOOLCHAIN_ENV += EXTRA_INCLUDE="$(EMSDK_PATH)cmake/Modules/Platform/Emscripten.cmake"
endif
+toolchain.cmake: $(SRC)/gen-cmake-toolchain.py
+ $(CMAKE_TOOLCHAIN_ENV) $(SRC)/gen-cmake-toolchain.py $@
+ cat $@
+
MESON_SYSTEM_NAME =
ifdef HAVE_WIN32
MESON_SYSTEM_NAME = windows
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ffd8229e0aab98576e91d8cfae9b394eca064e9e...a6dcec33242e131addf60fd8f324256fc2127bb5
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ffd8229e0aab98576e91d8cfae9b394eca064e9e...a6dcec33242e131addf60fd8f324256fc2127bb5
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list