From e5c27be7e1f2f04c4b762c6684d0315f4bd8f192 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Fri, 21 Aug 2020 00:38:25 +1200 Subject: [PATCH] GuestLibs: Allow configuring compiler via cmake --- CMakeLists.txt | 8 ++++++-- ThunkLibs/GuestLibs/CMakeLists.txt | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00875f7ff..78a8d0ad5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,9 @@ option(ENABLE_LLD "Enable linking with LLD" FALSE) option(ENABLE_ASAN "Enables Clang ASAN" FALSE) option(ENABLE_TSAN "Enables Clang TSAN" FALSE) +set (X86_C_COMPILER "x86_64-linux-gnu-gcc" CACHE STRING "c compiler for compiling x86 guest libs") +set (X86_CXX_COMPILER "x86_64-linux-gnu-g++" CACHE STRING "c++ compiler for compiling x86 guest libs") + set(CMAKE_CXX_STANDARD 17) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Bin) @@ -135,7 +138,7 @@ include(ExternalProject) ExternalProject_Add(host-libs PREFIX host-libs SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ThunkLibs/HostLibs" - BINARY_DIR "Host" + BINARY_DIR "Host" INSTALL_COMMAND "" BUILD_ALWAYS ON ) @@ -143,7 +146,8 @@ ExternalProject_Add(host-libs ExternalProject_Add(guest-libs PREFIX guest-libs SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ThunkLibs/GuestLibs" - BINARY_DIR "Guest" + BINARY_DIR "Guest" + CMAKE_ARGS "-DX86_C_COMPILER:STRING=${X86_C_COMPILER}" "-DX86_CXX_COMPILER:STRING=${X86_CXX_COMPILER}" INSTALL_COMMAND "" BUILD_ALWAYS ON ) diff --git a/ThunkLibs/GuestLibs/CMakeLists.txt b/ThunkLibs/GuestLibs/CMakeLists.txt index 140d8ca46..dd94cda7b 100644 --- a/ThunkLibs/GuestLibs/CMakeLists.txt +++ b/ThunkLibs/GuestLibs/CMakeLists.txt @@ -1,8 +1,12 @@ cmake_minimum_required(VERSION 3.14) project(guest-thunks) -set(CMAKE_C_COMPILER x86_64-linux-gnu-gcc) -set(CMAKE_CXX_COMPILER x86_64-linux-gnu-g++) +# These get passed in from the main cmake project +set (X86_C_COMPILER "x86_64-linux-gnu-gcc" CACHE STRING "c compiler for compiling x86 guest libs") +set (X86_CXX_COMPILER "x86_64-linux-gnu-g++" CACHE STRING "c++ compiler for compiling x86 guest libs") + +set(CMAKE_C_COMPILER "${X86_C_COMPILER}") +set(CMAKE_CXX_COMPILER "${X86_CXX_COMPILER}") function(generate NAME) foreach(WHAT IN LISTS ARGN)