Skip to content

Commit

Permalink
Make CMake 3.10 the minimum version, add LTO option (google#1316)
Browse files Browse the repository at this point in the history
* Make CMake 3.10 the minimum version, add LTO option

* Install a newer CMake on Linux CI builds

* Update LLVM and Cmake on Windows CI

* Update build/windows/ci-common.bat

Co-Authored-By: Ben Doherty <[email protected]>

* Update formatting

* Apply suggestions from code review

* Update build/windows/ci-common.bat

* Update CMake

* Switch Android projects back to CMake 3.6
  • Loading branch information
romainguy authored Jun 19, 2019
1 parent 8cd44fb commit b124216
Show file tree
Hide file tree
Showing 68 changed files with 105 additions and 79 deletions.
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ==================================================================================================
# CMake
# ==================================================================================================
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)

# ==================================================================================================
# Project declaration
Expand All @@ -18,6 +18,8 @@ option(USE_EXTERNAL_GLES3 "Experimental: Compile Filament against OpenGL ES 3" O

option(GENERATE_JS_DOCS "Build WebGL documentation and tutorials" OFF)

option(ENABLE_LTO "Enable link-time optimizations if supported by the compiler" OFF)

# ==================================================================================================
# OS specific
# ==================================================================================================
Expand Down Expand Up @@ -101,7 +103,7 @@ set(TOOLS ${CMAKE_CURRENT_SOURCE_DIR}/tools)
# ==================================================================================================
# Compiler check
# ==================================================================================================
set(MIN_CLANG_VERSION "5.0")
set(MIN_CLANG_VERSION "6.0")

if (CMAKE_C_COMPILER_ID MATCHES "Clang")
if (CMAKE_C_COMPILER_VERSION VERSION_LESS MIN_CLANG_VERSION)
Expand All @@ -124,6 +126,20 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "${CMAKE_CXX_SIMULATE_ID}" S
set(CLANG_CL true)
endif()

# ==================================================================================================
# Link time optimizations (LTO)
# ==================================================================================================
if (ENABLE_LTO)
include(CheckIPOSupported)

check_ipo_supported(RESULT IPO_SUPPORT)

if (IPO_SUPPORT)
message(STATUS "LTO support is enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
endif()

# ==================================================================================================
# General compiler flags
# ==================================================================================================
Expand Down
2 changes: 1 addition & 1 deletion android/filamat-android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4.1)
cmake_minimum_required(VERSION 3.6)

set(FILAMENT_DIR ${FILAMENT_DIST_DIR})

Expand Down
2 changes: 1 addition & 1 deletion android/filament-android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4.1)
cmake_minimum_required(VERSION 3.6)

set(FILAMENT_DIR ${FILAMENT_DIST_DIR})

Expand Down
2 changes: 1 addition & 1 deletion android/gltfio-android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4.1)
cmake_minimum_required(VERSION 3.6)

set(FILAMENT_DIR ${FILAMENT_DIST_DIR})

Expand Down
18 changes: 9 additions & 9 deletions build/linux/ci-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ if [[ "$KOKORO_BUILD_ID" ]]; then
if [[ "$FILAMENT_ANDROID_CI_BUILD" ]]; then
# Update NDK
yes | $ANDROID_HOME/tools/bin/sdkmanager "ndk-bundle" > /dev/null
fi

# Install CMake
mkdir -p cmake
cd cmake
# Install CMake
mkdir -p cmake
cd cmake

sudo wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-Linux-x86_64.sh
sudo chmod +x ./cmake-$CMAKE_VERSION-Linux-x86_64.sh
sudo ./cmake-$CMAKE_VERSION-Linux-x86_64.sh --skip-license > /dev/null
sudo update-alternatives --install /usr/bin/cmake cmake `pwd`/bin/cmake 1000 --force
sudo wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-Linux-x86_64.sh
sudo chmod +x ./cmake-$CMAKE_VERSION-Linux-x86_64.sh
sudo ./cmake-$CMAKE_VERSION-Linux-x86_64.sh --skip-license > /dev/null
sudo update-alternatives --install /usr/bin/cmake cmake `pwd`/bin/cmake 1000 --force

cd ..
fi
cd ..

# Install clang
# This may or may not be needed...
Expand Down
16 changes: 13 additions & 3 deletions build/windows/ci-common.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
if defined KOKORO_BUILD_ID (
choco install llvm --version 6.0.1 -y
choco install cmake -y

:: retry if choco install failed
if errorlevel 1 (
choco install llvm --version 6.0.1 -y
choco install cmake -y
if errorlevel 1 exit /b %errorlevel%
)

:: refreshenv is necessary to put LLVM on path
refreshenv

choco install llvm --version 8.0.0 -y

:: retry if choco install failed
if errorlevel 1 (
choco install llvm --version 8.0.8 -y
if errorlevel 1 exit /b %errorlevel%
)

:: refreshenv is necessary to put CMake and LLVM on path
refreshenv
)

Expand Down
2 changes: 1 addition & 1 deletion filament/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(filament C ASM)

set(TARGET filament)
Expand Down
2 changes: 1 addition & 1 deletion filament/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(filament C ASM)

set(TARGET backend)
Expand Down
2 changes: 1 addition & 1 deletion filament/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(filament-benchmarks)

# ==================================================================================================
Expand Down
2 changes: 1 addition & 1 deletion filament/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(filament-tests)

