|
| 1 | +cmake_minimum_required(VERSION 3.12) |
| 2 | + |
| 3 | +if (COMPILER_TARGET) |
| 4 | + set(CMAKE_C_COMPILER_TARGET "${COMPILER_TARGET}") |
| 5 | + set(CMAKE_CXX_COMPILER_TARGET "${COMPILER_TARGET}") |
| 6 | + set(CMAKE_ASM_COMPILER_TARGET "${COMPILER_TARGET}") |
| 7 | +endif() |
| 8 | + |
| 9 | +project(native_client C CXX ASM) |
| 10 | + |
| 11 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") |
| 12 | + |
| 13 | +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") |
| 14 | + |
| 15 | +include(DaemonPlatform/Platform) |
| 16 | +include(NaClFlags) |
| 17 | + |
| 18 | +if (NOT CMAKE_BUILD_TYPE) |
| 19 | + set(CMAKE_BUILD_TYPE RelWithDebInfo) |
| 20 | +endif() |
| 21 | + |
| 22 | +option(BUILD_NACL_LOADER "Build the sel_ldr program." ON) |
| 23 | + |
| 24 | +if (LINUX) |
| 25 | + option(BUILD_NACL_HELPER_BOOTSTRAP "Build the nacl_helper_bootstrap program on platforms requiring it." ON) |
| 26 | +endif() |
| 27 | + |
| 28 | +# TODO(arbenson): remove this once binutils bug is fixed (see |
| 29 | +# src/trusted/service_runtime/arch/x86_64/sel_addrspace_posix_x86_64.c) |
| 30 | +if (BUILD_NACL_LOADER AND ARCH_amd64 AND NOT WIN32) |
| 31 | + option(USE_AMD64_ZERO_BASED_SANDBOX "Allow the zero-based sandbox model to run insecurely." OFF) |
| 32 | + list(APPEND INHERITED_OPTIONS "USE_AMD64_ZERO_BASED_SANDBOX") |
| 33 | +endif() |
| 34 | + |
| 35 | +if (BUILD_NACL_LOADER AND WIN32) |
| 36 | + option(FORCE_NO_TRUSTED_BUILD "Prevent use of trusted toolchain." OFF) |
| 37 | +endif() |
| 38 | + |
| 39 | +if (BUILD_NACL_LOADER AND WIN32) |
| 40 | + set(REQUIRE_MASM ON) |
| 41 | +endif() |
| 42 | + |
| 43 | +if (BUILD_NACL_LOADER AND APPLE) |
| 44 | + set(REQUIRE_PYTHON ON) |
| 45 | +endif() |
| 46 | + |
| 47 | +if (BUILD_NACL_HELPER_BOOTSTRAP) |
| 48 | + set(REQUIRE_PYTHON ON) |
| 49 | +endif() |
| 50 | + |
| 51 | +if (REQUIRE_PYTHON) |
| 52 | + if (NOT PYTHON) |
| 53 | + find_program(PYTHON NAMES "python3" DOC "Path to the python3 executable." REQUIRED) |
| 54 | + endif() |
| 55 | +endif() |
| 56 | + |
| 57 | +if (REQUIRE_MASM) |
| 58 | + if (NOT MSVC AND NOT CMAKE_ASM_MASM_COMPILER) |
| 59 | + include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include-hax/fake_masm") |
| 60 | + |
| 61 | + find_program(JWASM NAMES "jwasm" DOC "Path to the JWasm executable." REQUIRED) |
| 62 | + |
| 63 | + set(CMAKE_ASM_MASM_COMPILER "${JWASM}") |
| 64 | + |
| 65 | + if (ARCH_i686) |
| 66 | + list(APPEND CMAKE_ASM_MASM_FLAGS "-coff") |
| 67 | + elseif(ARCH_amd64) |
| 68 | + list(APPEND CMAKE_ASM_MASM_FLAGS "-win64") |
| 69 | + endif() |
| 70 | + endif() |
| 71 | + |
| 72 | + enable_language(ASM_MASM) |
| 73 | +endif() |
| 74 | + |
| 75 | +include_directories("include-hax") |
| 76 | + |
| 77 | +if (ARCH_i686) |
| 78 | + set(ARCH_SUFFIX "_x86_32") |
| 79 | +elseif (ARCH_amd64) |
| 80 | + set(ARCH_SUFFIX "_X86_64") |
| 81 | +elseif (ARCH_armhf OR ARCH_armel) |
| 82 | + set(ARCH_SUFFIX "_arm") |
| 83 | +elseif (ARCH_mipsel) |
| 84 | + set(ARCH_SUFFIX "_mips32") |
| 85 | +endif() |
| 86 | + |
| 87 | +if (BUILD_NACL_LOADER) |
| 88 | + add_subdirectory(src/shared/gio) |
| 89 | + add_subdirectory(src/shared/imc) |
| 90 | + add_subdirectory(src/shared/platform) |
| 91 | + add_subdirectory(src/trusted/cpu_features) |
| 92 | + add_subdirectory(src/trusted/debug_stub) |
| 93 | + add_subdirectory(src/trusted/desc) |
| 94 | + add_subdirectory(src/trusted/fault_injection) |
| 95 | + add_subdirectory(src/trusted/interval_multiset) |
| 96 | + add_subdirectory(src/trusted/nacl_base) |
| 97 | + add_subdirectory(src/trusted/perf_counter) |
| 98 | + add_subdirectory(src/trusted/platform_qualify) |
| 99 | + add_subdirectory(src/trusted/validator) |
| 100 | + |
| 101 | + if (ARCH_i686 OR ARCH_amd64) |
| 102 | + add_subdirectory(src/trusted/validator_x86) |
| 103 | + add_subdirectory(src/trusted/validator_ragel) |
| 104 | + elseif (ARCH_armhf OR ARCH_armel) |
| 105 | + add_subdirectory(src/trusted/validator_arm) |
| 106 | + elseif (ARCH_mipsel) |
| 107 | + add_subdirectory(src/trusted/validator_mips) |
| 108 | + endif() |
| 109 | +endif() |
| 110 | + |
| 111 | +if (BUILD_NACL_LOADER) |
| 112 | + add_subdirectory(src/trusted/service_runtime) |
| 113 | +endif() |
| 114 | + |
| 115 | +if (BUILD_NACL_HELPER_BOOTSTRAP) |
| 116 | + add_subdirectory(src/trusted/service_runtime/linux) |
| 117 | +endif() |
0 commit comments