From 8fe48092dc54c8841489ae4afb0126295964c652 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 14 May 2017 20:02:52 +0200 Subject: compat/simple-mat: pass -Werror on llvm --- compat/simple-mat.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'compat') diff --git a/compat/simple-mat.hpp b/compat/simple-mat.hpp index a909e40b..11bb191f 100644 --- a/compat/simple-mat.hpp +++ b/compat/simple-mat.hpp @@ -206,6 +206,11 @@ public: inline num operator()(unsigned j, unsigned i) const { return data[j][i]; } inline num& operator()(unsigned j, unsigned i) { return data[j][i]; } +#ifdef __GNUG__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmissing-braces" +#endif + template::value>::type> Mat(const ts... xs) : data{static_cast(xs)...} @@ -213,6 +218,10 @@ public: static_assert(h__ == h_ && w__ == w_, ""); } +#ifdef __GNUG__ +# pragma GCC diagnostic pop +#endif + Mat() { for (int j = 0; j < h_; j++) -- cgit v1.2.3 From 8c2d5631df1a25fe4ba9890bd8f716eae840aa37 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 14 May 2017 20:03:11 +0200 Subject: compat/timer: add missing assert include --- compat/timer.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'compat') diff --git a/compat/timer.cpp b/compat/timer.cpp index 3ecdf528..ca22fa10 100644 --- a/compat/timer.cpp +++ b/compat/timer.cpp @@ -6,6 +6,9 @@ * notice appear in all copies. */ +#include "ndebug-guard.hpp" +#include + #include "timer.hpp" #include -- cgit v1.2.3 From c066a471f1ffd98cd1f1f2154b6f8f16e4f94e32 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 12 May 2017 16:09:35 +0200 Subject: compat/timer: remove unused headers --- compat/time.hpp | 1 - compat/timer.hpp | 1 - 2 files changed, 2 deletions(-) (limited to 'compat') diff --git a/compat/time.hpp b/compat/time.hpp index fbe7469a..b560da70 100644 --- a/compat/time.hpp +++ b/compat/time.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include namespace time_units { diff --git a/compat/timer.hpp b/compat/timer.hpp index 58e1c7d6..6af7430d 100644 --- a/compat/timer.hpp +++ b/compat/timer.hpp @@ -18,7 +18,6 @@ #endif #include -#include #include "time.hpp" -- cgit v1.2.3 From 6faab6ff960e2dd04aa35e8ef1aa62bce2976725 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 May 2017 03:31:00 +0200 Subject: add otr_prop for appending property strings --- cmake/opentrack-boilerplate.cmake | 78 +++++++++++++++++++++++++++++++++++++-- compat/CMakeLists.txt | 2 +- proto-fsuipc/CMakeLists.txt | 2 +- qxt-mini/CMakeLists.txt | 2 +- x-plane-plugin/CMakeLists.txt | 12 +++--- 5 files changed, 84 insertions(+), 12 deletions(-) (limited to 'compat') diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index 4c056c3e..bb596951 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -75,7 +75,7 @@ endfunction() function(otr_compat target) if(NOT MSVC) - set_property(SOURCE ${${target}-moc} APPEND_STRING PROPERTY COMPILE_FLAGS " -w -Wno-error") + otr_prop(SOURCE ${${target}-moc} COMPILE_FLAGS "-w -Wno-error") endif() if(WIN32) target_link_libraries(${target} dinput8 dxguid strmiids) @@ -97,8 +97,8 @@ function(otr_compat target) set(l-props "-Wl,--as-needed") endif() - set_property(TARGET ${target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${c-props} ${arg_COMPILE}") - set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS " ${l-props} ${arg_LINK}") + otr_prop(TARGET ${target} COMPILE_FLAGS "${c-props} ${arg_COMPILE}" + LINK_FLAGS "${l-props} ${arg_LINK}") endfunction() include(CMakeParseArguments) @@ -209,3 +209,75 @@ function(otr_module n_) set_property(GLOBAL APPEND PROPERTY opentrack-all-source-dirs "${CMAKE_CURRENT_SOURCE_DIR}") endfunction() +function(otr_prop type) + set(files "") + set(opts ${ARGN}) + # only SOURCE allows for multiple files + if(".${type}" STREQUAL ".SOURCE") + while(TRUE) + # keep popping first element off `opts' and adding to `files` + list(LENGTH opts len) + if(NOT "${len}" GREATER 0) + break() + endif() + list(GET opts 0 k) + string(FIND "${k}" "." idx1) + string(FIND "${k}" "/" idx2) + if("${idx1}" GREATER -1 AND "${idx2}" GREATER -1) + list(REMOVE_AT opts 0) + list(APPEND files "${k}") + else() + # not a pathname + break() + endif() + endwhile() + # no files, break early + # happens a few in the codebase + list(LENGTH files len) + if(len EQUAL 0) + return() + endif() + else() + # single file argument + set(opts "${ARGN}") + list(GET opts 0 files) + list(REMOVE_AT opts 0) + endif() + # must pass some properties at least + list(LENGTH opts len) + if(NOT "${len}" GREATER 1) + message(FATAL_ERROR "no properties given") + endif() + + # prop name but no value + list(LENGTH opts len) + math(EXPR mod "${len} % 2") + if(NOT "${mod}" EQUAL 0) + message(FATAL_ERROR "must specify parameter for each property") + endif() + + foreach(f ${files}) + set(opts-copy "${opts}") + + while(TRUE) + list(LENGTH opts-copy len) + if ("${len}" LESS 2) + break() + endif() + + # pop off two elements, set property + list(GET opts-copy 0 name) + list(GET opts-copy 1 value) + list(REMOVE_AT opts-copy 1 0) + + get_property(old "${type}" "${f}" PROPERTY "${name}") + if(".${old}" STREQUAL ".") + set(spc "") + else() + set(spc " ") + endif() + + set_property("${type}" "${f}" APPEND_STRING PROPERTY "${name}" "${spc}${value}") + endwhile() + endforeach() +endfunction() diff --git a/compat/CMakeLists.txt b/compat/CMakeLists.txt index 7655a223..33cb02bd 100644 --- a/compat/CMakeLists.txt +++ b/compat/CMakeLists.txt @@ -5,5 +5,5 @@ if(NOT WIN32 AND NOT APPLE) endif() if(CMAKE_COMPILER_IS_GNUCXX) - set_property(SOURCE nan.cpp APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-lto -fno-fast-math -fno-finite-math-only -O0") + otr_prop(SOURCE nan.cpp COMPILE_FLAGS "-fno-lto -fno-fast-math -fno-finite-math-only -O0") endif() diff --git a/proto-fsuipc/CMakeLists.txt b/proto-fsuipc/CMakeLists.txt index 24006644..99e362aa 100644 --- a/proto-fsuipc/CMakeLists.txt +++ b/proto-fsuipc/CMakeLists.txt @@ -5,7 +5,7 @@ if(WIN32) target_link_libraries(opentrack-proto-fsuipc ${SDK_FSUIPC}/FSUIPC_User.lib) target_include_directories(opentrack-proto-fsuipc SYSTEM PUBLIC ${SDK_FSUIPC}) if(MSVC) - set_property(TARGET opentrack-proto-fsuipc APPEND_STRING PROPERTY LINK_FLAGS " /NODEFAULTLIB:LIBC.lib") + otr_prop(TARGET opentrack-proto-fsuipc LINK_FLAGS "/NODEFAULTLIB:LIBC.lib") endif() endif() endif() diff --git a/qxt-mini/CMakeLists.txt b/qxt-mini/CMakeLists.txt index bf8a30f9..a6c2908e 100644 --- a/qxt-mini/CMakeLists.txt +++ b/qxt-mini/CMakeLists.txt @@ -3,6 +3,6 @@ if(UNIX OR APPLE) if(NOT APPLE) target_link_libraries(opentrack-qxt-mini X11) else() - set_property(TARGET opentrack-qxt-mini APPEND_STRING PROPERTY LINK_FLAGS " -framework Carbon -framework CoreFoundation") + otr_prop(TARGET opentrack-qxt-mini LINK_FLAGS "-framework Carbon -framework CoreFoundation") endif() endif() diff --git a/x-plane-plugin/CMakeLists.txt b/x-plane-plugin/CMakeLists.txt index abca2d68..db712590 100644 --- a/x-plane-plugin/CMakeLists.txt +++ b/x-plane-plugin/CMakeLists.txt @@ -7,18 +7,18 @@ if(LINUX OR APPLE) install(FILES ${opentrack-xplane-plugin-c} DESTINATION "${opentrack-doc-src-pfx}/opentrack-xplane-plugin") target_include_directories(opentrack-xplane-plugin SYSTEM PUBLIC ${SDK_XPLANE}/CHeaders ${SDK_XPLANE}/CHeaders/XPLM) - set(begin TARGET opentrack-xplane-plugin APPEND_STRING PROPERTY) + set(begin TARGET opentrack-xplane-plugin) if(APPLE) - set_property(${begin} COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM200 -DXPLM210 -framework XPLM -framework XPWidgets") - set_property(${begin} LINK_FLAGS "-F${SDK_XPLANE}/Libraries/Mac/ -framework XPLM -framework XPWidgets") + otr_prop(${begin} COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM200 -DXPLM210 -framework XPLM -framework XPWidgets" + LINK_FLAGS "-F${SDK_XPLANE}/Libraries/Mac/ -framework XPLM -framework XPWidgets") elseif(CMAKE_COMPILER_IS_GNUCXX) - set_property(${begin} COMPILE_FLAGS "-fPIC -DLIN -DXPLM200 -DXPLM210") - set_property(${begin} LINK_FLAGS "-rdynamic -nodefaultlibs -fPIC") + otr_prop(${begin} COMPILE_FLAGS "-fPIC -DLIN -DXPLM200 -DXPLM210" + LINK_FLAGS "-rdynamic -nodefaultlibs -fPIC") endif() if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_COMPILER_IS_CLANG) - set_property(${begin} LINK_FLAGS "-undefined_warning") + otr_prop(${begin} LINK_FLAGS "-undefined_warning") endif() set_target_properties(opentrack-xplane-plugin PROPERTIES -- cgit v1.2.3 From 8bab49e4bccb8f4a43d59d642a0501d80a9235d0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 May 2017 03:31:41 +0200 Subject: compat/euler: return using an initializer list Will come back to the same simplification elsewher.e --- compat/euler.cpp | 68 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 29 deletions(-) (limited to 'compat') diff --git a/compat/euler.cpp b/compat/euler.cpp index ab119d3e..f02365c9 100644 --- a/compat/euler.cpp +++ b/compat/euler.cpp @@ -11,13 +11,17 @@ euler_t OTR_COMPAT_EXPORT rmat_to_euler(const rmat& R) const double cy = sqrt(R(2,2)*R(2, 2) + R(2, 1)*R(2, 1)); const bool large_enough = cy > 1e-10; if (large_enough) - return euler_t(atan2(-R(1, 0), R(0, 0)), - atan2(R(2, 0), cy), - atan2(-R(2, 1), R(2, 2))); + return { + atan2(-R(1, 0), R(0, 0)), + atan2(R(2, 0), cy), + atan2(-R(2, 1), R(2, 2)) + }; else - return euler_t(atan2(R(0, 1), R(1, 1)), - atan2(R(2, 0), cy), - 0); + return { + atan2(R(0, 1), R(1, 1)), + atan2(R(2, 0), cy), + 0 + }; } // tait-bryan angles, not euler @@ -37,20 +41,20 @@ rmat OTR_COMPAT_EXPORT euler_to_rmat(const euler_t& input) const auto c3 = cos(B); const auto s3 = sin(B); - return rmat( - // z - c1 * c2, - c1 * s2 * s3 - c3 * s1, - s1 * s3 + c1 * c3 * s2, - // y - c2 * s1, - c1 * c3 + s1 * s2 * s3, - c3 * s1 * s2 - c1 * s3, - // x - -s2, - c2 * s3, - c2 * c3 - ); + return { + // z + c1*c2, + c1*s2*s3 - c3*s1, + s1*s3 + c1*c3*s2, + // y + c2*s1, + c1*c3 + s1*s2*s3, + c3*s1*s2 - c1*s3, + // x + -s2, + c2*s3, + c2*c3 + }; } // https://en.wikipedia.org/wiki/Davenport_chained_rotations#Tait.E2.80.93Bryan_chained_rotations @@ -67,9 +71,11 @@ void OTR_COMPAT_EXPORT tait_bryan_to_matrices(const euler_t& input, const double sin_phi = sin(phi); const double cos_phi = cos(phi); - r_roll = rmat(1, 0, 0, - 0, cos_phi, -sin_phi, - 0, sin_phi, cos_phi); + r_roll = { + 1, 0, 0, + 0, cos_phi, -sin_phi, + 0, sin_phi, cos_phi + }; } { @@ -77,9 +83,11 @@ void OTR_COMPAT_EXPORT tait_bryan_to_matrices(const euler_t& input, const double sin_theta = sin(theta); const double cos_theta = cos(theta); - r_pitch = rmat(cos_theta, 0, -sin_theta, - 0, 1, 0, - sin_theta, 0, cos_theta); + r_pitch = { + cos_theta, 0, -sin_theta, + 0, 1, 0, + sin_theta, 0, cos_theta + }; } { @@ -87,9 +95,11 @@ void OTR_COMPAT_EXPORT tait_bryan_to_matrices(const euler_t& input, const double sin_psi = sin(psi); const double cos_psi = cos(psi); - r_yaw = rmat(cos_psi, -sin_psi, 0, - sin_psi, cos_psi, 0, - 0, 0, 1); + r_yaw = { + cos_psi, -sin_psi, 0, + sin_psi, cos_psi, 0, + 0, 0, 1 + }; } } -- cgit v1.2.3