Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@
cmake_minimum_required(VERSION 3.17)
cmake_policy(SET CMP0079 NEW) # Allow target_link_libraries() in subdirs

include(src/cmake/environment-utils.cmake)
is_running_in_ci(IS_RUNNING_IN_CI)

message(STATUS "Running in CI environment? ${IS_RUNNING_IN_CI}")

if(NOT ${IS_RUNNING_IN_CI})
include(src/cmake/configure-linker.cmake)
configure_linker()
endif()

cmake_host_system_information(RESULT HOST_OS_NAME QUERY OS_NAME)

if("${HOST_OS_NAME}" STREQUAL "macOS")
Expand Down Expand Up @@ -64,6 +54,16 @@ set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/3rd-party/vcpkg/scripts/bu

project(Multipass)

include(src/cmake/environment-utils.cmake)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to move this so that we know what compiler was picked up. However, at this point the CMAKE_LINKER is also already set and I don't think it will get affected. I could set it manually, but I wonder if that's the right thing to do...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well not this line, the whole block...

is_running_in_ci(IS_RUNNING_IN_CI)

message(STATUS "Running in CI environment? ${IS_RUNNING_IN_CI}")

if(NOT ${IS_RUNNING_IN_CI})
include(src/cmake/configure-linker.cmake)
configure_linker()
endif()

option(MULTIPASS_ENABLE_TESTS "Build tests" ON)
option(MULTIPASS_ENABLE_FLUTTER_GUI "Build Flutter GUI" ON)

Expand Down
15 changes: 11 additions & 4 deletions src/cmake/configure-linker.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,20 @@ function(configure_linker)
find_program(LLD_LINKER NAMES ${LLD_LINKER_NAMES})

if(MOLD_LINKER)
message(STATUS "configure_linker: `mold` found in environment, will use it as default.")
set(CMAKE_LINKER_TYPE MOLD PARENT_SCOPE)
elseif(LLD_LINKER)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1)
message(STATUS "configure_linker supports `mold` with `g++` only on version 12.1 and above")
else()
message(STATUS "configure_linker: `mold` found in environment, will use it as default.")
set(CMAKE_LINKER_TYPE MOLD PARENT_SCOPE)
return()
endif()
endif()

if(LLD_LINKER)
message(STATUS "configure_linker: `lld` found in environment, will use it as default.")
set(CMAKE_LINKER_TYPE LLD PARENT_SCOPE)
else()
message(STATUS "configure_linker: neither `mold` or `lld` is present in the environment, will use the toolchain default.")
message(STATUS "configure_linker: could use neither `mold` nor `lld`; will use the toolchain default.")
endif()
else()
message(STATUS "configure_linker: will use the user specified linker: `${CMAKE_LINKER_TYPE}`")
Expand Down
Loading