Skip to content

Commit

Permalink
Support Companion build with clang-cl on Windows (fw/libsimu not work…
Browse files Browse the repository at this point in the history
…ing yet due to compiler-specific macros in that code).
  • Loading branch information
mpaperno committed Jul 9, 2018
1 parent d507dbb commit 6110bbc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmake/Macros.cmake
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion companion/src/CMakeLists.txt
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion radio/src/targets/simu/CMakeLists.txt
Expand Up @@ -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
Expand Down

0 comments on commit 6110bbc

Please sign in to comment.