From 6358ae47ded95c19d5e3868144cfe189aafe16b0 Mon Sep 17 00:00:00 2001 From: laikh Date: Wed, 5 Aug 2020 11:15:20 +0800 Subject: Fix: Remove /MP flag and improve FindEditbin.cmake for Windows clang-cl build --- cmake/CompileFlags.cmake | 6 ++++-- cmake/FindEditbin.cmake | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'cmake') diff --git a/cmake/CompileFlags.cmake b/cmake/CompileFlags.cmake index 4adc4a31a..49ae1d767 100644 --- a/cmake/CompileFlags.cmake +++ b/cmake/CompileFlags.cmake @@ -23,8 +23,10 @@ macro(compile_flags) # C++11 standard". We need C++11 for the way we use threads. add_compile_options(/Zc:rvalueCast) - # Enable multi-threaded compilation. - add_compile_options(/MP) + if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # Enable multi-threaded compilation. + add_compile_options(/MP) + endif(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # Add DPI manifest to project; other WIN32 targets get this via ottdres.rc list(APPEND GENERATED_SOURCE_FILES "${CMAKE_SOURCE_DIR}/os/windows/openttd.manifest") diff --git a/cmake/FindEditbin.cmake b/cmake/FindEditbin.cmake index 363bc0053..8ed30599f 100644 --- a/cmake/FindEditbin.cmake +++ b/cmake/FindEditbin.cmake @@ -1,11 +1,28 @@ # Autodetect editbin. Only useful for MSVC. -get_filename_component(MSVC_COMPILE_DIRECTORY ${CMAKE_CXX_COMPILER} DIRECTORY) +if (NOT EDITBIN_DIRECTORY) + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + get_filename_component(MSVC_COMPILE_DIRECTORY ${CMAKE_CXX_COMPILER} DIRECTORY) + set(EDITBIN_DIRECTORY ${MSVC_COMPILE_DIRECTORY}) + else (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # For clang-cl build + # find editbin.exe from environmental variable VCToolsInstallDir + set(EDITBIN_DIRECTORY "$ENV{VCToolsInstallDir}/bin/Hostx64/x64") + endif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +endif (NOT EDITBIN_DIRECTORY) + +message(CHECK_START "Finding editbin.exe") find_program( EDITBIN_EXECUTABLE editbin.exe - HINTS ${MSVC_COMPILE_DIRECTORY} + HINTS ${EDITBIN_DIRECTORY} ) +if (EDITBIN_EXECUTABLE) + message(CHECK_PASS "found") +else (EDITBIN_EXECUTABLE) + message(CHECK_FAIL "not found , please manually specify EDITBIN_DIRECTORY") +endif (EDITBIN_EXECUTABLE) + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Editbin FOUND_VAR EDITBIN_FOUND -- cgit v1.2.3-70-g09d2