diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f2682879..06518cbcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,9 +72,13 @@ else() set(LUA NO) endif() +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # regular Clang or AppleClang + set(CLANG TRUE) +endif() + option(DISABLE_COMPANION "Disable building companion and simulators" OFF) -if(NOT DISABLE_COMPANION) +if(NOT DISABLE_COMPANION) # FIXME cosmetics/style find_package(Qt5Core) find_package(Qt5Widgets) find_package(Qt5Xml) @@ -114,6 +118,9 @@ if(Qt5Core_FOUND) list(APPEND APP_COMMON_DEFINES -DQXT_STATIC) list(APPEND APP_COMMON_DEFINES -DQT_USE_QSTRINGBUILDER) # more efficient QString construction using % operator + if(MSVC) + list(APPEND APP_COMMON_DEFINES -D__STDC_LIMIT_MACROS) + endif() if(APP_CUSTOM_DBG_HANDLER) # provide full qDebug log context to our custom handler. This may also affect libsimulator, which is why it is here list(APPEND APP_COMMON_DEFINES -DQT_MESSAGELOGCONTEXT) @@ -153,7 +160,7 @@ if(Qt5Core_FOUND OR FOX_FOUND) message(STATUS "SDL not found! Simulator audio, and joystick inputs, will not work.") endif() endif() -endif() +endif(NOT DISABLE_COMPANION) # Check for a file that is typically left from a OpenTX 2.1 build and abort if found if (EXISTS ${RADIO_SRC_DIRECTORY}/stamp.h OR EXISTS ${RADIO_SRC_DIRECTORY}/translations/en.h) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index c8ca02aa0..06fbb244b 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -49,8 +49,8 @@ macro(use_cxx11) endmacro(use_cxx11) macro(PrintTargetReport targetName) - if(CMAKE_CXX_COMPILER MATCHES "/cl\\.exe$") - set(cpp_version ${MSVC_VERSION}) + if(CMAKE_CXX_COMPILER MATCHES "/(clang-)?cl\\.exe$") + set(cpp_version ${CMAKE_CXX_COMPILER_VERSION}) else() execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE cpp_version) endif() diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 3d884bcf1..ea24fe339 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -81,7 +81,9 @@ if(WIN32) set(WIN_EXECUTABLE_TYPE WIN32) # GUI (WinMain) app endif() if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /LD /MP") + if(NOT CLANG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /LD /MP") + endif() if(NOT WIN_USE_CONSOLE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01") # is this even needed? endif() diff --git a/radio/src/targets/simu/CMakeLists.txt b/radio/src/targets/simu/CMakeLists.txt index 6fd71aa1e..6bc237618 100644 --- a/radio/src/targets/simu/CMakeLists.txt +++ b/radio/src/targets/simu/CMakeLists.txt @@ -75,7 +75,9 @@ if(WIN32) endif(WIN32) if(MSVC) - set(CMAKE_CXX_FLAGS "/EHsc /LD /MP") + if(NOT CLANG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /LD /MP") + endif() else() if(MINGW) # struct packing breaks on MinGW w/out -mno-ms-bitfields: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 & http://stackoverflow.com/questions/24015852/struct-packing-and-alignment-with-mingw