]> git.sesse.net Git - casparcg/commitdiff
Fix compilation with Clang.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 7 May 2017 10:07:34 +0000 (12:07 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 7 May 2017 10:07:34 +0000 (12:07 +0200)
Mostly making the build system treat Clang equally to GCC, but also
some instances of invalid C++ code that GCC happens to accept.

CMakeLists.txt
accelerator/CMakeLists.txt
common/CMakeLists.txt
common/blocking_bounded_queue_adapter.h
core/diagnostics/call_context.h
core/producer/text/text_producer.cpp
core/producer/text/utils/texture_atlas.cpp
modules/decklink/CMakeLists.txt
modules/decklink/consumer/decklink_consumer.cpp
modules/decklink/producer/decklink_producer.cpp
shell/CMakeLists.txt

index 0df5fe8bd8db1a76f0845db4900142a790db475d..f08b5ce93bc50176d9d1e564b15ac28e82a64a7d 100644 (file)
@@ -44,7 +44,7 @@ set(DEPENDENCIES_FOLDER                       "${PROJECT_SOURCE_DIR}/dependencies64")
 
 if (MSVC)
        set(PLATFORM_FOLDER_NAME        "win32")
-elseif (CMAKE_COMPILER_IS_GNUCXX)
+elseif (CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
        set(PLATFORM_FOLDER_NAME        "linux")
 endif ()
 
@@ -230,9 +230,12 @@ if (MSVC)
        set(CMAKE_CXX_FLAGS_DEBUG                       "${CMAKE_CXX_FLAGS_DEBUG}                       /D TBB_USE_ASSERT=1 /D TBB_USE_DEBUG /bigobj")
        set(CMAKE_CXX_FLAGS_RELEASE                     "${CMAKE_CXX_FLAGS_RELEASE}                     /Oi /Ot /Gy /bigobj")
        set(CMAKE_CXX_FLAGS_RELWITHDEBINFO      "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}      /Oi /Ot /Gy /bigobj /Ob2")
-elseif (CMAKE_COMPILER_IS_GNUCXX)
-       set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g")
-       add_compile_options( -std=c++11 )
+elseif (CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
+       set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -std=c++11")
+       if (CMAKE_C_COMPILER_ID MATCHES "Clang")
+               # Needed to compile CEF.
+               add_compile_options( -Wno-undefined-var-template )
+       endif ()
        add_compile_options( -msse3 )
        add_compile_options( -mssse3 )
        add_compile_options( -msse4.1 )
index af99676115554c5d12cd532aad703bd8dd46967b..7cf1a3697137978c192fdb3f159891bf48a6cc38 100644 (file)
@@ -8,7 +8,7 @@ if (MSVC)
        
                        cpu/util/xmm.h
        )
-elseif (CMAKE_COMPILER_IS_GNUCXX)
+elseif (CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
 endif ()
 set(SOURCES
 
index 38668898079473c9b35be5c2f44fcf43c758cfd2..1b5c4dffc79f11307bf3f94daa8e4df9b9839c52 100644 (file)
@@ -33,7 +33,7 @@ if (MSVC)
                        os/windows/win32_exception.h
                        os/windows/windows.h
        )
-elseif (CMAKE_COMPILER_IS_GNUCXX)
+elseif (CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
        set(OS_SPECIFIC_SOURCES
                        os/linux/filesystem.cpp
                        os/linux/prec_timer.cpp
index 750083b0991e7ae51ad7401ad897bcc82e8cb0c0..ed7d3f60060540098dbf98d973ffe9905d07c26a 100644 (file)
@@ -55,7 +55,7 @@ private:
        mutable std::mutex      capacity_mutex_;
        size_type                               capacity_;
        semaphore                               space_available_                = capacity_;
-       semaphore                               elements_available_             = 0;
+       semaphore                               elements_available_             { 0 };
        Q                                               queue_;
 public:
        /**
index 560b9a1e39f1589e256b9f6c902687b4a99d54dc..609134a760d2fea7b673f31e56ee563163105155 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <string>
 
+#include <boost/noncopyable.hpp>
+
 namespace caspar { namespace core { namespace diagnostics {
 
 struct call_context
index 2578553f7fe806153e2814fb18d048d4e097dd66..dbc8a14df7a1755b79536eb0284c377d33bddc64 100644 (file)
@@ -132,7 +132,7 @@ struct text_producer::impl
        int                                                                             parent_width_;
        int                                                                             parent_height_;
        bool                                                                    standalone_;
-       constraints                                                             constraints_                            { parent_width_, parent_height_ };
+       constraints                                                             constraints_                            { double(parent_width_), double(parent_height_) };
        variable_impl<std::wstring>                             text_;
        std::shared_ptr<void>                                   text_subscription_;
        variable_impl<double>                                   tracking_;
index 8213f16f5ddee107a81d81fd3dbe049b2aad27b6..1287d5d2832b6c971ce778eaf7c8e93417a80538 100644 (file)
@@ -32,6 +32,7 @@
  * ============================================================================
  */
 
+#include <limits.h>
 #include <list>
 #include <vector>
 #include "texture_atlas.h"
index 1b74d4d703d46f94f654124294eb7ced7c720019..fcf3185361cb29c72c71867f9917b185bd26eb65 100644 (file)
@@ -27,7 +27,7 @@ if (MSVC)
                        interop/DeckLinkAPI.h
                        interop/DeckLinkAPIVersion.h
        )
-elseif (CMAKE_COMPILER_IS_GNUCXX)
+elseif (CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
        set(OS_SPECIFIC_SOURCES
                        linux_interop/DeckLinkAPIConfiguration.h
                        linux_interop/DeckLinkAPIDeckControl.h
@@ -74,7 +74,7 @@ if (MSVC)
                        core
                        ffmpeg
        )
-elseif (CMAKE_COMPILER_IS_GNUCXX)
+elseif (CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
        target_link_libraries(decklink
                        common
                        core
index b6a96a5f49e7ab57add7af5cfb68a0784a031e7d..6825c8c2c4e43971dd6a6999f582dc80a04874ef 100644 (file)
@@ -389,7 +389,7 @@ struct decklink_consumer : public IDeckLinkVideoOutputCallback, boost::noncopyab
 
        int                                                                                                     preroll_count_                  = 0;
 
-       boost::circular_buffer<std::vector<int32_t>>            audio_container_                { buffer_size_ + 1 };
+       boost::circular_buffer<std::vector<int32_t>>            audio_container_                { buffer_size_ + 1u };
 
        tbb::concurrent_bounded_queue<core::const_frame>        frame_buffer_;
        caspar::semaphore                                                                       ready_for_new_frames_   { 0 };
index 27096819abd37770735344f8cd34a30963538624..d1753f71eeb79a45483bfa070d13aee81740a786 100644 (file)
@@ -123,7 +123,7 @@ class decklink_producer : boost::noncopyable, public IDeckLinkInputCallback
                                                                                                                                                        ffmpeg::filter::is_deinterlacing(filter_)
                                                                                                                                                };
 
-       core::constraints                                                               constraints_            { in_format_desc_.width, in_format_desc_.height };
+       core::constraints                                                               constraints_            { double(in_format_desc_.width), double(in_format_desc_.height) };
 
        tbb::concurrent_bounded_queue<core::draw_frame> frame_buffer_;
        core::draw_frame                                                                last_frame_                     = core::draw_frame::empty();
index 6bc90c602a7e1d899139f517b15ec0180318f156..2665460a82d05be1f0779aa4922e91866f6ed176 100644 (file)
@@ -13,7 +13,7 @@ if (MSVC)
                        shell.rc
                        windows_specific.cpp
        )
-elseif (CMAKE_COMPILER_IS_GNUCXX)
+elseif (CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
        set(OS_SPECIFIC_SOURCES
                        linux_specific.cpp
        )