# ==================================================================================================
Expand Down
2 changes: 1 addition & 1 deletion filament/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(ssaogen)

set(TARGET ssaogen)
Expand Down
2 changes: 1 addition & 1 deletion java/filamat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4.1)
cmake_minimum_required(VERSION 3.10)
project(filament-java)

if (NOT ENABLE_JAVA)
Expand Down
2 changes: 1 addition & 1 deletion java/filament/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4.1)
cmake_minimum_required(VERSION 3.10)
project(filament-java)

if (NOT ENABLE_JAVA)
Expand Down
2 changes: 1 addition & 1 deletion libs/bluegl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(bluegl ASM)

set(TARGET bluegl)
Expand Down
2 changes: 1 addition & 1 deletion libs/bluevk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(bluevk)

set(TARGET bluevk)
Expand Down
2 changes: 1 addition & 1 deletion libs/filabridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(filabridge)

set(TARGET filabridge)
Expand Down
2 changes: 1 addition & 1 deletion libs/filaflat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(filaflat)

set(TARGET filaflat)
Expand Down
2 changes: 1 addition & 1 deletion libs/filagui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(filagui)

set(TARGET filagui)
Expand Down
2 changes: 1 addition & 1 deletion libs/filamat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(filamat)

set(TARGET filamat)
Expand Down
2 changes: 1 addition & 1 deletion libs/filameshio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(filameshio)

set(TARGET filameshio)
Expand Down
2 changes: 1 addition & 1 deletion libs/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(geometry)

set(TARGET geometry)
Expand Down
2 changes: 1 addition & 1 deletion libs/gltfio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(gltfio C ASM)

set(TARGET gltfio)
Expand Down
2 changes: 1 addition & 1 deletion libs/ibl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(cmgen)

set(TARGET ibl)
Expand Down
2 changes: 1 addition & 1 deletion libs/image/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(image)

set(TARGET image)
Expand Down
2 changes: 1 addition & 1 deletion libs/imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(imageio)

set(TARGET imageio)
Expand Down
2 changes: 1 addition & 1 deletion libs/math/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(math)

set(TARGET math)
Expand Down
2 changes: 1 addition & 1 deletion libs/rays/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(rays)

set(TARGET rays)
Expand Down
2 changes: 1 addition & 1 deletion libs/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(utils)

set(TARGET utils)
Expand Down
2 changes: 1 addition & 1 deletion samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(filament-samples C ASM)

set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
Expand Down
2 changes: 1 addition & 1 deletion shaders/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(shaders C ASM)

set(TARGET shaders)
Expand Down
2 changes: 1 addition & 1 deletion third_party/OpenImageDenoise/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
## limitations under the License. ##
## ======================================================================== ##

cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)

set(OIDN_VERSION_MAJOR 0)
set(OIDN_VERSION_MINOR 9)
Expand Down
2 changes: 1 addition & 1 deletion third_party/OpenImageDenoise/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(OIDN_VERSION_MAJOR 0)
Expand Down
2 changes: 1 addition & 1 deletion third_party/astcenc/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(astcenc)

set(TARGET astcenc)
Expand Down
2 changes: 1 addition & 1 deletion third_party/benchmark/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(benchmark)

set(OUR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
Expand Down
2 changes: 1 addition & 1 deletion third_party/cgltf/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(cgltf)

set(TARGET cgltf)
Expand Down
2 changes: 1 addition & 1 deletion third_party/etc2comp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 3.10)
project(EtcTest)

set (CMAKE_CXX_STANDARD 11)
Expand Down
2 changes: 1 addition & 1 deletion third_party/getopt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(getopt)

set(TARGET getopt)
Expand Down
2 changes: 1 addition & 1 deletion third_party/glslang/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.10)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Adhere to GNU filesystem layout conventions
Expand Down
2 changes: 1 addition & 1 deletion third_party/imgui/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(imgui)

set(OUR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
Expand Down
2 changes: 1 addition & 1 deletion third_party/libassimp/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(assimp)

set(OUR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
Expand Down
2 changes: 1 addition & 1 deletion third_party/libgtest/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(gtest)

set(OUR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
Expand Down
2 changes: 1 addition & 1 deletion third_party/libpng/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(png)

set(OUR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
Expand Down
2 changes: 1 addition & 1 deletion third_party/libsdl2/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(sdl2 C)

# This is necessary on Windows, so the sdl2.dll lives next to the sample apps that use it
Expand Down
2 changes: 1 addition & 1 deletion third_party/libz/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(z)

set(OUR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
Expand Down
2 changes: 1 addition & 1 deletion third_party/meshoptimizer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project(meshoptimizer)
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.10)

option(BUILD_DEMO "Build demo" OFF)

Expand Down
2 changes: 1 addition & 1 deletion third_party/robin-map/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(tsl)

set(TARGET tsl)
Expand Down
2 changes: 1 addition & 1 deletion third_party/skylight/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(skylight)

set(OUR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
Expand Down
2 changes: 1 addition & 1 deletion third_party/smol-v/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(smol-v)

set(TARGET smol-v)
Expand Down
2 changes: 1 addition & 1 deletion third_party/spirv-cross/tnt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
project(SPIRV-Cross)

# Use assertions instead of exceptions so we can succesfully compile with -fno-exceptions.
Expand Down
2 changes: 1 addition & 1 deletion third_party/spirv-tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.10)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif()
Expand Down
Loading

0 comments on commit b124216

Please sign in to comment.