• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7# https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14cmake_minimum_required(VERSION 3.1.0)
15project(astc-codec)
16
17option(OPTION_ASTC_TESTS "Build all the unit tests." OFF)
18
19# TODO add support for the fuzzer, it has some additional dependencies we are not
20# yet bringing in.
21option(OPTION_BUILD_FUZZER "Build the fuzzer tests." OFF)
22
23set (CMAKE_CXX_STANDARD 11)
24if(OPTION_ASTC_TESTS)
25  enable_testing()
26
27  # No need to build gmock if an external project defines it.
28  if(NOT TARGET gmock_main)
29    # We use the approach suggested by https://crascit.com/2015/07/25/cmake-gtest/ to download gtest.
30    include(ExternalProject)
31    # Download and unpack googletest at configure time
32    configure_file(GoogleTest-CMakeLists.txt.in googletest-download/CMakeLists.txt)
33    execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
34                    WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download")
35    execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download")
36
37    # Prevent GoogleTest from overriding our compiler/linker options when building with Visual Studio
38    set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
39
40    # Add googletest directly to our build. This adds the following targets: gtest, gtest_main, gmock and gmock_main
41    add_subdirectory("${CMAKE_BINARY_DIR}/googletest-src" "${CMAKE_BINARY_DIR}/googletest-build")
42  endif()
43endif()
44
45add_subdirectory(src/base)
46add_subdirectory(src/decoder)
47