1aaced190a
-- 3439d8a5cd745dfd2776593916eead65cb456afc by Kevin Zakka <kevinarmandzakka@gmail.com>: Respect an explicit CMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF The default-LTO guard checked the value rather than whether it was DEFINED, so an explicit -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF (used in CI to cut build time) was silently flipped back ON. Check DEFINED instead; default-on for Release is preserved when the caller makes no choice. -- bd15d1b264e5ab9594669b58fa1e0388d0a16f6b by Kevin Zakka <kevinarmandzakka@gmail.com>: Speed up CI ~10x faster on the POSIX jobs (~45m -> ~4-5m) and ~2x overall wall-clock. - Build Studio/Filament and WASM only in their dedicated canary jobs, not in every matrix job (WASM uses emcc, which ignores the host compiler). - Compiler matrix -> build_matrix.json with core/extended tiers: PRs build the core set, pushes to main run the full sweep. - ccache across build jobs (studio cache keyed on the Filament pin); fix the Python-bindings build so ccache hits (CCACHE_BASEDIR). - Disable IPO/LTO on POSIX (it was silently on); keep it on Windows where /GL-off exposes a latent test bug and build time is not the bottleneck. - Run ctest in parallel on POSIX (~2x); uv for Python installs (~29s -> ~8s). - Move MJX (compiler-independent) to a single dedicated job. - Restrict GITHUB_TOKEN to contents: read; bump actions off deprecated Node20. -- c0618ab7aef524b238e0a30f2f23c50c4ce0c9b1 by Kevin Zakka <kevinarmandzakka@gmail.com>: Build the gcc jobs with LTO off too Restores LTO-off for gcc (recovering the build-time win). That surfaces known gcc-12 -Wrestrict false positives in libstdc++ <char_traits> at -O3; two clean, behavior-preserving rewrites in the XML writer avoid them. Confirmed gcc-12 and gcc-14 build clean with LTO off (PR #3325). -- 2c38da0f48f77635e58e4b7931b86d60f3c253c7 by Kevin Zakka <kevinarmandzakka@gmail.com>: Respect explicit IPO=OFF in the Simulate and Sample options too Apply the same DEFINED check as cmake/MujocoOptions.cmake to the simulate/ and sample/ subprojects (which carry identical copies of the guard) to keep the three in sync, as the internal import requires. Since the guard now honors =OFF, stop forcing IPO=OFF on the tiny samples/simulate CI builds so they keep their default LTO and don't expose the gcc -Werror false positives that -O3-without-LTO triggers. COPYBARA_INTEGRATE_REVIEW=https://github.com/google-deepmind/mujoco/pull/3315 from google-deepmind:speed-up-ci 2c38da0f48f77635e58e4b7931b86d60f3c253c7 PiperOrigin-RevId: 930008698 Change-Id: Ic41dc87881833c95f2ebfc0602de1ed438db3d4f
127 lines
4.3 KiB
CMake
127 lines
4.3 KiB
CMake
# Copyright 2021 DeepMind Technologies Limited
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# Global compilation settings
|
|
set(CMAKE_C_STANDARD 11)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
if(EMSCRIPTEN)
|
|
set(CMAKE_C_EXTENSIONS ON)
|
|
else()
|
|
set(CMAKE_C_EXTENSIONS OFF)
|
|
endif()
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # For LLVM tooling
|
|
|
|
if(NOT CMAKE_CONFIGURATION_TYPES)
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
message(STATUS "Setting build type to 'Release' as none was specified.")
|
|
set(CMAKE_BUILD_TYPE
|
|
"Release"
|
|
CACHE STRING "Choose the type of build, recommanded options are: Debug or Release" FORCE
|
|
)
|
|
endif()
|
|
set(BUILD_TYPES
|
|
"Debug"
|
|
"Release"
|
|
"MinSizeRel"
|
|
"RelWithDebInfo"
|
|
)
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${BUILD_TYPES})
|
|
endif()
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
# Change the default output directory in the build structure. This is not stricly needed, but helps
|
|
# running in Windows, such that all built executables have DLLs in the same folder as the .exe
|
|
# files.
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
|
|
|
|
set(OpenGL_GL_PREFERENCE GLVND)
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
|
|
|
if(MSVC)
|
|
add_compile_options(/Gy /Gw /Oi)
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
add_compile_options(-fdata-sections -ffunction-sections)
|
|
endif()
|
|
|
|
# We default to shared library.
|
|
set(BUILD_SHARED_LIBS
|
|
ON
|
|
CACHE BOOL "Build Mujoco as shared library."
|
|
)
|
|
|
|
option(MUJOCO_ENABLE_AVX "Build binaries that require AVX instructions, if possible." ON)
|
|
option(MUJOCO_ENABLE_AVX_INTRINSICS "Make use of hand-written AVX intrinsics, if possible." ON)
|
|
option(MUJOCO_ENABLE_RPATH "Enable RPath support when installing Mujoco." ON)
|
|
mark_as_advanced(MUJOCO_ENABLE_RPATH)
|
|
|
|
if(MUJOCO_ENABLE_AVX)
|
|
include(CheckAvxSupport)
|
|
get_avx_compile_options(AVX_COMPILE_OPTIONS)
|
|
else()
|
|
set(AVX_COMPILE_OPTIONS)
|
|
endif()
|
|
|
|
option(MUJOCO_BUILD_MACOS_FRAMEWORKS "Build libraries as macOS Frameworks" OFF)
|
|
|
|
# Get some extra link options.
|
|
include(MujocoLinkOptions)
|
|
get_mujoco_extra_link_options(EXTRA_LINK_OPTIONS)
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT MSVC))
|
|
set(EXTRA_COMPILE_OPTIONS
|
|
-Werror
|
|
-Wall
|
|
-Wpedantic
|
|
-Wimplicit-fallthrough
|
|
-Wunused
|
|
-Wvla
|
|
-Wno-int-in-bool-context
|
|
-Wno-sign-compare
|
|
-Wno-unknown-pragmas
|
|
)
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
# Set -Wimplicit-fallthrough=5 to only allow fallthrough annotation via __attribute__.
|
|
set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} -Wimplicit-fallthrough=5
|
|
-Wno-maybe-uninitialized
|
|
)
|
|
endif()
|
|
endif()
|
|
|
|
# Enable interprocedural optimization (LTO) by default for non-Debug builds, but
|
|
# only when the caller has not made an explicit choice. Checking the value (rather
|
|
# than whether it is DEFINED) meant an explicit `-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF`
|
|
# was silently overridden back to ON, e.g. in CI where LTO is disabled to cut
|
|
# build time.
|
|
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION AND (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
|
endif()
|
|
|
|
include(MujocoHarden)
|
|
set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} ${MUJOCO_HARDEN_COMPILE_OPTIONS})
|
|
set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} ${MUJOCO_HARDEN_LINK_OPTIONS})
|
|
|
|
if(WIN32)
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
|
|
endif()
|